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


Golang EndpointPropertiesCreateUpdateParameters.Origins方法代码示例

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


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

示例1: resourceArmCdnEndpointCreate

func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*ArmClient)
	cdnEndpointsClient := client.cdnEndpointsClient

	log.Printf("[INFO] preparing arguments for Azure ARM CDN EndPoint creation.")

	name := d.Get("name").(string)
	location := d.Get("location").(string)
	resGroup := d.Get("resource_group_name").(string)
	profileName := d.Get("profile_name").(string)
	http_allowed := d.Get("is_http_allowed").(bool)
	https_allowed := d.Get("is_https_allowed").(bool)
	compression_enabled := d.Get("is_compression_enabled").(bool)
	caching_behaviour := d.Get("querystring_caching_behaviour").(string)
	tags := d.Get("tags").(map[string]interface{})

	properties := cdn.EndpointPropertiesCreateUpdateParameters{
		IsHTTPAllowed:              &http_allowed,
		IsHTTPSAllowed:             &https_allowed,
		IsCompressionEnabled:       &compression_enabled,
		QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(caching_behaviour),
	}

	origins, originsErr := expandAzureRmCdnEndpointOrigins(d)
	if originsErr != nil {
		return fmt.Errorf("Error Building list of CDN Endpoint Origins: %s", originsErr)
	}
	if len(origins) > 0 {
		properties.Origins = &origins
	}

	if v, ok := d.GetOk("origin_host_header"); ok {
		host_header := v.(string)
		properties.OriginHostHeader = &host_header
	}

	if v, ok := d.GetOk("origin_path"); ok {
		origin_path := v.(string)
		properties.OriginPath = &origin_path
	}

	if v, ok := d.GetOk("content_types_to_compress"); ok {
		var content_types []string
		ctypes := v.(*schema.Set).List()
		for _, ct := range ctypes {
			str := ct.(string)
			content_types = append(content_types, str)
		}

		properties.ContentTypesToCompress = &content_types
	}

	cdnEndpoint := cdn.EndpointCreateParameters{
		Location:   &location,
		Properties: &properties,
		Tags:       expandTags(tags),
	}

	resp, err := cdnEndpointsClient.Create(name, cdnEndpoint, profileName, resGroup)
	if err != nil {
		return err
	}

	d.SetId(*resp.ID)

	log.Printf("[DEBUG] Waiting for CDN Endpoint (%s) to become available", name)
	stateConf := &resource.StateChangeConf{
		Pending: []string{"Accepted", "Updating", "Creating"},
		Target:  []string{"Succeeded"},
		Refresh: cdnEndpointStateRefreshFunc(client, resGroup, profileName, name),
		Timeout: 10 * time.Minute,
	}
	if _, err := stateConf.WaitForState(); err != nil {
		return fmt.Errorf("Error waiting for CDN Endpoint (%s) to become available: %s", name, err)
	}

	return resourceArmCdnEndpointRead(d, meta)
}
开发者ID:higebu,项目名称:terraform,代码行数:78,代码来源:resource_arm_cdn_endpoint.go

示例2: resourceArmCdnEndpointUpdate

