当前位置: 首页>>代码示例>>Golang>>正文


Golang simpledb.New函数代码示例

本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/simpledb.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ExampleSimpleDB_BatchPutAttributes

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)
}
开发者ID:skion,项目名称:amazon-ecs-cli,代码行数:32,代码来源:examples_test.go

示例2: ExampleSimpleDB_DeleteAttributes

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)
}
开发者ID:skion,项目名称:amazon-ecs-cli,代码行数:31,代码来源:examples_test.go

示例3: CreateAwsmDatabase

// CreateAwsmDatabase creates an awsm SimpleDB Domain
func CreateAwsmDatabase() error {

	svc := simpledb.New(session.New(&aws.Config{Region: aws.String("us-east-1")})) // TODO handle default region preference

	params := &simpledb.CreateDomainInput{
		DomainName: aws.String("awsm"),
	}
	_, err := svc.CreateDomain(params)

	if err != nil {
		return err
	}

	// Insert our default configs
	Insert("securitygroups", DefaultSecurityGroupClasses())
	Insert("vpcs", DefaultVpcClasses())
	Insert("subnets", DefaultSubnetClasses())
	Insert("instances", DefaultInstanceClasses())
	Insert("alarms", DefaultAlarms())
	Insert("images", DefaultImageClasses())
	Insert("scalingpolicies", DefaultScalingPolicyClasses())
	Insert("launchconfigurations", DefaultLaunchConfigurationClasses())
	Insert("loadbalancers", DefaultLoadBalancerClasses())
	Insert("volumes", DefaultVolumeClasses())
	Insert("snapshots", DefaultSnapshotClasses())
	Insert("autoscalegroups", DefaultAutoscaleGroupClasses())
	Insert("keypairs", DefaultKeyPairClasses())
	Insert("widgets", DefaultWidgets())

	return nil
}
开发者ID:murdinc,项目名称:awsm,代码行数:32,代码来源:database.go

示例4: ExampleSimpleDB_Select

func ExampleSimpleDB_Select() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := simpledb.New(sess)

	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)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:26,代码来源:examples_test.go

示例5: TestResponseError

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())
		}
	}
}
开发者ID:rifflock,项目名称:aws-sdk-go,代码行数:27,代码来源:unmarshall_error_test.go

示例6: ExampleSimpleDB_GetAttributes

func ExampleSimpleDB_GetAttributes() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := simpledb.New(sess)

	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)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:30,代码来源:examples_test.go

示例7: ExampleSimpleDB_ListDomains

func ExampleSimpleDB_ListDomains() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := simpledb.New(sess)

	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)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:25,代码来源:examples_test.go

示例8: DeleteItemsByType

// DeleteItemsByType batch deletes classes from SimpleDB
func DeleteItemsByType(classType string) error {
	svc := simpledb.New(session.New(&aws.Config{Region: aws.String("us-east-1")})) // TODO handle default region preference

	existingItems, err := GetItemsByType(classType)
	if err != nil {
		return err
	}

	params := &simpledb.BatchDeleteAttributesInput{
		DomainName: aws.String("awsm"),
		//Items:      deleteList,
	}

	for _, item := range existingItems {
		itemName := aws.StringValue(item.Name)
		params.Items = append(params.Items, &simpledb.DeletableItem{
			Name: item.Name,
		})

		terminal.Information("Deleting [" + classType + "/" + itemName + "] Configuration...")
	}

	_, err = svc.BatchDeleteAttributes(params)
	if err != nil {
		return err
	}

	terminal.Information("Done!")

	return nil
}
开发者ID:murdinc,项目名称:awsm,代码行数:32,代码来源:database.go

示例9: GetItemByName

// GetItemByName gets a SimpleDB item by its type and name
func GetItemByName(classType, className string) (*simpledb.Item, error) {

	svc := simpledb.New(session.New(&aws.Config{Region: aws.String("us-east-1")})) // TODO handle default region preference

	params := &simpledb.GetAttributesInput{
		DomainName:     aws.String("awsm"),
		ItemName:       aws.String(classType + "/" + className),
		ConsistentRead: aws.Bool(true),
	}
	resp, err := svc.GetAttributes(params)

	if err != nil {
		return &simpledb.Item{}, err
	}

	if len(resp.Attributes) < 1 {
		return &simpledb.Item{}, errors.New("Unable to find the [" + className + "] class in the database!")
	}

	item := &simpledb.Item{
		Name:       aws.String(classType + "/" + className),
		Attributes: resp.Attributes,
	}

	return item, nil
}
开发者ID:murdinc,项目名称:awsm,代码行数:27,代码来源:database.go

