本文整理汇总了Golang中github.com/convox/rack/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/session.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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)
}
示例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)
}
示例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"))
}
示例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"))
}
示例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"])
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}