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


Golang CreateDirectoryInput.Description方法代码示例

本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/directoryservice.CreateDirectoryInput.Description方法的典型用法代码示例。如果您正苦于以下问题:Golang CreateDirectoryInput.Description方法的具体用法?Golang CreateDirectoryInput.Description怎么用?Golang CreateDirectoryInput.Description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/aws/aws-sdk-go/service/directoryservice.CreateDirectoryInput的用法示例。


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

示例1: createSimpleDirectoryService

func createSimpleDirectoryService(dsconn *directoryservice.DirectoryService, d *schema.ResourceData) (directoryId string, err error) {
	if _, ok := d.GetOk("size"); !ok {
		return "", fmt.Errorf("size is required for type = SimpleAD")
	}

	input := directoryservice.CreateDirectoryInput{
		Name:     aws.String(d.Get("name").(string)),
		Password: aws.String(d.Get("password").(string)),
		Size:     aws.String(d.Get("size").(string)),
	}

	if v, ok := d.GetOk("description"); ok {
		input.Description = aws.String(v.(string))
	}
	if v, ok := d.GetOk("short_name"); ok {
		input.ShortName = aws.String(v.(string))
	}

	input.VpcSettings, err = buildVpcSettings(d)
	if err != nil {
		return "", err
	}

	log.Printf("[DEBUG] Creating Simple Directory Service: %s", input)
	out, err := dsconn.CreateDirectory(&input)
	if err != nil {
		return "", err
	}
	log.Printf("[DEBUG] Simple Directory Service created: %s", out)

	return *out.DirectoryId, nil
}
开发者ID:paultyng,项目名称:terraform,代码行数:32,代码来源:resource_aws_directory_service_directory.go

示例2: resourceAwsDirectoryServiceDirectoryCreate

func resourceAwsDirectoryServiceDirectoryCreate(d *schema.ResourceData, meta interface{}) error {
	dsconn := meta.(*AWSClient).dsconn

	input := directoryservice.CreateDirectoryInput{
		Name:     aws.String(d.Get("name").(string)),
		Password: aws.String(d.Get("password").(string)),
		Size:     aws.String(d.Get("size").(string)),
	}

	if v, ok := d.GetOk("description"); ok {
		input.Description = aws.String(v.(string))
	}
	if v, ok := d.GetOk("short_name"); ok {
		input.ShortName = aws.String(v.(string))
	}

	if v, ok := d.GetOk("vpc_settings"); ok {
		settings := v.([]interface{})

		if len(settings) > 1 {
			return fmt.Errorf("Only a single vpc_settings block is expected")
		} else if len(settings) == 1 {
			s := settings[0].(map[string]interface{})
			var subnetIds []*string
			for _, id := range s["subnet_ids"].(*schema.Set).List() {
				subnetIds = append(subnetIds, aws.String(id.(string)))
			}

			vpcSettings := directoryservice.DirectoryVpcSettings{
				SubnetIds: subnetIds,
				VpcId:     aws.String(s["vpc_id"].(string)),
			}
			input.VpcSettings = &vpcSettings
		}
	}

	log.Printf("[DEBUG] Creating Directory Service: %s", input)
	out, err := dsconn.CreateDirectory(&input)
	if err != nil {
		return err
	}
	log.Printf("[DEBUG] Directory Service created: %s", out)
	d.SetId(*out.DirectoryId)

	// Wait for creation
	log.Printf("[DEBUG] Waiting for DS (%q) to become available", d.Id())
	stateConf := &resource.StateChangeConf{
		Pending: []string{"Requested", "Creating", "Created"},
		Target:  "Active",
		Refresh: func() (interface{}, string, error) {
			resp, err := dsconn.DescribeDirectories(&directoryservice.DescribeDirectoriesInput{
				DirectoryIds: []*string{aws.String(d.Id())},
			})
			if err != nil {
				log.Printf("Error during creation of DS: %q", err.Error())
				return nil, "", err
			}

			ds := resp.DirectoryDescriptions[0]
			log.Printf("[DEBUG] Creation of DS %q is in following stage: %q.",
				d.Id(), *ds.Stage)
			return ds, *ds.Stage, nil
		},
		Timeout: 10 * time.Minute,
	}
	if _, err := stateConf.WaitForState(); err != nil {
		return fmt.Errorf(
			"Error waiting for Directory Service (%s) to become available: %#v",
			d.Id(), err)
	}

	if v, ok := d.GetOk("alias"); ok {
		d.SetPartial("alias")

		input := directoryservice.CreateAliasInput{
			DirectoryId: aws.String(d.Id()),
			Alias:       aws.String(v.(string)),
		}

		log.Printf("[DEBUG] Assigning alias %q to DS directory %q",
			v.(string), d.Id())
		out, err := dsconn.CreateAlias(&input)
		if err != nil {
			return err
		}
		log.Printf("[DEBUG] Alias %q assigned to DS directory %q",
			*out.Alias, *out.DirectoryId)
	}

	return resourceAwsDirectoryServiceDirectoryUpdate(d, meta)
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:91,代码来源:resource_aws_directory_service_directory.go


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