func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) error {
	cdnEndpointsClient := meta.(*ArmClient).cdnEndpointsClient

	if !d.HasChange("tags") {
		return nil
	}

	name := d.Get("name").(string)
	resGroup := d.Get("resource_group_name").(string)
	profileName := d.Get("profile_name").(string)
	http_allowed := d.Get("is_http_allowed").(bool)
	https_allowed := d.Get("is_https_allowed").(bool)
	compression_enabled := d.Get("is_compression_enabled").(bool)
	caching_behaviour := d.Get("querystring_caching_behaviour").(string)
	newTags := d.Get("tags").(map[string]interface{})

	properties := cdn.EndpointPropertiesCreateUpdateParameters{
		IsHTTPAllowed:              &http_allowed,
		IsHTTPSAllowed:             &https_allowed,
		IsCompressionEnabled:       &compression_enabled,
		QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(caching_behaviour),
	}

	if d.HasChange("origin") {
		origins, originsErr := expandAzureRmCdnEndpointOrigins(d)
		if originsErr != nil {
			return fmt.Errorf("Error Building list of CDN Endpoint Origins: %s", originsErr)
		}
		if len(origins) > 0 {
			properties.Origins = &origins
		}
	}

	if d.HasChange("origin_host_header") {
		host_header := d.Get("origin_host_header").(string)
		properties.OriginHostHeader = &host_header
	}

	if d.HasChange("origin_path") {
		origin_path := d.Get("origin_path").(string)
		properties.OriginPath = &origin_path
	}

	if d.HasChange("content_types_to_compress") {
		var content_types []string
		ctypes := d.Get("content_types_to_compress").(*schema.Set).List()
		for _, ct := range ctypes {
			str := ct.(string)
			content_types = append(content_types, str)
		}

		properties.ContentTypesToCompress = &content_types
	}

	updateProps := cdn.EndpointUpdateParameters{
		Tags:       expandTags(newTags),
		Properties: &properties,
	}

	_, err := cdnEndpointsClient.Update(name, updateProps, profileName, resGroup)
	if err != nil {
		return fmt.Errorf("Error issuing Azure ARM update request to update CDN Endpoint %q: %s", name, err)
	}

	return resourceArmCdnEndpointRead(d, meta)
}
开发者ID:higebu,项目名称:terraform,代码行数:66,代码来源:resource_arm_cdn_endpoint.go

示例3: resourceArmCdnEndpointCreate

func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*ArmClient)
	cdnEndpointsClient := client.cdnEndpointsClient

	log.Printf("[INFO] preparing arguments for Azure ARM CDN EndPoint creation.")

	name := d.Get("name").(string)
	location := d.Get("location").(string)
	resGroup := d.Get("resource_group_name").(string)
	profileName := d.Get("profile_name").(string)
	http_allowed := d.Get("is_http_allowed").(bool)
	https_allowed := d.Get("is_https_allowed").(bool)
	compression_enabled := d.Get("is_compression_enabled").(bool)
	caching_behaviour := d.Get("querystring_caching_behaviour").(string)
	tags := d.Get("tags").(map[string]interface{})

	properties := cdn.EndpointPropertiesCreateUpdateParameters{
		IsHTTPAllowed:              &http_allowed,
		IsHTTPSAllowed:             &https_allowed,
		IsCompressionEnabled:       &compression_enabled,
		QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(caching_behaviour),
	}

	origins, originsErr := expandAzureRmCdnEndpointOrigins(d)
	if originsErr != nil {
		return fmt.Errorf("Error Building list of CDN Endpoint Origins: %s", originsErr)
	}
	if len(origins) > 0 {
		properties.Origins = &origins
	}

	if v, ok := d.GetOk("origin_host_header"); ok {
		host_header := v.(string)
		properties.OriginHostHeader = &host_header
	}

	if v, ok := d.GetOk("origin_path"); ok {
		origin_path := v.(string)
		properties.OriginPath = &origin_path
	}

	if v, ok := d.GetOk("content_types_to_compress"); ok {
		var content_types []string
		ctypes := v.(*schema.Set).List()
		for _, ct := range ctypes {
			str := ct.(string)
			content_types = append(content_types, str)
		}

		properties.ContentTypesToCompress = &content_types
	}

	cdnEndpoint := cdn.EndpointCreateParameters{
		Location:   &location,
		Properties: &properties,
		Tags:       expandTags(tags),
	}

	_, err := cdnEndpointsClient.Create(name, cdnEndpoint, profileName, resGroup, make(chan struct{}))
	if err != nil {
		return err
	}

	read, err := cdnEndpointsClient.Get(name, profileName, resGroup)
	if err != nil {
		return err
	}
	if read.ID == nil {
		return fmt.Errorf("Cannot read CND Endpoint %s/%s (resource group %s) ID", profileName, name, resGroup)
	}

	d.SetId(*read.ID)

	return resourceArmCdnEndpointRead(d, meta)
}
开发者ID:RezaDKhan,项目名称:terraform,代码行数:75,代码来源:resource_arm_cdn_endpoint.go


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