func ExampleSimpleDB_DeleteAttributes() { svc := simpledb.New(nil) params := &simpledb.DeleteAttributesInput{ DomainName: aws.String("String"), // Required ItemName: aws.String("String"), // Required Attributes: []*simpledb.DeletableAttribute{ { // Required Name: aws.String("String"), // Required Value: aws.String("String"), }, // More values... }, Expected: &simpledb.UpdateCondition{ Exists: aws.Bool(true), Name: aws.String("String"), Value: aws.String("String"), }, } resp, err := svc.DeleteAttributes(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) }
func ExampleSimpleDB_BatchPutAttributes() { svc := simpledb.New(nil) params := &simpledb.BatchPutAttributesInput{ DomainName: aws.String("String"), // Required Items: []*simpledb.ReplaceableItem{ // Required { // Required Attributes: []*simpledb.ReplaceableAttribute{ // Required { // Required Name: aws.String("String"), // Required Value: aws.String("String"), // Required Replace: aws.Bool(true), }, // More values... }, Name: aws.String("String"), // Required }, // More values... }, } resp, err := svc.BatchPutAttributes(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) }
func TestResponseError(t *testing.T) { for _, test := range responseErrorTests { s := simpledb.New(nil) s.Handlers.Send.Clear() s.Handlers.Send.PushBack(func(r *request.Request) { xml := createXMLResponse(test.requestID, test.errors) body := ioutil.NopCloser(bytes.NewReader([]byte(xml))) r.HTTPResponse = &http.Response{ ContentLength: int64(len(xml)), StatusCode: test.scode, Status: test.status, Body: body, } }) _, err := s.CreateDomain(&simpledb.CreateDomainInput{ DomainName: aws.String("test-domain"), }) assert.Error(t, err) assert.Equal(t, test.code, err.(awserr.Error).Code()) assert.Equal(t, test.message, err.(awserr.Error).Message()) if len(test.errors) > 0 { assert.Equal(t, test.requestID, err.(awserr.RequestFailure).RequestID()) assert.Equal(t, test.scode, err.(awserr.RequestFailure).StatusCode()) } } }
func ExampleSimpleDB_CreateDomain() { svc := simpledb.New(nil) params := &simpledb.CreateDomainInput{ DomainName: aws.String("String"), // Required } resp, err := svc.CreateDomain(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) }
func ExampleSimpleDB_ListDomains() { svc := simpledb.New(nil) params := &simpledb.ListDomainsInput{ MaxNumberOfDomains: aws.Int64(1), NextToken: aws.String("String"), } resp, err := svc.ListDomains(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) }
func ExampleSimpleDB_Select() { svc := simpledb.New(nil) params := &simpledb.SelectInput{ SelectExpression: aws.String("String"), // Required ConsistentRead: aws.Bool(true), NextToken: aws.String("String"), } resp, err := svc.Select(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) }
func TestStatusCodeError(t *testing.T) { for _, test := range statusCodeErrorTests { s := simpledb.New(nil) s.Handlers.Send.Clear() s.Handlers.Send.PushBack(func(r *request.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte{})) r.HTTPResponse = &http.Response{ ContentLength: 0, StatusCode: test.scode, Status: test.status, Body: body, } }) _, err := s.CreateDomain(&simpledb.CreateDomainInput{ DomainName: aws.String("test-domain"), }) assert.Error(t, err) assert.Equal(t, test.code, err.(awserr.Error).Code()) assert.Equal(t, test.message, err.(awserr.Error).Message()) } }
func ExampleSimpleDB_GetAttributes() { svc := simpledb.New(nil) params := &simpledb.GetAttributesInput{ DomainName: aws.String("String"), // Required ItemName: aws.String("String"), // Required AttributeNames: []*string{ aws.String("String"), // Required // More values... }, ConsistentRead: aws.Bool(true), } resp, err := svc.GetAttributes(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) }
func init() { Before("@simpledb", func() { World["client"] = simpledb.New(nil) }) }