本文整理汇总了Golang中github.com/convox/rack/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/session.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ExampleECS_CreateService
func ExampleECS_CreateService() {
svc := ecs.New(session.New())
params := &ecs.CreateServiceInput{
DesiredCount: aws.Int64(1), // Required
ServiceName: aws.String("String"), // Required
TaskDefinition: aws.String("String"), // Required
ClientToken: aws.String("String"),
Cluster: aws.String("String"),
DeploymentConfiguration: &ecs.DeploymentConfiguration{
MaximumPercent: aws.Int64(1),
MinimumHealthyPercent: aws.Int64(1),
},
LoadBalancers: []*ecs.LoadBalancer{
{ // Required
ContainerName: aws.String("String"),
ContainerPort: aws.Int64(1),
LoadBalancerName: aws.String("String"),
},
// More values...
},
Role: aws.String("String"),
}
resp, err := svc.CreateService(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:kuenzaa,项目名称:rack,代码行数:35,代码来源:examples_test.go
示例2: ExampleKinesis_PutRecords
func ExampleKinesis_PutRecords() {
svc := kinesis.New(session.New())
params := &kinesis.PutRecordsInput{
Records: []*kinesis.PutRecordsRequestEntry{ // Required
{ // Required
Data: []byte("PAYLOAD"), // Required
PartitionKey: aws.String("PartitionKey"), // Required
ExplicitHashKey: aws.String("HashKey"),
},
// More values...
},
StreamName: aws.String("StreamName"), // Required
}
resp, err := svc.PutRecords(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:kuenzaa,项目名称:rack,代码行数:26,代码来源:examples_test.go
示例3: ExampleCloudWatchLogs_PutLogEvents
func ExampleCloudWatchLogs_PutLogEvents() {
svc := cloudwatchlogs.New(session.New())
params := &cloudwatchlogs.PutLogEventsInput{
LogEvents: []*cloudwatchlogs.InputLogEvent{ // Required
{ // Required
Message: aws.String("EventMessage"), // Required
Timestamp: aws.Int64(1), // Required
},
// More values...
},
LogGroupName: aws.String("LogGroupName"), // Required
LogStreamName: aws.String("LogStreamName"), // Required
SequenceToken: aws.String("SequenceToken"),
}
resp, err := svc.PutLogEvents(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:kuenzaa,项目名称:rack,代码行数:27,代码来源:examples_test.go
示例4: 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:kuenzaa,项目名称:rack,代码行数:27,代码来源:build_test.go
示例5: TestInputService5ProtocolTestRecursiveShapesCase3
func TestInputService5ProtocolTestRecursiveShapesCase3(t *testing.T) {
sess := session.New()
svc := NewInputService5ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService5TestShapeInputShape{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
RecursiveStruct: &InputService5TestShapeRecursiveStructType{
NoRecurse: aws.String("foo"),
},
},
},
},
}
req, _ := svc.InputService5TestCaseOperation3Request(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":{"RecursiveStruct":{"RecursiveStruct":{"RecursiveStruct":{"NoRecurse":"foo"}}}}}`, 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:kuenzaa,项目名称:rack,代码行数:35,代码来源:build_test.go
示例6: 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:kuenzaa,项目名称:rack,代码行数:27,代码来源:unmarshal_test.go
示例7: ExampleKMS_ReEncrypt
func ExampleKMS_ReEncrypt() {
svc := kms.New(session.New())
params := &kms.ReEncryptInput{
CiphertextBlob: []byte("PAYLOAD"), // Required
DestinationKeyId: aws.String("KeyIdType"), // Required
DestinationEncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
GrantTokens: []*string{
aws.String("GrantTokenType"), // Required
// More values...
},
SourceEncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
}
resp, err := svc.ReEncrypt(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:kuenzaa,项目名称:rack,代码行数:31,代码来源:examples_test.go
示例8: ExampleS3_PutBucketTagging
func ExampleS3_PutBucketTagging() {
svc := s3.New(session.New())
params := &s3.PutBucketTaggingInput{
Bucket: aws.String("BucketName"), // Required
Tagging: &s3.Tagging{ // Required
TagSet: []*s3.Tag{ // Required
{ // Required
Key: aws.String("ObjectKey"), // Required
Value: aws.String("Value"), // Required
},
// More values...
},
},
}
resp, err := svc.PutBucketTagging(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:kuenzaa,项目名称:rack,代码行数:27,代码来源:examples_test.go
示例9: ExampleS3_UploadPart
func ExampleS3_UploadPart() {
svc := s3.New(session.New())
params := &s3.UploadPartInput{
Bucket: aws.String("BucketName"), // Required
Key: aws.String("ObjectKey"), // Required
PartNumber: aws.Int64(1), // Required
UploadId: aws.String("MultipartUploadId"), // Required
Body: bytes.NewReader([]byte("PAYLOAD")),
ContentLength: aws.Int64(1),
RequestPayer: aws.String("RequestPayer"),
SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
SSECustomerKey: aws.String("SSECustomerKey"),
SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
}
resp, err := svc.UploadPart(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:kuenzaa,项目名称:rack,代码行数:27,代码来源:examples_test.go
示例10: 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:kuenzaa,项目名称:rack,代码行数:27,代码来源:examples_test.go
示例11: ExampleS3_PutBucketReplication
func ExampleS3_PutBucketReplication() {
svc := s3.New(session.New())
params := &s3.PutBucketReplicationInput{
Bucket: aws.String("BucketName"), // Required
ReplicationConfiguration: &s3.ReplicationConfiguration{ // Required
Role: aws.String("Role"), // Required
Rules: []*s3.ReplicationRule{ // Required
{ // Required
Destination: &s3.Destination{ // Required
Bucket: aws.String("BucketName"), // Required
StorageClass: aws.String("StorageClass"),
},
Prefix: aws.String("Prefix"), // Required
Status: aws.String("ReplicationRuleStatus"), // Required
ID: aws.String("ID"),
},
// More values...
},
},
}
resp, err := svc.PutBucketReplication(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:kuenzaa,项目名称:rack,代码行数:33,代码来源:examples_test.go
示例12: ExampleECS_UpdateService
func ExampleECS_UpdateService() {
svc := ecs.New(session.New())
params := &ecs.UpdateServiceInput{
Service: aws.String("String"), // Required
Cluster: aws.String("String"),
DeploymentConfiguration: &ecs.DeploymentConfiguration{
MaximumPercent: aws.Int64(1),
MinimumHealthyPercent: aws.Int64(1),
},
DesiredCount: aws.Int64(1),
TaskDefinition: aws.String("String"),
}
resp, err := svc.UpdateService(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:kuenzaa,项目名称:rack,代码行数:25,代码来源:examples_test.go
示例13: ExampleECS_SubmitContainerStateChange
func ExampleECS_SubmitContainerStateChange() {
svc := ecs.New(session.New())
params := &ecs.SubmitContainerStateChangeInput{
Cluster: aws.String("String"),
ContainerName: aws.String("String"),
ExitCode: aws.Int64(1),
NetworkBindings: []*ecs.NetworkBinding{
{ // Required
BindIP: aws.String("String"),
ContainerPort: aws.Int64(1),
HostPort: aws.Int64(1),
Protocol: aws.String("TransportProtocol"),
},
// More values...
},
Reason: aws.String("String"),
Status: aws.String("String"),
Task: aws.String("String"),
}
resp, err := svc.SubmitContainerStateChange(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:kuenzaa,项目名称:rack,代码行数:32,代码来源:examples_test.go
示例14: ExampleECS_ListTasks
func ExampleECS_ListTasks() {
svc := ecs.New(session.New())
params := &ecs.ListTasksInput{
Cluster: aws.String("String"),
ContainerInstance: aws.String("String"),
DesiredStatus: aws.String("DesiredStatus"),
Family: aws.String("String"),
MaxResults: aws.Int64(1),
NextToken: aws.String("String"),
ServiceName: aws.String("String"),
StartedBy: aws.String("String"),
}
resp, err := svc.ListTasks(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:kuenzaa,项目名称:rack,代码行数:25,代码来源:examples_test.go
示例15: ExampleCloudWatch_DescribeAlarmsForMetric
func ExampleCloudWatch_DescribeAlarmsForMetric() {
svc := cloudwatch.New(session.New())
params := &cloudwatch.DescribeAlarmsForMetricInput{
MetricName: aws.String("MetricName"), // Required
Namespace: aws.String("Namespace"), // Required
Dimensions: []*cloudwatch.Dimension{
{ // Required
Name: aws.String("DimensionName"), // Required
Value: aws.String("DimensionValue"), // Required
},
// More values...
},
Period: aws.Int64(1),
Statistic: aws.String("Statistic"),
Unit: aws.String("StandardUnit"),
}
resp, err := svc.DescribeAlarmsForMetric(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:kuenzaa,项目名称:rack,代码行数:29,代码来源:examples_test.go
示例16: ExampleS3_UploadPartCopy
func ExampleS3_UploadPartCopy() {
svc := s3.New(session.New())
params := &s3.UploadPartCopyInput{
Bucket: aws.String("BucketName"), // Required
CopySource: aws.String("CopySource"), // Required
Key: aws.String("ObjectKey"), // Required
PartNumber: aws.Int64(1), // Required
UploadId: aws.String("MultipartUploadId"), // Required
CopySourceIfMatch: aws.String("CopySourceIfMatch"),
CopySourceIfModifiedSince: aws.Time(time.Now()),
CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
CopySourceRange: aws.String("CopySourceRange"),
CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
RequestPayer: aws.String("RequestPayer"),
SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
SSECustomerKey: aws.String("SSECustomerKey"),
SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
}
resp, err := svc.UploadPartCopy(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:kuenzaa,项目名称:rack,代码行数:34,代码来源:examples_test.go
示例17: TestOutputService1ProtocolTestScalarMembersCase1
func TestOutputService1ProtocolTestScalarMembersCase1(t *testing.T) {
sess := session.New()
svc := NewOutputService1ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
buf := bytes.NewReader([]byte("{\"Str\": \"myname\", \"Num\": 123, \"FalseBool\": false, \"TrueBool\": true, \"Float\": 1.2, \"Double\": 1.3, \"Long\": 200, \"Char\": \"a\"}"))
req, out := svc.OutputService1TestCaseOperation1Request(nil)
req.HTTPResponse = &http.Response{StatusCode: 200, Body: ioutil.NopCloser(buf), Header: http.Header{}}
// set headers
req.HTTPResponse.Header.Set("ImaHeader", "test")
req.HTTPResponse.Header.Set("X-Foo", "abc")
// 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, "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, "test", *out.ImaHeader)
assert.Equal(t, "abc", *out.ImaHeaderLocation)
assert.Equal(t, int64(200), *out.Long)
assert.Equal(t, int64(123), *out.Num)
assert.Equal(t, int64(200), *out.Status)
assert.Equal(t, "myname", *out.Str)
assert.Equal(t, true, *out.TrueBool)
}
开发者ID:kuenzaa,项目名称:rack,代码行数:32,代码来源:unmarshal_test.go
示例18: ExampleS3_DeleteObjects
func ExampleS3_DeleteObjects() {
svc := s3.New(session.New())
params := &s3.DeleteObjectsInput{
Bucket: aws.String("BucketName"), // Required
Delete: &s3.Delete{ // Required
Objects: []*s3.ObjectIdentifier{ // Required
{ // Required
Key: aws.String("ObjectKey"), // Required
VersionId: aws.String("ObjectVersionId"),
},
// More values...
},
Quiet: aws.Bool(true),
},
MFA: aws.String("MFA"),
RequestPayer: aws.String("RequestPayer"),
}
resp, err := svc.DeleteObjects(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:kuenzaa,项目名称:rack,代码行数:30,代码来源:examples_test.go
示例19: ExampleKMS_GenerateDataKeyWithoutPlaintext
func ExampleKMS_GenerateDataKeyWithoutPlaintext() {
svc := kms.New(session.New())
params := &kms.GenerateDataKeyWithoutPlaintextInput{
KeyId: aws.String("KeyIdType"), // Required
EncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
GrantTokens: []*string{
aws.String("GrantTokenType"), // Required
// More values...
},
KeySpec: aws.String("DataKeySpec"),
NumberOfBytes: aws.Int64(1),
}
resp, err := svc.GenerateDataKeyWithoutPlaintext(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:kuenzaa,项目名称:rack,代码行数:28,代码来源:examples_test.go
示例20: ExampleS3_CompleteMultipartUpload
func ExampleS3_CompleteMultipartUpload() {
svc := s3.New(session.New())
params := &s3.CompleteMultipartUploadInput{
Bucket: aws.String("BucketName"), // Required
Key: aws.String("ObjectKey"), // Required
UploadId: aws.String("MultipartUploadId"), // Required
MultipartUpload: &s3.CompletedMultipartUpload{
Parts: []*s3.CompletedPart{
{ // Required
ETag: aws.String("ETag"),
PartNumber: aws.Int64(1),
},
// More values...
},
},
RequestPayer: aws.String("RequestPayer"),
}
resp, err := svc.CompleteMultipartUpload(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:kuenzaa,项目名称:rack,代码行数:30,代码来源:examples_test.go
注:本文中的github.com/convox/rack/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/session.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论