• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang simpledb.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CreateSimpleDBDomain

// CreateSimpleDBDomain creates a new SimpleDB Domain
func CreateSimpleDBDomain(domain, region string) error {

	// Validate the region
	if !regions.ValidRegion(region) {
		return errors.New("Region [" + region + "] is Invalid!")
	}

	svc := simpledb.New(session.New(&aws.Config{Region: aws.String(region)}))

	params := &simpledb.CreateDomainInput{
		DomainName: aws.String(domain),
	}

	terminal.Information("Creating SimpleDB Domain [" + domain + "] in [" + region + "]...")

	_, err := svc.CreateDomain(params)
	if err == nil {
		terminal.Information("Done!")
	}

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


示例17: ExampleSimpleDB_PutAttributes

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

	svc := simpledb.New(sess)

	params := &simpledb.PutAttributesInput{
		Attributes: []*simpledb.ReplaceableAttribute{ // Required
			{ // Required
				Name:    aws.String("String"), // Required
				Value:   aws.String("String"), // Required
				Replace: aws.Bool(true),
			},
			// More values...
		},
		DomainName: aws.String("String"), // Required
		ItemName:   aws.String("String"), // Required
		Expected: &simpledb.UpdateCondition{
			Exists: aws.Bool(true),
			Name:   aws.String("String"),
			Value:  aws.String("String"),
		},
	}
	resp, err := svc.PutAttributes(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,代码行数:38,代码来源:examples_test.go


示例18: GetRegionSimpleDBDomains

// GetRegionSimpleDBDomains returns a slice of a regions SimpleDB Domains into the provided SimpleDBDomains slice
func GetRegionSimpleDBDomains(region *string, domainList *SimpleDBDomains, search string) error {
	svc := simpledb.New(session.New(&aws.Config{Region: region}))
	result, err := svc.ListDomains(nil)
	if err != nil {
		//return err // TODO handle regions without services
	}

	domains := make(SimpleDBDomains, len(result.DomainNames))
	for i, domain := range result.DomainNames {

		domains[i] = SimpleDBDomain{
			Name:   aws.StringValue(domain),
			Region: aws.StringValue(region),
		}
	}

	if search != "" {
		term := regexp.MustCompile(search)
	Loop:
		for i, dn := range domains {
			rDomain := reflect.ValueOf(dn)

			for k := 0; k < rDomain.NumField(); k++ {
				sVal := rDomain.Field(k).String()

				if term.MatchString(sVal) {
					*domainList = append(*domainList, domains[i])
					continue Loop
				}
			}
		}
	} else {
		*domainList = append(*domainList, domains[:]...)
	}

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


示例19: ExampleSimpleDB_BatchDeleteAttributes

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

	svc := simpledb.New(sess)

	params := &simpledb.BatchDeleteAttributesInput{
		DomainName: aws.String("String"), // Required
		Items: []*simpledb.DeletableItem{ // Required
			{ // Required
				Name: aws.String("String"), // Required
				Attributes: []*simpledb.DeletableAttribute{
					{ // Required
						Name:  aws.String("String"), // Required
						Value: aws.String("String"),
					},
					// More values...
				},
			},
			// More values...
		},
	}
	resp, err := svc.BatchDeleteAttributes(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,代码行数:37,代码来源:examples_test.go


示例20: ExampleSimpleDB_DomainMetadata

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

	svc := simpledb.New(sess)

	params := &simpledb.DomainMetadataInput{
		DomainName: aws.String("String"), // Required
	}
	resp, err := svc.DomainMetadata(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,代码行数:24,代码来源:examples_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang sns.New函数代码示例发布时间:2022-05-24
下一篇:
Golang ses.New函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap