コード例 #1
0
func ExampleSimpleDB_DeleteAttributes() {
	svc := simpledb.New(session.New())

	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)
}
コード例 #2
0
func ExampleSimpleDB_BatchPutAttributes() {
	svc := simpledb.New(session.New())

	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)
}
コード例 #3
0
func TestResponseError(t *testing.T) {
	for _, test := range responseErrorTests {
		s := simpledb.New(unit.Session)
		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())
		}
	}
}
コード例 #4
0
func ExampleSimpleDB_CreateDomain() {
	svc := simpledb.New(session.New())

	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)
}
コード例 #5
0
func ExampleSimpleDB_ListDomains() {
	svc := simpledb.New(session.New())

	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)
}
コード例 #6
0
func ExampleSimpleDB_Select() {
	svc := simpledb.New(session.New())

	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)
}
コード例 #7
0
func TestStatusCodeError(t *testing.T) {
	for _, test := range statusCodeErrorTests {
		s := simpledb.New(unit.Session)
		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())
	}
}
コード例 #8
0
func ExampleSimpleDB_GetAttributes() {
	svc := simpledb.New(session.New())

	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)
}
コード例 #9
0
ファイル: client.go プロジェクト: bluet-deps/aws-sdk-go
func init() {
	Before("@simpledb", func() {
		World["client"] = simpledb.New(smoke.Session)
	})
}