本文整理匯總了Golang中github.com/awslabs/aws-sdk-go/service/sns.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExampleSNS_CreatePlatformApplication
func ExampleSNS_CreatePlatformApplication() {
svc := sns.New(nil)
params := &sns.CreatePlatformApplicationInput{
Attributes: &map[string]*string{ // Required
"Key": aws.String("String"), // Required
// More values...
},
Name: aws.String("String"), // Required
Platform: aws.String("String"), // Required
}
resp, err := svc.CreatePlatformApplication(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, The SDK should alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例2: ExampleSNS_Unsubscribe
func ExampleSNS_Unsubscribe() {
svc := sns.New(nil)
params := &sns.UnsubscribeInput{
SubscriptionARN: aws.String("subscriptionARN"), // Required
}
resp, err := svc.Unsubscribe(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, The SDK should alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例3: ExampleSNS_AddPermission
func ExampleSNS_AddPermission() {
svc := sns.New(nil)
params := &sns.AddPermissionInput{
AWSAccountID: []*string{ // Required
aws.String("delegate"), // Required
// More values...
},
ActionName: []*string{ // Required
aws.String("action"), // Required
// More values...
},
Label: aws.String("label"), // Required
TopicARN: aws.String("topicARN"), // Required
}
resp, err := svc.AddPermission(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, The SDK should alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例4: ExampleSNS_Publish
func ExampleSNS_Publish() {
svc := sns.New(nil)
params := &sns.PublishInput{
Message: aws.String("message"), // Required
MessageAttributes: &map[string]*sns.MessageAttributeValue{
"Key": &sns.MessageAttributeValue{ // Required
DataType: aws.String("String"), // Required
BinaryValue: []byte("PAYLOAD"),
StringValue: aws.String("String"),
},
// More values...
},
MessageStructure: aws.String("messageStructure"),
Subject: aws.String("subject"),
TargetARN: aws.String("String"),
TopicARN: aws.String("topicARN"),
}
resp, err := svc.Publish(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, The SDK should alwsy return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例5: init
func init() {
Before("@sns", func() {
World["client"] = sns.New(nil)
})
}
示例6: TestInterface
func TestInterface(t *testing.T) {
assert.Implements(t, (*snsiface.SNSAPI)(nil), sns.New(nil))
}