本文整理匯總了Golang中github.com/Azure/azure-sdk-for-go/arm/cdn.EndpointPropertiesCreateUpdateParameters類的典型用法代碼示例。如果您正苦於以下問題:Golang EndpointPropertiesCreateUpdateParameters類的具體用法?Golang EndpointPropertiesCreateUpdateParameters怎麽用?Golang EndpointPropertiesCreateUpdateParameters使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了EndpointPropertiesCreateUpdateParameters類的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)
}
示例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)
}
示例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)
}