示例10: DeleteSimpleDBDomains

// DeleteSimpleDBDomains deletes one or more SimpleDB Domains
func DeleteSimpleDBDomains(search, region string) (err error) {

	domainList := new(SimpleDBDomains)

	// Check if we were given a region or not
	if region != "" {
		err = GetRegionSimpleDBDomains(aws.String(region), domainList, search)
	} else {
		domainList, _ = GetSimpleDBDomains(search)
	}

	if err != nil {
		terminal.ErrorLine("Error gathering SimpleDB domains list")
		return
	}

	if len(*domainList) > 0 {
		// Print the table
		domainList.PrintTable()
	} else {
		terminal.ErrorLine("No SimpleDB Domains found, Aborting!")
		return
	}

	// Confirm
	if !terminal.PromptBool("Are you sure you want to delete these SimpleDB Domains?") {
		terminal.ErrorLine("Aborting!")
		return
	}

	// Delete 'Em
	for _, domain := range *domainList {
		svc := simpledb.New(session.New(&aws.Config{Region: aws.String(domain.Region)}))

		params := &simpledb.DeleteDomainInput{
			DomainName: aws.String(domain.Name),
		}
		_, err = svc.DeleteDomain(params)
		if err != nil {
			terminal.ErrorLine("Error while deleting SimpleDB Domain [" + domain.Name + "] in [" + domain.Region + "], Aborting!")
			return
		}
		terminal.Information("Deleted SimpleDB Domain [" + domain.Name + "] in [" + domain.Region + "]!")
	}

	terminal.Information("Done!")

	return
}
开发者ID:murdinc,项目名称:awsm,代码行数:50,代码来源:simpledbs.go

示例11: CheckDB

// CheckDB checks for an awsm database
func CheckDB() bool {

	svc := simpledb.New(session.New(&aws.Config{Region: aws.String("us-east-1")})) // TODO handle default region preference

	params := &simpledb.DomainMetadataInput{
		DomainName: aws.String("awsm"), // Required
	}
	_, err := svc.DomainMetadata(params)

	if err != nil {
		return false
	}

	// TODO handle the response stats?
	return true
}
开发者ID:murdinc,项目名称:awsm,代码行数:17,代码来源:database.go

示例12: ExampleSimpleDB_CreateDomain

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)
}
开发者ID:skion,项目名称:amazon-ecs-cli,代码行数:18,代码来源:examples_test.go

示例13: DeleteWidget

// DeleteWidget deletes a widget from SimpleDB
func DeleteWidget(widgetName string) error {
	svc := simpledb.New(session.New(&aws.Config{Region: aws.String("us-east-1")})) // TODO handle default region preference

	itemName := "widgets/" + widgetName

	params := &simpledb.DeleteAttributesInput{
		DomainName: aws.String("awsm"),
		ItemName:   aws.String(itemName),
	}

	terminal.Information("Deleting [" + itemName + "] Configuration...")
	_, err := svc.DeleteAttributes(params)
	if err != nil {
		return err
	}

	terminal.Information("Done!")

	return nil
}
开发者ID:murdinc,项目名称:awsm,代码行数:21,代码来源:widgets.go

示例14: TestStatusCodeError

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())
	}
}
开发者ID:rifflock,项目名称:aws-sdk-go,代码行数:22,代码来源:unmarshall_error_test.go

示例15: GetItemsByType

// GetItemsByType returns all SimpleDB items by class type
func GetItemsByType(classType string) ([]*simpledb.Item, error) {

	svc := simpledb.New(session.New(&aws.Config{Region: aws.String("us-east-1")})) // TODO handle default region preference

	params := &simpledb.SelectInput{
		SelectExpression: aws.String(fmt.Sprintf("select * from awsm where classType = '%s'", classType)),
		ConsistentRead:   aws.Bool(true),
		//NextToken:        aws.String("String"),
	}

	resp, err := svc.Select(params)

	if err != nil {
		return []*simpledb.Item{}, err
	}

	if len(resp.Items) < 1 {
		return []*simpledb.Item{}, errors.New("Unable to find the [" + classType + "] class in the database!")
	}

	return resp.Items, nil
}
开发者ID:murdinc,项目名称:awsm,代码行数:23,代码来源:database.go


注:本文中的github.com/aws/aws-sdk-go/service/simpledb.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。