本文整理汇总了Golang中github.com/somathor/aws-sdk-go/aws/session.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestOutputService4ProtocolTestListsCase2
func TestOutputService4ProtocolTestListsCase2(t *testing.T) {
sess := session.New()
svc := NewOutputService4ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
buf := bytes.NewReader([]byte("{\"ListMember\": [\"a\", null], \"ListMemberMap\": [{}, null, null, {}], \"ListMemberStruct\": [{}, null, null, {}]}"))
req, out := svc.OutputService4TestCaseOperation2Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
jsonrpc.UnmarshalMeta(req)
jsonrpc.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "a", *out.ListMember[0])
assert.Nil(t, out.ListMember[1])
assert.Nil(t, out.ListMemberMap[1])
assert.Nil(t, out.ListMemberMap[2])
assert.Nil(t, out.ListMemberStruct[1])
assert.Nil(t, out.ListMemberStruct[2])
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:25,代码来源:unmarshal_test.go
示例2: TestInputService2ProtocolTestTimestampValuesCase1
func TestInputService2ProtocolTestTimestampValuesCase1(t *testing.T) {
sess := session.New()
svc := NewInputService2ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService2TestShapeInputService2TestCaseOperation1Input{
TimeArg: aws.Time(time.Unix(1422172800, 0)),
}
req, _ := svc.InputService2TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"TimeArg":1422172800}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:26,代码来源:build_test.go
示例3: TestInputService3ProtocolTestBase64EncodedBlobsCase1
func TestInputService3ProtocolTestBase64EncodedBlobsCase1(t *testing.T) {
sess := session.New()
svc := NewInputService3ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService3TestShapeInputShape{
BlobArg: []byte("foo"),
}
req, _ := svc.InputService3TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"BlobArg":"Zm9v"}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:26,代码来源:build_test.go
示例4: TestInputService5ProtocolTestRecursiveShapesCase6
func TestInputService5ProtocolTestRecursiveShapesCase6(t *testing.T) {
sess := session.New()
svc := NewInputService5ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService5TestShapeInputShape{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
RecursiveMap: map[string]*InputService5TestShapeRecursiveStructType{
"bar": {
NoRecurse: aws.String("bar"),
},
"foo": {
NoRecurse: aws.String("foo"),
},
},
},
}
req, _ := svc.InputService5TestCaseOperation6Request(input)
r := req.HTTPRequest
// build request
jsonrpc.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertJSON(t, `{"RecursiveStruct":{"RecursiveMap":{"foo":{"NoRecurse":"foo"},"bar":{"NoRecurse":"bar"}}}}`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
assert.Equal(t, "application/x-amz-json-1.1", r.Header.Get("Content-Type"))
assert.Equal(t, "com.amazonaws.foo.OperationName", r.Header.Get("X-Amz-Target"))
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:35,代码来源:build_test.go
示例5: ExampleRoute53_UpdateHealthCheck
func ExampleRoute53_UpdateHealthCheck() {
svc := route53.New(session.New())
params := &route53.UpdateHealthCheckInput{
HealthCheckId: aws.String("HealthCheckId"), // Required
ChildHealthChecks: []*string{
aws.String("HealthCheckId"), // Required
// More values...
},
FailureThreshold: aws.Int64(1),
FullyQualifiedDomainName: aws.String("FullyQualifiedDomainName"),
HealthCheckVersion: aws.Int64(1),
HealthThreshold: aws.Int64(1),
IPAddress: aws.String("IPAddress"),
Inverted: aws.Bool(true),
Port: aws.Int64(1),
ResourcePath: aws.String("ResourcePath"),
SearchString: aws.String("SearchString"),
}
resp, err := svc.UpdateHealthCheck(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:31,代码来源:examples_test.go
示例6: ExampleRoute53_ChangeTagsForResource
func ExampleRoute53_ChangeTagsForResource() {
svc := route53.New(session.New())
params := &route53.ChangeTagsForResourceInput{
ResourceId: aws.String("TagResourceId"), // Required
ResourceType: aws.String("TagResourceType"), // Required
AddTags: []*route53.Tag{
{ // Required
Key: aws.String("TagKey"),
Value: aws.String("TagValue"),
},
// More values...
},
RemoveTagKeys: []*string{
aws.String("TagKey"), // Required
// More values...
},
}
resp, err := svc.ChangeTagsForResource(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:30,代码来源:examples_test.go
示例7: TestOutputService1ProtocolTestScalarMembersCase1
func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
sess := session.New()
svc := NewOutputService1ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
buf := bytes.NewReader([]byte("<OperationNameResponse><Str>myname</Str><FooNum>123</FooNum><FalseBool>false</FalseBool><TrueBool>true</TrueBool><Float>1.2</Float><Double>1.3</Double><Long>200</Long><Char>a</Char><RequestId>request-id</RequestId></OperationNameResponse>"))
req, out := svc.OutputService1TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
// unmarshal response
ec2query.UnmarshalMeta(req)
ec2query.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "a", *out.Char)
assert.Equal(t, 1.3, *out.Double)
assert.Equal(t, false, *out.FalseBool)
assert.Equal(t, 1.2, *out.Float)
assert.Equal(t, int64(200), *out.Long)
assert.Equal(t, int64(123), *out.Num)
assert.Equal(t, "myname", *out.Str)
assert.Equal(t, true, *out.TrueBool)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:27,代码来源:unmarshal_test.go
示例8: ExampleSES_SendRawEmail
func ExampleSES_SendRawEmail() {
svc := ses.New(session.New())
params := &ses.SendRawEmailInput{
RawMessage: &ses.RawMessage{ // Required
Data: []byte("PAYLOAD"), // Required
},
Destinations: []*string{
aws.String("Address"), // Required
// More values...
},
FromArn: aws.String("AmazonResourceName"),
ReturnPathArn: aws.String("AmazonResourceName"),
Source: aws.String("Address"),
SourceArn: aws.String("AmazonResourceName"),
}
resp, err := svc.SendRawEmail(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:28,代码来源:examples_test.go
示例9: TestEC2RoleProviderExpiryWindowIsExpired
func TestEC2RoleProviderExpiryWindowIsExpired(t *testing.T) {
server := initTestServer("2014-12-16T01:51:37Z", false)
defer server.Close()
p := &ec2rolecreds.EC2RoleProvider{
Client: ec2metadata.New(session.New(), &aws.Config{Endpoint: aws.String(server.URL + "/latest")}),
ExpiryWindow: time.Hour * 1,
}
p.CurrentTime = func() time.Time {
return time.Date(2014, 12, 15, 0, 51, 37, 0, time.UTC)
}
assert.True(t, p.IsExpired(), "Expect creds to be expired before retrieve.")
_, err := p.Retrieve()
assert.Nil(t, err, "Expect no error, %v", err)
assert.False(t, p.IsExpired(), "Expect creds to not be expired after retrieve.")
p.CurrentTime = func() time.Time {
return time.Date(2014, 12, 16, 0, 55, 37, 0, time.UTC)
}
assert.True(t, p.IsExpired(), "Expect creds to be expired.")
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:25,代码来源:ec2_role_provider_test.go
示例10: TestInputService2ProtocolTestStructureWithLocationNameAndQueryNameAppliedToMembersCase1
func TestInputService2ProtocolTestStructureWithLocationNameAndQueryNameAppliedToMembersCase1(t *testing.T) {
sess := session.New()
svc := NewInputService2ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService2TestShapeInputService2TestCaseOperation1Input{
Bar: aws.String("val2"),
Foo: aws.String("val1"),
Yuck: aws.String("val3"),
}
req, _ := svc.InputService2TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&BarLocationName=val2&Foo=val1&Version=2014-01-01&yuckQueryName=val3`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:26,代码来源:build_test.go
示例11: TestInputService3ProtocolTestNestedStructureMembersCase1
func TestInputService3ProtocolTestNestedStructureMembersCase1(t *testing.T) {
sess := session.New()
svc := NewInputService3ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService3TestShapeInputService3TestCaseOperation1Input{
StructArg: &InputService3TestShapeStructType{
ScalarArg: aws.String("foo"),
},
}
req, _ := svc.InputService3TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&Struct.Scalar=foo&Version=2014-01-01`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:26,代码来源:build_test.go
示例12: ExampleOpsWorks_CreateDeployment
func ExampleOpsWorks_CreateDeployment() {
svc := opsworks.New(session.New())
params := &opsworks.CreateDeploymentInput{
Command: &opsworks.DeploymentCommand{ // Required
Name: aws.String("DeploymentCommandName"), // Required
Args: map[string][]*string{
"Key": { // Required
aws.String("String"), // Required
// More values...
},
// More values...
},
},
StackId: aws.String("String"), // Required
AppId: aws.String("String"),
Comment: aws.String("String"),
CustomJson: aws.String("String"),
InstanceIds: []*string{
aws.String("String"), // Required
// More values...
},
}
resp, err := svc.CreateDeployment(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:35,代码来源:examples_test.go
示例13: ExampleRoute53_ListChangeBatchesByRRSet
func ExampleRoute53_ListChangeBatchesByRRSet() {
svc := route53.New(session.New())
params := &route53.ListChangeBatchesByRRSetInput{
EndDate: aws.String("Date"), // Required
HostedZoneId: aws.String("ResourceId"), // Required
Name: aws.String("DNSName"), // Required
StartDate: aws.String("Date"), // Required
Type: aws.String("RRType"), // Required
Marker: aws.String("PageMarker"),
MaxItems: aws.String("PageMaxItems"),
SetIdentifier: aws.String("ResourceRecordSetIdentifier"),
}
resp, err := svc.ListChangeBatchesByRRSet(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:25,代码来源:examples_test.go
示例14: ExampleOpsWorks_UpdateInstance
func ExampleOpsWorks_UpdateInstance() {
svc := opsworks.New(session.New())
params := &opsworks.UpdateInstanceInput{
InstanceId: aws.String("String"), // Required
AgentVersion: aws.String("String"),
AmiId: aws.String("String"),
Architecture: aws.String("Architecture"),
AutoScalingType: aws.String("AutoScalingType"),
EbsOptimized: aws.Bool(true),
Hostname: aws.String("String"),
InstallUpdatesOnBoot: aws.Bool(true),
InstanceType: aws.String("String"),
LayerIds: []*string{
aws.String("String"), // Required
// More values...
},
Os: aws.String("String"),
SshKeyName: aws.String("String"),
}
resp, err := svc.UpdateInstance(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:32,代码来源:examples_test.go
示例15: ExampleOpsWorks_CreateApp
func ExampleOpsWorks_CreateApp() {
svc := opsworks.New(session.New())
params := &opsworks.CreateAppInput{
Name: aws.String("String"), // Required
StackId: aws.String("String"), // Required
Type: aws.String("AppType"), // Required
AppSource: &opsworks.Source{
Password: aws.String("String"),
Revision: aws.String("String"),
SshKey: aws.String("String"),
Type: aws.String("SourceType"),
Url: aws.String("String"),
Username: aws.String("String"),
},
Attributes: map[string]*string{
"Key": aws.String("String"), // Required
// More values...
},
DataSources: []*opsworks.DataSource{
{ // Required
Arn: aws.String("String"),
DatabaseName: aws.String("String"),
Type: aws.String("String"),
},
// More values...
},
Description: aws.String("String"),
Domains: []*string{
aws.String("String"), // Required
// More values...
},
EnableSsl: aws.Bool(true),
Environment: []*opsworks.EnvironmentVariable{
{ // Required
Key: aws.String("String"), // Required
Value: aws.String("String"), // Required
Secure: aws.Bool(true),
},
// More values...
},
Shortname: aws.String("String"),
SslConfiguration: &opsworks.SslConfiguration{
Certificate: aws.String("String"), // Required
PrivateKey: aws.String("String"), // Required
Chain: aws.String("String"),
},
}
resp, err := svc.CreateApp(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:60,代码来源:examples_test.go
示例16: ExampleOpsWorks_RegisterInstance
func ExampleOpsWorks_RegisterInstance() {
svc := opsworks.New(session.New())
params := &opsworks.RegisterInstanceInput{
StackId: aws.String("String"), // Required
Hostname: aws.String("String"),
InstanceIdentity: &opsworks.InstanceIdentity{
Document: aws.String("String"),
Signature: aws.String("String"),
},
PrivateIp: aws.String("String"),
PublicIp: aws.String("String"),
RsaPublicKey: aws.String("String"),
RsaPublicKeyFingerprint: aws.String("String"),
}
resp, err := svc.RegisterInstance(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:27,代码来源:examples_test.go
示例17: TestInputService4ProtocolTestListTypesCase1
func TestInputService4ProtocolTestListTypesCase1(t *testing.T) {
sess := session.New()
svc := NewInputService4ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService4TestShapeInputService4TestCaseOperation1Input{
ListArg: []*string{
aws.String("foo"),
aws.String("bar"),
aws.String("baz"),
},
}
req, _ := svc.InputService4TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
awstesting.AssertQuery(t, `Action=OperationName&ListArg.1=foo&ListArg.2=bar&ListArg.3=baz&Version=2014-01-01`, util.Trim(string(body)))
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:28,代码来源:build_test.go
示例18: ExampleS3_CreateBucket
func ExampleS3_CreateBucket() {
svc := s3.New(session.New())
params := &s3.CreateBucketInput{
Bucket: aws.String("BucketName"), // Required
ACL: aws.String("BucketCannedACL"),
CreateBucketConfiguration: &s3.CreateBucketConfiguration{
LocationConstraint: aws.String("BucketLocationConstraint"),
},
GrantFullControl: aws.String("GrantFullControl"),
GrantRead: aws.String("GrantRead"),
GrantReadACP: aws.String("GrantReadACP"),
GrantWrite: aws.String("GrantWrite"),
GrantWriteACP: aws.String("GrantWriteACP"),
}
resp, err := svc.CreateBucket(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:27,代码来源:examples_test.go
示例19: ExampleRoute53_CreateHostedZone
func ExampleRoute53_CreateHostedZone() {
svc := route53.New(session.New())
params := &route53.CreateHostedZoneInput{
CallerReference: aws.String("Nonce"), // Required
Name: aws.String("DNSName"), // Required
DelegationSetId: aws.String("ResourceId"),
HostedZoneConfig: &route53.HostedZoneConfig{
Comment: aws.String("ResourceDescription"),
PrivateZone: aws.Bool(true),
},
VPC: &route53.VPC{
VPCId: aws.String("VPCId"),
VPCRegion: aws.String("VPCRegion"),
},
}
resp, err := svc.CreateHostedZone(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:28,代码来源:examples_test.go
示例20: TestOutputService9ProtocolTestSupportsHeaderMapsCase1
func TestOutputService9ProtocolTestSupportsHeaderMapsCase1(t *testing.T) {
sess := session.New()
svc := NewOutputService9ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
buf := bytes.NewReader([]byte("{}"))
req, out := svc.OutputService9TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
req.HTTPResponse.Header.Set("Content-Length", "10")
req.HTTPResponse.Header.Set("X-Bam", "boo")
req.HTTPResponse.Header.Set("X-Foo", "bar")
// unmarshal response
restjson.UnmarshalMeta(req)
restjson.Unmarshal(req)
assert.NoError(t, req.Error)
// assert response
assert.NotNil(t, out) // ensure out variable is used
assert.Equal(t, "10", *out.AllHeaders["Content-Length"])
assert.Equal(t, "boo", *out.AllHeaders["X-Bam"])
assert.Equal(t, "bar", *out.AllHeaders["X-Foo"])
assert.Equal(t, "boo", *out.PrefixedHeaders["Bam"])
assert.Equal(t, "bar", *out.PrefixedHeaders["Foo"])
}
开发者ID:somathor,项目名称:aws-sdk-go,代码行数:27,代码来源:unmarshal_test.go
注:本文中的github.com/somathor/aws-sdk-go/aws/session.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论