func ExampleSQS_ChangeMessageVisibilityBatch() { svc := sqs.New(nil) params := &sqs.ChangeMessageVisibilityBatchInput{ Entries: []*sqs.ChangeMessageVisibilityBatchRequestEntry{ // Required { // Required ID: aws.String("String"), // Required ReceiptHandle: aws.String("String"), // Required VisibilityTimeout: aws.Int64(1), }, // More values... }, QueueURL: aws.String("String"), // Required } resp, err := svc.ChangeMessageVisibilityBatch(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 always return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.Prettify(resp)) }
func ExampleSQS_SetQueueAttributes() { svc := sqs.New(nil) params := &sqs.SetQueueAttributesInput{ Attributes: map[string]*string{ // Required "Key": aws.String("String"), // Required // More values... }, QueueURL: aws.String("String"), // Required } resp, err := svc.SetQueueAttributes(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 always return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.Prettify(resp)) }
func ExampleSQS_GetQueueURL() { svc := sqs.New(nil) params := &sqs.GetQueueURLInput{ QueueName: aws.String("String"), // Required QueueOwnerAWSAccountID: aws.String("String"), } resp, err := svc.GetQueueURL(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 always return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.Prettify(resp)) }
func ExampleSQS_SendMessageBatch() { svc := sqs.New(nil) params := &sqs.SendMessageBatchInput{ Entries: []*sqs.SendMessageBatchRequestEntry{ // Required { // Required ID: aws.String("String"), // Required MessageBody: aws.String("String"), // Required DelaySeconds: aws.Int64(1), MessageAttributes: map[string]*sqs.MessageAttributeValue{ "Key": { // Required DataType: aws.String("String"), // Required BinaryListValues: [][]byte{ []byte("PAYLOAD"), // Required // More values... }, BinaryValue: []byte("PAYLOAD"), StringListValues: []*string{ aws.String("String"), // Required // More values... }, StringValue: aws.String("String"), }, // More values... }, }, // More values... }, QueueURL: aws.String("String"), // Required } resp, err := svc.SendMessageBatch(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 always return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.Prettify(resp)) }
func TestFlattenedTraits(t *testing.T) { s := sqs.New(nil) _, err := s.DeleteMessageBatch(&sqs.DeleteMessageBatchInput{ QueueURL: aws.String("QUEUE"), Entries: []*sqs.DeleteMessageBatchRequestEntry{ { ID: aws.String("TEST"), ReceiptHandle: aws.String("RECEIPT"), }, }, }) assert.Error(t, err) assert.Equal(t, "InvalidAddress", err.Code()) assert.Equal(t, "The address QUEUE is not valid for this endpoint.", err.Message()) }
func TestSendMessageChecksumInvalidNoValidation(t *testing.T) { s := sqs.New(&aws.Config{ DisableParamValidation: aws.Bool(true), DisableComputeChecksums: aws.Bool(true), }) s.Handlers.Send.Clear() req, _ := s.SendMessageRequest(&sqs.SendMessageInput{ MessageBody: aws.String("test"), }) req.Handlers.Send.PushBack(func(r *aws.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} r.Data = &sqs.SendMessageOutput{ MD5OfMessageBody: aws.String("000"), MessageID: aws.String("12345"), } }) err := req.Send() assert.NoError(t, err) }
func ExampleSQS_ReceiveMessage() { svc := sqs.New(nil) params := &sqs.ReceiveMessageInput{ QueueURL: aws.String("String"), // Required AttributeNames: []*string{ aws.String("QueueAttributeName"), // Required // More values... }, MaxNumberOfMessages: aws.Int64(1), MessageAttributeNames: []*string{ aws.String("MessageAttributeName"), // Required // More values... }, VisibilityTimeout: aws.Int64(1), WaitTimeSeconds: aws.Int64(1), } resp, err := svc.ReceiveMessage(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 always return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.Prettify(resp)) }
"io/ioutil" "net/http" "testing" "github.com/gunosy/aws-sdk-go/aws" "github.com/gunosy/aws-sdk-go/aws/awserr" "github.com/gunosy/aws-sdk-go/internal/test/unit" "github.com/gunosy/aws-sdk-go/service/sqs" "github.com/stretchr/testify/assert" ) var _ = unit.Imported var svc = func() *sqs.SQS { s := sqs.New(&aws.Config{ DisableParamValidation: aws.Bool(true), }) s.Handlers.Send.Clear() return s }() func TestSendMessageChecksum(t *testing.T) { req, _ := svc.SendMessageRequest(&sqs.SendMessageInput{ MessageBody: aws.String("test"), }) req.Handlers.Send.PushBack(func(r *aws.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} r.Data = &sqs.SendMessageOutput{ MD5OfMessageBody: aws.String("098f6bcd4621d373cade4e832627b4f6"), MessageID: aws.String("12345"),
func TestInterface(t *testing.T) { assert.Implements(t, (*sqsiface.SQSAPI)(nil), sqs.New(nil)) }
func init() { Before("@sqs", func() { World["client"] = sqs.New(nil) }) }