diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go new file mode 100644 index 000000000000..1581cdfe39bd --- /dev/null +++ b/azurerm/helpers/validate/cdn.go @@ -0,0 +1,77 @@ +package validate + +import ( + "fmt" + "regexp" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" +) + +func EndpointDeliveryRuleName() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$"), + "The Delivery Rule Name must start with a letter any may only contain letters and numbers.", + ) +} + +func RuleActionCacheExpirationDuration() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile(`^(\d+\.)?([0-1][0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9]$`), + "The Cache duration must be in this format [d.]hh:mm:ss.", + ) +} + +func RuleActionUrlRedirectPath() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^(/.*)?$"), + "The Url Redirect Path must start with a slash.", + ) +} + +func RuleActionUrlRedirectQueryString() schema.SchemaValidateFunc { + return func(i interface{}, s string) ([]string, []error) { + querystring := i.(string) + + if len(querystring) > 100 { + return nil, []error{fmt.Errorf("The Url Query String's max length is 100.")} + } + + re := regexp.MustCompile("^[?&]") + if re.MatchString(querystring) { + return nil, []error{fmt.Errorf("The Url Query String must not start with a question mark or ampersand.")} + } + + kvre := regexp.MustCompile("^[^?&]+=[^?&]+$") + kvs := strings.Split(querystring, "&") + for _, kv := range kvs { + if len(kv) > 0 && !kvre.MatchString(kv) { + return nil, []error{fmt.Errorf("The Url Query String must be in = format and separated by an ampersand.")} + } + } + + return nil, nil + } +} + +func RuleActionUrlRedirectFragment() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^([^#].*)?$"), + "The Url Fragment must not start with a hash.", + ) +} + +func RuleActionUrlRewriteSourcePattern() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^/[^\n]{0,259}$"), + "The Url Rewrite Source Pattern must start with a slash and can not have more than 260 characters.", + ) +} + +func RuleActionUrlRewriteDestination() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^/[^\n]{0,259}$"), + "The Url Rewrite Destination must start with a slash and can not have more than 260 characters.", + ) +} diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go new file mode 100644 index 000000000000..357f032d64d9 --- /dev/null +++ b/azurerm/helpers/validate/cdn_test.go @@ -0,0 +1,330 @@ +package validate + +import ( + "testing" +) + +func TestCdnEndpointDeliveryPolicyRuleName(t *testing.T) { + cases := []struct { + Name string + ShouldError bool + }{ + { + Name: "", + ShouldError: true, + }, + { + Name: "a", + ShouldError: false, + }, + { + Name: "Z", + ShouldError: false, + }, + { + Name: "3", + ShouldError: true, + }, + { + Name: "abc123", + ShouldError: false, + }, + { + Name: "aBc123", + ShouldError: false, + }, + { + Name: "aBc 123", + ShouldError: true, + }, + { + Name: "aBc&123", + ShouldError: true, + }, + } + + for _, tc := range cases { + t.Run(tc.Name, func(t *testing.T) { + _, errors := EndpointDeliveryRuleName()(tc.Name, "name") + + hasErrors := len(errors) > 0 + if !hasErrors && tc.ShouldError { + t.Fatalf("Expected an error but didn't get one for %q", tc.Name) + } + + if hasErrors && !tc.ShouldError { + t.Fatalf("Expected to get no errors for %q but got %d", tc.Name, len(errors)) + } + }) + } +} + +func TestRuleActionUrlRedirectPath(t *testing.T) { + cases := []struct { + Path string + ShouldError bool + }{ + { + Path: "", + ShouldError: false, + }, + { + Path: "a", + ShouldError: true, + }, + { + Path: "/", + ShouldError: false, + }, + { + Path: "/abc", + ShouldError: false, + }, + } + + for _, tc := range cases { + t.Run(tc.Path, func(t *testing.T) { + _, errors := RuleActionUrlRedirectPath()(tc.Path, "path") + + hasErrors := len(errors) > 0 + if !hasErrors && tc.ShouldError { + t.Fatalf("Expected an error but didn't get one for %q", tc.Path) + } + + if hasErrors && !tc.ShouldError { + t.Fatalf("Expected to get no errors for %q but got %d", tc.Path, len(errors)) + } + }) + } +} + +func TestRuleActionUrlRedirectQueryString(t *testing.T) { + cases := []struct { + QueryString string + ShouldError bool + }{ + { + QueryString: "", + ShouldError: false, + }, + { + QueryString: "a", + ShouldError: true, + }, + { + QueryString: "&a=b", + ShouldError: true, + }, + { + QueryString: "?a=b", + ShouldError: true, + }, + { + QueryString: "a=b", + ShouldError: false, + }, + { + QueryString: "a=b&", + ShouldError: false, + }, + { + QueryString: "a=b&c=d", + ShouldError: false, + }, + } + + for _, tc := range cases { + t.Run(tc.QueryString, func(t *testing.T) { + _, errors := RuleActionUrlRedirectQueryString()(tc.QueryString, "query_string") + + hasErrors := len(errors) > 0 + if !hasErrors && tc.ShouldError { + t.Fatalf("Expected an error but didn't get one for %q", tc.QueryString) + } + + if hasErrors && !tc.ShouldError { + t.Fatalf("Expected to get no errors for %q but got %d", tc.QueryString, len(errors)) + } + }) + } +} + +func TestRuleActionUrlRedirectFragment(t *testing.T) { + cases := []struct { + Fragment string + ShouldError bool + }{ + { + Fragment: "", + ShouldError: false, + }, + { + Fragment: "a", + ShouldError: false, + }, + { + Fragment: "#", + ShouldError: true, + }, + { + Fragment: "#5fgdfg", + ShouldError: true, + }, + { + Fragment: "5fgdfg", + ShouldError: false, + }, + } + + for _, tc := range cases { + t.Run(tc.Fragment, func(t *testing.T) { + _, errors := RuleActionUrlRedirectFragment()(tc.Fragment, "fragment") + + hasErrors := len(errors) > 0 + if !hasErrors && tc.ShouldError { + t.Fatalf("Expected an error but didn't get one for %q", tc.Fragment) + } + + if hasErrors && !tc.ShouldError { + t.Fatalf("Expected to get no errors for %q but got %d", tc.Fragment, len(errors)) + } + }) + } +} + +func TestRuleActionCacheExpirationDuration(t *testing.T) { + cases := []struct { + Duration string + ShouldError bool + }{ + { + Duration: "", + ShouldError: true, + }, + { + Duration: "23:44:21", + ShouldError: false, + }, + { + Duration: "9.23:44:21", + ShouldError: false, + }, + { + Duration: ".23:44:21", + ShouldError: true, + }, + { + Duration: "9.24:44:21", + ShouldError: true, + }, + { + Duration: "9.12:61:21", + ShouldError: true, + }, + { + Duration: "9.11:44:91", + ShouldError: true, + }, + } + + for _, tc := range cases { + t.Run(tc.Duration, func(t *testing.T) { + _, errors := RuleActionCacheExpirationDuration()(tc.Duration, "duration") + + hasErrors := len(errors) > 0 + if !hasErrors && tc.ShouldError { + t.Fatalf("Expected an error but didn't get one for %q", tc.Duration) + } + + if hasErrors && !tc.ShouldError { + t.Fatalf("Expected to get no errors for %q but got %d", tc.Duration, len(errors)) + } + }) + } +} + +func TestRuleActionUrlRewriteSourcePattern(t *testing.T) { + cases := []struct { + SourcePattern string + ShouldError bool + }{ + { + SourcePattern: "", + ShouldError: true, + }, + { + SourcePattern: "a", + ShouldError: true, + }, + { + SourcePattern: "/", + ShouldError: false, + }, + { + SourcePattern: "/abc", + ShouldError: false, + }, + { + SourcePattern: "/abc\n", + ShouldError: true, + }, + } + + for _, tc := range cases { + t.Run(tc.SourcePattern, func(t *testing.T) { + _, errors := RuleActionUrlRewriteSourcePattern()(tc.SourcePattern, "source_pattern") + + hasErrors := len(errors) > 0 + if !hasErrors && tc.ShouldError { + t.Fatalf("Expected an error but didn't get one for %q", tc.SourcePattern) + } + + if hasErrors && !tc.ShouldError { + t.Fatalf("Expected to get no errors for %q but got %d", tc.SourcePattern, len(errors)) + } + }) + } +} + +func TestRuleActionUrlRewriteSourceDestination(t *testing.T) { + cases := []struct { + Destination string + ShouldError bool + }{ + { + Destination: "", + ShouldError: true, + }, + { + Destination: "a", + ShouldError: true, + }, + { + Destination: "/", + ShouldError: false, + }, + { + Destination: "/abc", + ShouldError: false, + }, + { + Destination: "/abc\n", + ShouldError: true, + }, + } + + for _, tc := range cases { + t.Run(tc.Destination, func(t *testing.T) { + _, errors := RuleActionUrlRewriteDestination()(tc.Destination, "destination") + + hasErrors := len(errors) > 0 + if !hasErrors && tc.ShouldError { + t.Fatalf("Expected an error but didn't get one for %q", tc.Destination) + } + + if hasErrors && !tc.ShouldError { + t.Fatalf("Expected to get no errors for %q but got %d", tc.Destination, len(errors)) + } + }) + } +} diff --git a/azurerm/internal/services/cdn/client/client.go b/azurerm/internal/services/cdn/client/client.go index befb82529324..8a62f611253b 100644 --- a/azurerm/internal/services/cdn/client/client.go +++ b/azurerm/internal/services/cdn/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn" + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) diff --git a/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go new file mode 100644 index 000000000000..247aceef8eaa --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go @@ -0,0 +1,84 @@ +package deliveryruleactions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func CacheExpiration() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.BypassCache), + string(cdn.Override), + string(cdn.SetIfMissing), + }, false), + }, + + "duration": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.RuleActionCacheExpirationDuration(), + }, + }, + } +} + +func ExpandArmCdnEndpointActionCacheExpiration(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + cacheExpirationAction := cdn.DeliveryRuleCacheExpirationAction{ + Name: cdn.NameCacheExpiration, + Parameters: &cdn.CacheExpirationActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters"), + CacheBehavior: cdn.CacheBehavior(item["behavior"].(string)), + CacheType: utils.String("All"), + }, + } + + if duration := item["duration"].(string); duration != "" { + if cacheExpirationAction.Parameters.CacheBehavior == cdn.BypassCache { + return nil, fmt.Errorf("Cache expiration duration must not be set when using behavior `BypassCache`") + } + + cacheExpirationAction.Parameters.CacheDuration = utils.String(duration) + } + + output = append(output, cacheExpirationAction) + } + + return &output, nil +} + +func FlattenArmCdnEndpointActionCacheExpiration(input cdn.BasicDeliveryRuleAction) (*map[string]interface{}, error) { + action, ok := input.AsDeliveryRuleCacheExpirationAction() + if !ok { + return nil, fmt.Errorf("expected a delivery rule cache expiration action!") + } + + behaviour := "" + duration := "" + if params := action.Parameters; params != nil { + behaviour = string(params.CacheBehavior) + + if params.CacheDuration != nil { + duration = *params.CacheDuration + } + } + + return &map[string]interface{}{ + "behavior": behaviour, + "duration": duration, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleactions/cache_key_query_string.go b/azurerm/internal/services/cdn/deliveryruleactions/cache_key_query_string.go new file mode 100644 index 000000000000..2c8479559612 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/cache_key_query_string.go @@ -0,0 +1,82 @@ +package deliveryruleactions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func CacheKeyQueryString() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Exclude), + string(cdn.ExcludeAll), + string(cdn.Include), + string(cdn.IncludeAll), + }, false), + }, + + "parameters": { + Type: schema.TypeString, + Optional: true, + }, + }, + } +} + +func ExpandArmCdnEndpointActionCacheKeyQueryString(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + cacheKeyQueryStringAction := cdn.DeliveryRuleCacheKeyQueryStringAction{ + Name: cdn.NameCacheKeyQueryString, + Parameters: &cdn.CacheKeyQueryStringActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheKeyQueryStringBehaviorActionParameters"), + QueryStringBehavior: cdn.QueryStringBehavior(item["behavior"].(string)), + }, + } + + if parameters := item["parameters"].(string); parameters == "" { + if behavior := cacheKeyQueryStringAction.Parameters.QueryStringBehavior; behavior == cdn.Include || behavior == cdn.Exclude { + return nil, fmt.Errorf("Parameters can not be empty if the behavior is either Include or Exclude.") + } + } else { + cacheKeyQueryStringAction.Parameters.QueryParameters = utils.String(parameters) + } + + output = append(output, cacheKeyQueryStringAction) + } + + return &output, nil +} + +func FlattenArmCdnEndpointActionCacheKeyQueryString(input cdn.BasicDeliveryRuleAction) (*map[string]interface{}, error) { + action, ok := input.AsDeliveryRuleCacheKeyQueryStringAction() + if !ok { + return nil, fmt.Errorf("expected a delivery rule cache key query string action!") + } + + behaviour := "" + parameters := "" + if params := action.Parameters; params != nil { + behaviour = string(params.QueryStringBehavior) + + if params.QueryParameters != nil { + parameters = *params.QueryParameters + } + } + + return &map[string]interface{}{ + "behavior": behaviour, + "parameters": parameters, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleactions/modify_request_header.go b/azurerm/internal/services/cdn/deliveryruleactions/modify_request_header.go new file mode 100644 index 000000000000..0435c44bcdde --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/modify_request_header.go @@ -0,0 +1,89 @@ +package deliveryruleactions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func ModifyRequestHeader() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Append), + string(cdn.Delete), + string(cdn.Overwrite), + }, false), + }, + + "name": { + Type: schema.TypeString, + Required: true, + }, + + "value": { + Type: schema.TypeString, + Optional: true, + }, + }, + } +} + +func ExpandArmCdnEndpointActionModifyRequestHeader(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + requestHeaderAction := cdn.DeliveryRuleRequestHeaderAction{ + Name: cdn.NameModifyRequestHeader, + Parameters: &cdn.HeaderActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters"), + HeaderAction: cdn.HeaderAction(item["action"].(string)), + HeaderName: utils.String(item["name"].(string)), + }, + } + + if value := item["value"].(string); value != "" { + requestHeaderAction.Parameters.Value = utils.String(value) + } + + output = append(output, requestHeaderAction) + } + + return &output, nil +} + +func FlattenArmCdnEndpointActionModifyRequestHeader(input cdn.BasicDeliveryRuleAction) (*map[string]interface{}, error) { + action, ok := input.AsDeliveryRuleRequestHeaderAction() + if !ok { + return nil, fmt.Errorf("expected a delivery rule request header action!") + } + + headerAction := "" + headerName := "" + value := "" + if params := action.Parameters; params != nil { + headerAction = string(params.HeaderAction) + + if params.HeaderName != nil { + headerName = *params.HeaderName + } + + if params.Value != nil { + value = *params.Value + } + } + + return &map[string]interface{}{ + "action": headerAction, + "name": headerName, + "value": value, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleactions/modify_response_header.go b/azurerm/internal/services/cdn/deliveryruleactions/modify_response_header.go new file mode 100644 index 000000000000..dc3a4d5754e3 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/modify_response_header.go @@ -0,0 +1,88 @@ +package deliveryruleactions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func ModifyResponseHeader() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Append), + string(cdn.Delete), + string(cdn.Overwrite), + }, false), + }, + + "name": { + Type: schema.TypeString, + Required: true, + }, + + "value": { + Type: schema.TypeString, + Optional: true, + }, + }, + } +} + +func ExpandArmCdnEndpointActionModifyResponseHeader(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + requestHeaderAction := cdn.DeliveryRuleResponseHeaderAction{ + Name: cdn.NameModifyResponseHeader, + Parameters: &cdn.HeaderActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters"), + HeaderAction: cdn.HeaderAction(item["action"].(string)), + HeaderName: utils.String(item["name"].(string)), + }, + } + + if value := item["value"].(string); value != "" { + requestHeaderAction.Parameters.Value = utils.String(value) + } + + output = append(output, requestHeaderAction) + } + + return &output, nil +} + +func FlattenArmCdnEndpointActionModifyResponseHeader(input cdn.BasicDeliveryRuleAction) (*map[string]interface{}, error) { + action, ok := input.AsDeliveryRuleResponseHeaderAction() + if !ok { + return nil, fmt.Errorf("expected a delivery rule response header action!") + } + + headerAction := "" + headerName := "" + value := "" + if params := action.Parameters; params != nil { + headerAction = string(params.HeaderAction) + if params.HeaderName != nil { + headerName = *params.HeaderName + } + + if params.Value != nil { + value = *params.Value + } + } + + return &map[string]interface{}{ + "action": headerAction, + "name": headerName, + "value": value, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go b/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go new file mode 100644 index 000000000000..9c11a25afbe9 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go @@ -0,0 +1,146 @@ +package deliveryruleactions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func URLRedirect() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "redirect_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Found), + string(cdn.Moved), + string(cdn.PermanentRedirect), + string(cdn.TemporaryRedirect), + }, false), + }, + + "protocol": { + Type: schema.TypeString, + Optional: true, + Default: string(cdn.MatchRequest), + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.MatchRequest), + string(cdn.HTTP), + string(cdn.HTTPS), + }, false), + }, + + "hostname": { + Type: schema.TypeString, + Optional: true, + }, + + "path": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "query_string": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.RuleActionUrlRedirectQueryString(), + }, + + "fragment": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validate.RuleActionUrlRedirectFragment(), + }, + }, + } +} + +func ExpandArmCdnEndpointActionUrlRedirect(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + params := cdn.URLRedirectActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRedirectActionParameters"), + RedirectType: cdn.RedirectType(item["redirect_type"].(string)), + } + + if destProt := item["protocol"]; destProt.(string) != "" { + params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) + } + + if hostname := item["hostname"]; hostname.(string) != "" { + params.CustomHostname = utils.String(hostname.(string)) + } + + if path := item["path"]; path.(string) != "" { + params.CustomPath = utils.String(path.(string)) + } + + if queryString := item["query_string"]; queryString.(string) != "" { + params.CustomQueryString = utils.String(queryString.(string)) + } + + if fragment := item["fragment"]; fragment.(string) != "" { + params.CustomFragment = utils.String(fragment.(string)) + } + + output = append(output, cdn.URLRedirectAction{ + Name: cdn.NameURLRedirect, + Parameters: ¶ms, + }) + } + + return &output, nil +} + +func FlattenArmCdnEndpointActionUrlRedirect(input cdn.BasicDeliveryRuleAction) (*map[string]interface{}, error) { + action, ok := input.AsURLRedirectAction() + if !ok { + return nil, fmt.Errorf("expected a delivery rule url redirect action!") + } + + customHostname := "" + customPath := "" + fragment := "" + queryString := "" + protocol := "" + redirectType := "" + + if params := action.Parameters; params != nil { + redirectType = string(params.RedirectType) + protocol = string(params.DestinationProtocol) + + if params.CustomHostname != nil { + customHostname = *params.CustomHostname + } + + if params.CustomPath != nil { + customPath = *params.CustomPath + } + + if params.CustomQueryString != nil { + queryString = *params.CustomQueryString + } + + if params.CustomFragment != nil { + fragment = *params.CustomFragment + } + } + + return &map[string]interface{}{ + "fragment": fragment, + "hostname": customHostname, + "query_string": queryString, + "path": customPath, + "protocol": protocol, + "redirect_type": redirectType, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go b/azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go new file mode 100644 index 000000000000..73709ffffff2 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go @@ -0,0 +1,84 @@ +package deliveryruleactions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func URLRewrite() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "source_pattern": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.RuleActionUrlRewriteSourcePattern(), + }, + + "destination": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.RuleActionUrlRewriteDestination(), + }, + + "preserve_unmatched_path": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + }, + } +} + +func ExpandArmCdnEndpointActionURLRewrite(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + output = append(output, cdn.URLRewriteAction{ + Name: cdn.NameURLRewrite, + Parameters: &cdn.URLRewriteActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRewriteActionParameters"), + SourcePattern: utils.String(item["source_pattern"].(string)), + Destination: utils.String(item["destination"].(string)), + PreserveUnmatchedPath: utils.Bool(item["preserve_unmatched_path"].(bool)), + }, + }) + } + + return &output, nil +} + +func FlattenArmCdnEndpointActionURLRewrite(input cdn.BasicDeliveryRuleAction) (*map[string]interface{}, error) { + action, ok := input.AsURLRewriteAction() + if !ok { + return nil, fmt.Errorf("expected a delivery rule url rewrite action!") + } + + sourcePattern := "" + destination := "" + preserveUnmatchedPath := true + if params := action.Parameters; params != nil { + if params.Destination != nil { + destination = *params.Destination + } + + if params.SourcePattern != nil { + sourcePattern = *params.SourcePattern + } + + if params.PreserveUnmatchedPath != nil { + preserveUnmatchedPath = *params.PreserveUnmatchedPath + } + } + + return &map[string]interface{}{ + "destination": destination, + "preserve_unmatched_path": preserveUnmatchedPath, + "source_pattern": sourcePattern, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go new file mode 100644 index 000000000000..ca9f7e3f585b --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go @@ -0,0 +1,138 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func Cookies() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "selector": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Any), + string(cdn.BeginsWith), + string(cdn.Contains), + string(cdn.EndsWith), + string(cdn.Equal), + string(cdn.GreaterThan), + string(cdn.GreaterThanOrEqual), + string(cdn.LessThan), + string(cdn.LessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionCookies(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + for _, v := range input { + item := v.(map[string]interface{}) + cookiesCondition := cdn.DeliveryRuleCookiesCondition{ + Name: cdn.NameCookies, + Parameters: &cdn.CookiesMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCookiesConditionParameters"), + Selector: utils.String(item["selector"].(string)), + Operator: cdn.CookiesOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + cookiesCondition.Parameters.Transforms = &transforms + } + + output = append(output, cookiesCondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionCookies(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleCookiesCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule cookie condition") + } + + selector := "" + operator := "" + negateCondition := false + matchValues := make([]interface{}, 0) + transforms := make([]string, 0) + + if params := condition.Parameters; params != nil { + if params.Selector != nil { + selector = *params.Selector + } + + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "operator": operator, + "selector": selector, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/device.go b/azurerm/internal/services/cdn/deliveryruleconditions/device.go new file mode 100644 index 000000000000..056ba8a9c55a --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/device.go @@ -0,0 +1,93 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func Device() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Optional: true, + Default: "Equal", + ValidateFunc: validation.StringInSlice([]string{ + "Equal", + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + "Desktop", + "Mobile", + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionDevice(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + output = append(output, cdn.DeliveryRuleIsDeviceCondition{ + Name: cdn.NameHTTPVersion, + Parameters: &cdn.IsDeviceMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleIsDeviceConditionParameters"), + Operator: utils.String(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + }) + } + + return output +} + +func FlattenArmCdnEndpointConditionDevice(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleIsDeviceCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule device condition") + } + + operator := "" + matchValues := make([]interface{}, 0) + negateCondition := false + if params := condition.Parameters; params != nil { + if params.Operator != nil { + operator = *params.Operator + } + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/http_version.go b/azurerm/internal/services/cdn/deliveryruleconditions/http_version.go new file mode 100644 index 000000000000..34a8ed826dea --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/http_version.go @@ -0,0 +1,95 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func HTTPVersion() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Optional: true, + Default: "Equal", + ValidateFunc: validation.StringInSlice([]string{ + "Equal", + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + "0.9", + "1.0", + "1.1", + "2.0", + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionHTTPVersion(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + output = append(output, cdn.DeliveryRuleHTTPVersionCondition{ + Name: cdn.NameHTTPVersion, + Parameters: &cdn.HTTPVersionMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHttpVersionConditionParameters"), + Operator: utils.String(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + }) + } + + return output +} + +func FlattenArmCdnEndpointConditionHTTPVersion(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleHTTPVersionCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule http version condition") + } + + operator := "" + matchValues := make([]interface{}, 0) + negateCondition := false + if params := condition.Parameters; params != nil { + if params.Operator != nil { + operator = *params.Operator + } + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go b/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go new file mode 100644 index 000000000000..8f0d90bed37e --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go @@ -0,0 +1,140 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func PostArg() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "selector": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.PostArgsOperatorAny), + string(cdn.PostArgsOperatorBeginsWith), + string(cdn.PostArgsOperatorContains), + string(cdn.PostArgsOperatorEndsWith), + string(cdn.PostArgsOperatorEqual), + string(cdn.PostArgsOperatorGreaterThan), + string(cdn.PostArgsOperatorGreaterThanOrEqual), + string(cdn.PostArgsOperatorLessThan), + string(cdn.PostArgsOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionPostArg(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + condition := cdn.DeliveryRulePostArgsCondition{ + Name: cdn.NameCookies, + Parameters: &cdn.PostArgsMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRulePostArgsConditionParameters"), + Selector: utils.String(item["selector"].(string)), + Operator: cdn.PostArgsOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + condition.Parameters.Transforms = &transforms + } + + output = append(output, condition) + } + + return output +} + +func FlattenArmCdnEndpointConditionPostArg(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRulePostArgsCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule post args condition") + } + + operator := "" + matchValues := make([]interface{}, 0) + negateCondition := false + selector := "" + transforms := make([]string, 0) + + if params := condition.Parameters; params != nil { + if params.Selector != nil { + selector = *params.Selector + } + + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "selector": selector, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go b/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go new file mode 100644 index 000000000000..af6733a67157 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go @@ -0,0 +1,126 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func QueryString() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.QueryStringOperatorAny), + string(cdn.QueryStringOperatorBeginsWith), + string(cdn.QueryStringOperatorContains), + string(cdn.QueryStringOperatorEndsWith), + string(cdn.QueryStringOperatorEqual), + string(cdn.QueryStringOperatorGreaterThan), + string(cdn.QueryStringOperatorGreaterThanOrEqual), + string(cdn.QueryStringOperatorLessThan), + string(cdn.QueryStringOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionQueryString(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + queryStringCondition := cdn.DeliveryRuleQueryStringCondition{ + Name: cdn.NameQueryString, + Parameters: &cdn.QueryStringMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleQueryStringConditionParameters"), + Operator: cdn.QueryStringOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + queryStringCondition.Parameters.Transforms = &transforms + } + + output = append(output, queryStringCondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionQueryString(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleQueryStringCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule query string condition") + } + + operator := "" + matchValues := make([]interface{}, 0) + negateCondition := false + transforms := make([]string, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/remote_address.go b/azurerm/internal/services/cdn/deliveryruleconditions/remote_address.go new file mode 100644 index 000000000000..1bd77cc458f2 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/remote_address.go @@ -0,0 +1,90 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func RemoteAddress() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.RemoteAddressOperatorAny), + string(cdn.RemoteAddressOperatorGeoMatch), + string(cdn.RemoteAddressOperatorIPMatch), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRemoteAddress(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + output = append(output, cdn.DeliveryRuleRemoteAddressCondition{ + Name: cdn.NameRemoteAddress, + Parameters: &cdn.RemoteAddressMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRemoteAddressConditionParameters"), + Operator: cdn.RemoteAddressOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + }) + } + + return output +} + +func FlattenArmCdnEndpointConditionRemoteAddress(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleRemoteAddressCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule address condition") + } + + operator := "" + negateCondition := false + matchValues := make([]interface{}, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_body.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_body.go new file mode 100644 index 000000000000..49dfcfabb5ff --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_body.go @@ -0,0 +1,126 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func RequestBody() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.RequestBodyOperatorAny), + string(cdn.RequestBodyOperatorBeginsWith), + string(cdn.RequestBodyOperatorContains), + string(cdn.RequestBodyOperatorEndsWith), + string(cdn.RequestBodyOperatorEqual), + string(cdn.RequestBodyOperatorGreaterThan), + string(cdn.RequestBodyOperatorGreaterThanOrEqual), + string(cdn.RequestBodyOperatorLessThan), + string(cdn.RequestBodyOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRequestBody(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + queryStringCondition := cdn.DeliveryRuleRequestBodyCondition{ + Name: cdn.NameRequestBody, + Parameters: &cdn.RequestBodyMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestBodyConditionParameters"), + Operator: cdn.RequestBodyOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + queryStringCondition.Parameters.Transforms = &transforms + } + + output = append(output, queryStringCondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionRequestBody(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleRequestBodyCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule request body condition") + } + + operator := "" + matchValues := make([]interface{}, 0) + negateCondition := false + transforms := make([]string, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_header.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_header.go new file mode 100644 index 000000000000..28cf27d1bbf6 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_header.go @@ -0,0 +1,124 @@ +package deliveryruleconditions + +import ( + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func RequestHeader() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "selector": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.RequestHeaderOperatorAny), + string(cdn.RequestHeaderOperatorBeginsWith), + string(cdn.RequestHeaderOperatorContains), + string(cdn.RequestHeaderOperatorEndsWith), + string(cdn.RequestHeaderOperatorEqual), + string(cdn.RequestHeaderOperatorGreaterThan), + string(cdn.RequestHeaderOperatorGreaterThanOrEqual), + string(cdn.RequestHeaderOperatorLessThan), + string(cdn.RequestHeaderOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRequestHeader(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + requestHeaderCondition := cdn.DeliveryRuleRequestHeaderCondition{ + Name: cdn.NameRequestHeader, + Parameters: &cdn.RequestHeaderMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestHeaderConditionParameters"), + Selector: utils.String(item["selector"].(string)), + Operator: cdn.RequestHeaderOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + requestHeaderCondition.Parameters.Transforms = &transforms + } + + output = append(output, requestHeaderCondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionRequestHeader(cc *cdn.DeliveryRuleRequestHeaderCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := cc.Parameters; params != nil { + if params.Selector != nil { + res["selector"] = *params.Selector + } + + res["operator"] = string(params.Operator) + + if params.NegateCondition != nil { + res["negate_condition"] = *params.NegateCondition + } + + if params.MatchValues != nil { + res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + } + + if params.Transforms != nil { + transforms := make([]string, 0) + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + res["transforms"] = &transforms + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go new file mode 100644 index 000000000000..991e2cee379e --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go @@ -0,0 +1,97 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func RequestMethod() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Optional: true, + Default: "Equal", + ValidateFunc: validation.StringInSlice([]string{ + "Equal", + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + "DELETE", + "GET", + "HEAD", + "OPTIONS", + "POST", + "PUT", + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRequestMethod(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + output = append(output, cdn.DeliveryRuleRequestMethodCondition{ + Name: cdn.NameRequestMethod, + Parameters: &cdn.RequestMethodMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestMethodConditionParameters"), + Operator: utils.String(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + }) + } + + return output +} + +func FlattenArmCdnEndpointConditionRequestMethod(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleRequestMethodCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule request method condition") + } + + operator := "" + negateCondition := false + matchValues := make([]interface{}, 0) + if params := condition.Parameters; params != nil { + if params.Operator != nil { + operator = *params.Operator + } + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + } + + return &map[string]interface{}{ + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "operator": operator, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go new file mode 100644 index 000000000000..7dd20ebcb3f1 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go @@ -0,0 +1,99 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func RequestScheme() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Optional: true, + Default: "Equal", + ValidateFunc: validation.StringInSlice([]string{ + "Equal", + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + "HTTP", + "HTTPS", + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRequestScheme(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ + Name: cdn.NameRequestScheme, + Parameters: &cdn.RequestSchemeMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if operator := item["operator"]; operator.(string) != "" { + requestSchemeCondition.Parameters.Operator = utils.String(operator.(string)) + } + + output = append(output, requestSchemeCondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionRequestScheme(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleRequestSchemeCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule request scheme condition") + } + + operator := "" + negateCondition := false + matchValues := make([]interface{}, 0) + if params := condition.Parameters; params != nil { + if params.Operator != nil { + operator = *params.Operator + } + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_uri.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_uri.go new file mode 100644 index 000000000000..2bcc17f7ad26 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_uri.go @@ -0,0 +1,125 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func RequestURI() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.RequestURIOperatorAny), + string(cdn.RequestURIOperatorBeginsWith), + string(cdn.RequestURIOperatorContains), + string(cdn.RequestURIOperatorEndsWith), + string(cdn.RequestURIOperatorEqual), + string(cdn.RequestURIOperatorGreaterThan), + string(cdn.RequestURIOperatorGreaterThanOrEqual), + string(cdn.RequestURIOperatorLessThan), + string(cdn.RequestURIOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRequestURI(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + requestURICondition := cdn.DeliveryRuleRequestURICondition{ + Name: cdn.NameRequestURI, + Parameters: &cdn.RequestURIMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestUriConditionParameters"), + Operator: cdn.RequestURIOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + requestURICondition.Parameters.Transforms = &transforms + } + + output = append(output, requestURICondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionRequestURI(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleRequestURICondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule request uri condition") + } + + matchValues := make([]interface{}, 0) + negateCondition := false + operator := "" + transforms := make([]string, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "operator": operator, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/url_file_extension.go b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_extension.go new file mode 100644 index 000000000000..99e811f472e6 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_extension.go @@ -0,0 +1,126 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func URLFileExtension() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.URLFileExtensionOperatorAny), + string(cdn.URLFileExtensionOperatorBeginsWith), + string(cdn.URLFileExtensionOperatorContains), + string(cdn.URLFileExtensionOperatorEndsWith), + string(cdn.URLFileExtensionOperatorEqual), + string(cdn.URLFileExtensionOperatorGreaterThan), + string(cdn.URLFileExtensionOperatorGreaterThanOrEqual), + string(cdn.URLFileExtensionOperatorLessThan), + string(cdn.URLFileExtensionOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionURLFileExtension(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + requestURICondition := cdn.DeliveryRuleURLFileExtensionCondition{ + Name: cdn.NameURLFileExtension, + Parameters: &cdn.URLFileExtensionMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlFileExtensionMatchConditionParameters"), + Operator: cdn.URLFileExtensionOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + requestURICondition.Parameters.Transforms = &transforms + } + + output = append(output, requestURICondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionURLFileExtension(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleURLFileExtensionCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule url file extension condition") + } + + matchValues := make([]interface{}, 0) + negateCondition := false + operator := "" + transforms := make([]string, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "operator": operator, + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/url_file_name.go b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_name.go new file mode 100644 index 000000000000..ca4cd257b55f --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_name.go @@ -0,0 +1,126 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func URLFileName() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.URLFileNameOperatorAny), + string(cdn.URLFileNameOperatorBeginsWith), + string(cdn.URLFileNameOperatorContains), + string(cdn.URLFileNameOperatorEndsWith), + string(cdn.URLFileNameOperatorEqual), + string(cdn.URLFileNameOperatorGreaterThan), + string(cdn.URLFileNameOperatorGreaterThanOrEqual), + string(cdn.URLFileNameOperatorLessThan), + string(cdn.URLFileNameOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionURLFileName(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + requestURICondition := cdn.DeliveryRuleURLFileNameCondition{ + Name: cdn.NameURLFileName, + Parameters: &cdn.URLFileNameMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlFilenameConditionParameters"), + Operator: cdn.URLFileNameOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + requestURICondition.Parameters.Transforms = &transforms + } + + output = append(output, requestURICondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionURLFileName(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleURLFileNameCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule url file name condition") + } + + matchValues := make([]interface{}, 0) + negateCondition := false + operator := "" + transforms := make([]string, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "operator": operator, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/url_path.go b/azurerm/internal/services/cdn/deliveryruleconditions/url_path.go new file mode 100644 index 000000000000..cfd1cab88f17 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_path.go @@ -0,0 +1,126 @@ +package deliveryruleconditions + +import ( + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func URLPath() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "operator": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.URLPathOperatorAny), + string(cdn.URLPathOperatorBeginsWith), + string(cdn.URLPathOperatorContains), + string(cdn.URLPathOperatorEndsWith), + string(cdn.URLPathOperatorEqual), + string(cdn.URLPathOperatorGreaterThan), + string(cdn.URLPathOperatorGreaterThanOrEqual), + string(cdn.URLPathOperatorLessThan), + string(cdn.URLPathOperatorLessThanOrEqual), + }, false), + }, + + "negate_condition": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + }, + + "transforms": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + }, + } +} + +func ExpandArmCdnEndpointConditionURLPath(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) + + for _, v := range input { + item := v.(map[string]interface{}) + + requestURICondition := cdn.DeliveryRuleURLPathCondition{ + Name: cdn.NameURLPath, + Parameters: &cdn.URLPathMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlPathMatchConditionParameters"), + Operator: cdn.URLPathOperator(item["operator"].(string)), + NegateCondition: utils.Bool(item["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(item["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := item["transforms"].([]interface{}); len(rawTransforms) != 0 { + transforms := make([]cdn.Transform, 0) + for _, t := range rawTransforms { + transforms = append(transforms, cdn.Transform(t.(string))) + } + requestURICondition.Parameters.Transforms = &transforms + } + + output = append(output, requestURICondition) + } + + return output +} + +func FlattenArmCdnEndpointConditionURLPath(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) { + condition, ok := input.AsDeliveryRuleURLPathCondition() + if !ok { + return nil, fmt.Errorf("expected a delivery rule url path condition") + } + + matchValues := make([]interface{}, 0) + negateCondition := false + operator := "" + transforms := make([]string, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) + + if params.NegateCondition != nil { + negateCondition = *params.NegateCondition + } + + if params.MatchValues != nil { + matchValues = utils.FlattenStringSlice(params.MatchValues) + } + + if params.Transforms != nil { + for _, transform := range *params.Transforms { + transforms = append(transforms, string(transform)) + } + } + } + + return &map[string]interface{}{ + "match_values": schema.NewSet(schema.HashString, matchValues), + "negate_condition": negateCondition, + "operator": operator, + "transforms": transforms, + }, nil +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go new file mode 100644 index 000000000000..b0229be493cd --- /dev/null +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -0,0 +1,488 @@ +package cdn + +import ( + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/deliveryruleactions" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/deliveryruleconditions" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func endpointDeliveryRule() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.EndpointDeliveryRuleName(), + }, + + "order": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "cookies_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.Cookies(), + }, + + "http_version_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.HTTPVersion(), + }, + + "device_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleconditions.Device(), + }, + + "post_arg_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.PostArg(), + }, + + "query_string_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.QueryString(), + }, + + "remote_address_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RemoteAddress(), + }, + + "request_body_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RequestBody(), + }, + + "request_header_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RequestHeader(), + }, + + "request_method_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleconditions.RequestMethod(), + }, + + "request_scheme_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleconditions.RequestScheme(), + }, + + "request_uri_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RequestURI(), + }, + + "url_file_extension_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.URLFileExtension(), + }, + + "url_file_name_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.URLFileName(), + }, + + "url_path_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.URLPath(), + }, + + "cache_expiration_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.CacheExpiration(), + }, + + "cache_key_query_string_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.CacheKeyQueryString(), + }, + + "modify_request_header_action": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleactions.ModifyRequestHeader(), + }, + + "modify_response_header_action": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleactions.ModifyResponseHeader(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.URLRedirect(), + }, + + "url_rewrite_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.URLRewrite(), + }, + }, + }, + } +} + +func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.DeliveryRule, error) { + deliveryRule := cdn.DeliveryRule{ + Name: utils.String(rule["name"].(string)), + Order: utils.Int32(int32(rule["order"].(int))), + } + + deliveryRule.Conditions = expandDeliveryRuleConditions(rule) + + actions, err := expandDeliveryRuleActions(rule) + if err != nil { + return nil, err + } + deliveryRule.Actions = &actions + + return &deliveryRule, nil +} + +func expandDeliveryRuleConditions(input map[string]interface{}) *[]cdn.BasicDeliveryRuleCondition { + conditions := make([]cdn.BasicDeliveryRuleCondition, 0) + + // @tombuildsstuff: we'd generally avoid over generalization, but this is /very/ repetitive so makes sense + type expandFunc func(input []interface{}) []cdn.BasicDeliveryRuleCondition + conditionTypes := map[string]expandFunc{ + "cookies_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionCookies, + "device_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionDevice, + "http_version_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionHTTPVersion, + "query_string_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionQueryString, + "post_arg_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionPostArg, + "request_body_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionRequestBody, + "request_header_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionRequestHeader, + "request_method_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionRequestMethod, + "remote_address_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionRemoteAddress, + "request_scheme_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme, + "request_uri_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionRequestURI, + "url_file_extension_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionURLFileExtension, + "url_file_name_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionURLFileName, + "url_path_condition": deliveryruleconditions.ExpandArmCdnEndpointConditionURLPath, + } + + for schemaKey, expandFunc := range conditionTypes { + raw := input[schemaKey].([]interface{}) + expanded := expandFunc(raw) + conditions = append(conditions, expanded...) + } + + return &conditions +} + +func expandDeliveryRuleActions(input map[string]interface{}) ([]cdn.BasicDeliveryRuleAction, error) { + actions := make([]cdn.BasicDeliveryRuleAction, 0) + + type expandFunc func(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) + actionTypes := map[string]expandFunc{ + "cache_expiration_action": deliveryruleactions.ExpandArmCdnEndpointActionCacheExpiration, + "cache_key_query_string_action": deliveryruleactions.ExpandArmCdnEndpointActionCacheKeyQueryString, + "modify_request_header_action": deliveryruleactions.ExpandArmCdnEndpointActionModifyRequestHeader, + "modify_response_header_action": deliveryruleactions.ExpandArmCdnEndpointActionModifyResponseHeader, + "url_redirect_action": deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect, + "url_rewrite_action": deliveryruleactions.ExpandArmCdnEndpointActionURLRewrite, + } + + for schemaKey, expandFunc := range actionTypes { + raw := input[schemaKey].([]interface{}) + expanded, err := expandFunc(raw) + if err != nil { + return nil, err + } + + actions = append(actions, *expanded...) + } + + return actions, nil +} + +func flattenArmCdnEndpointDeliveryRule(deliveryRule cdn.DeliveryRule) (*map[string]interface{}, error) { + name := "" + if deliveryRule.Name != nil { + name = *deliveryRule.Name + } + + order := -1 + if deliveryRule.Order != nil { + order = int(*deliveryRule.Order) + } + + output := map[string]interface{}{ + "name": name, + "order": order, + } + + conditions, err := flattenDeliveryRuleConditions(deliveryRule.Conditions) + if err != nil { + return nil, err + } + + for key, value := range *conditions { + output[key] = value + } + + actions, err := flattenDeliveryRuleActions(deliveryRule.Actions) + if err != nil { + return nil, err + } + + for key, value := range *actions { + output[key] = value + } + + return &output, nil +} + +func flattenDeliveryRuleActions(actions *[]cdn.BasicDeliveryRuleAction) (*map[string][]interface{}, error) { + type flattenFunc = func(input cdn.BasicDeliveryRuleAction) (*map[string]interface{}, error) + type validateFunc = func(input cdn.BasicDeliveryRuleAction) bool + + actionTypes := map[string]struct { + flattenFunc flattenFunc + validateFunc validateFunc + }{ + "cache_expiration_action": { + flattenFunc: deliveryruleactions.FlattenArmCdnEndpointActionCacheExpiration, + validateFunc: func(action cdn.BasicDeliveryRuleAction) bool { + _, ok := action.AsDeliveryRuleCacheExpirationAction() + return ok + }, + }, + "cache_key_query_string_action": { + flattenFunc: deliveryruleactions.FlattenArmCdnEndpointActionCacheKeyQueryString, + validateFunc: func(action cdn.BasicDeliveryRuleAction) bool { + _, ok := action.AsDeliveryRuleCacheKeyQueryStringAction() + return ok + }, + }, + "modify_request_header_action": { + flattenFunc: deliveryruleactions.FlattenArmCdnEndpointActionModifyRequestHeader, + validateFunc: func(action cdn.BasicDeliveryRuleAction) bool { + _, ok := action.AsDeliveryRuleRequestHeaderAction() + return ok + }, + }, + "modify_response_header_action": { + flattenFunc: deliveryruleactions.FlattenArmCdnEndpointActionModifyResponseHeader, + validateFunc: func(action cdn.BasicDeliveryRuleAction) bool { + _, ok := action.AsDeliveryRuleResponseHeaderAction() + return ok + }, + }, + "url_redirect_action": { + flattenFunc: deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect, + validateFunc: func(action cdn.BasicDeliveryRuleAction) bool { + _, ok := action.AsURLRedirectAction() + return ok + }, + }, + "url_rewrite_action": { + flattenFunc: deliveryruleactions.FlattenArmCdnEndpointActionURLRewrite, + validateFunc: func(action cdn.BasicDeliveryRuleAction) bool { + _, ok := action.AsURLRewriteAction() + return ok + }, + }, + } + + // first ensure there's a map for all of the keys + output := make(map[string][]interface{}) + for schemaKey := range actionTypes { + output[schemaKey] = make([]interface{}, 0) + } + + // intentionally bail here now we have defaults populated + if actions == nil { + return &output, nil + } + + // then iterate over all the actions and map them as necessary + for _, action := range *actions { + for schemaKey, actionType := range actionTypes { + suitable := actionType.validateFunc(action) + if !suitable { + continue + } + + mapped, err := actionType.flattenFunc(action) + if err != nil { + return nil, err + } + + output[schemaKey] = append(output[schemaKey], mapped) + break + } + } + + return &output, nil +} + +func flattenDeliveryRuleConditions(conditions *[]cdn.BasicDeliveryRuleCondition) (*map[string][]interface{}, error) { + type flattenFunc = func(input cdn.BasicDeliveryRuleCondition) (*map[string]interface{}, error) + type validateFunc = func(input cdn.BasicDeliveryRuleCondition) bool + + conditionTypes := map[string]struct { + flattenFunc flattenFunc + validateFunc validateFunc + }{ + "cookies_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionCookies, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleCookiesCondition() + return ok + }, + }, + "device_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionDevice, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleIsDeviceCondition() + return ok + }, + }, + "http_version_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionHTTPVersion, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleHTTPVersionCondition() + return ok + }, + }, + "query_string_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionQueryString, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleQueryStringCondition() + return ok + }, + }, + "post_arg_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionPostArg, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRulePostArgsCondition() + return ok + }, + }, + "remote_address_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionRemoteAddress, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleRemoteAddressCondition() + return ok + }, + }, + "request_body_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionRequestBody, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleRequestBodyCondition() + return ok + }, + }, + "request_method_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionRequestMethod, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleRequestMethodCondition() + return ok + }, + }, + "request_scheme_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleRequestSchemeCondition() + return ok + }, + }, + "request_uri_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionRequestURI, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleRequestURICondition() + return ok + }, + }, + "url_file_extension_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileExtension, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleURLFileExtensionCondition() + return ok + }, + }, + "url_file_name_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileName, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleURLFileNameCondition() + return ok + }, + }, + "url_path_condition": { + flattenFunc: deliveryruleconditions.FlattenArmCdnEndpointConditionURLPath, + validateFunc: func(condition cdn.BasicDeliveryRuleCondition) bool { + _, ok := condition.AsDeliveryRuleURLPathCondition() + return ok + }, + }, + } + + // first ensure there's a map for all of the keys + output := make(map[string][]interface{}) + for schemaKey := range conditionTypes { + output[schemaKey] = make([]interface{}, 0) + } + + // intentionally bail here now we have defaults populated + if conditions == nil { + return &output, nil + } + + // then iterate over all the conditions and map them as necessary + for _, condition := range *conditions { + for schemaKey, conditionType := range conditionTypes { + suitable := conditionType.validateFunc(condition) + if !suitable { + continue + } + + mapped, err := conditionType.flattenFunc(condition) + if err != nil { + return nil, err + } + + output[schemaKey] = append(output[schemaKey], mapped) + break + } + } + + return &output, nil +} diff --git a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go new file mode 100644 index 000000000000..3bd4c741e08b --- /dev/null +++ b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go @@ -0,0 +1,87 @@ +package cdn + +import ( + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/deliveryruleactions" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func endpointGlobalDeliveryRule() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cache_expiration_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.CacheExpiration(), + }, + + "cache_key_query_string_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.CacheKeyQueryString(), + }, + + "modify_request_header_action": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleactions.ModifyRequestHeader(), + }, + + "modify_response_header_action": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleactions.ModifyResponseHeader(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.URLRedirect(), + }, + + "url_rewrite_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.URLRewrite(), + }, + }, + }, + } +} + +func expandArmCdnEndpointGlobalDeliveryRule(rule map[string]interface{}) (*cdn.DeliveryRule, error) { + deliveryRule := cdn.DeliveryRule{ + Name: utils.String("Global"), + Order: utils.Int32(0), + } + + actions, err := expandDeliveryRuleActions(rule) + if err != nil { + return nil, err + } + deliveryRule.Actions = &actions + + return &deliveryRule, nil +} + +func flattenArmCdnEndpointGlobalDeliveryRule(deliveryRule cdn.DeliveryRule) (*map[string]interface{}, error) { + actions, err := flattenDeliveryRuleActions(deliveryRule.Actions) + if err != nil { + return nil, err + } + + output := make(map[string]interface{}) + for key, value := range *actions { + output[key] = value + } + return &output, nil +} diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index c7c6d8ab8647..2572d5fe4412 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn" + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -13,7 +13,6 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" @@ -197,13 +196,18 @@ func resourceArmCdnEndpoint() *schema.Resource { Computed: true, }, + "global_delivery_rule": endpointGlobalDeliveryRule(), + + "delivery_rule": endpointDeliveryRule(), + "tags": tags.Schema(), }, } } func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cdn.EndpointsClient + endpointsClient := meta.(*clients.Client).Cdn.EndpointsClient + profilesClient := meta.(*clients.Client).Cdn.ProfilesClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -213,17 +217,15 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro resourceGroup := d.Get("resource_group_name").(string) profileName := d.Get("profile_name").(string) - if features.ShouldResourcesBeImported() && d.IsNewResource() { - existing, err := client.Get(ctx, resourceGroup, profileName, name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of existing CDN Endpoint %q (Profile %q / Resource Group %q): %s", name, profileName, resourceGroup, err) - } + existing, err := endpointsClient.Get(ctx, resourceGroup, profileName, name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("Error checking for presence of existing CDN Endpoint %q (Profile %q / Resource Group %q): %s", name, profileName, resourceGroup, err) } + } - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_cdn_endpoint", *existing.ID) - } + if existing.ID != nil && *existing.ID != "" { + return tf.ImportAsExistsError("azurerm_cdn_endpoint", *existing.ID) } location := azure.NormalizeLocation(d.Get("location").(string)) @@ -236,13 +238,14 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) + geoFilters := expandCdnEndpointGeoFilters(d) t := d.Get("tags").(map[string]interface{}) endpoint := cdn.Endpoint{ Location: &location, EndpointProperties: &cdn.EndpointProperties{ ContentTypesToCompress: &contentTypes, - GeoFilters: expandArmCdnEndpointGeoFilters(d), + GeoFilters: geoFilters, IsHTTPAllowed: &httpAllowed, IsHTTPSAllowed: &httpsAllowed, IsCompressionEnabled: &compressionEnabled, @@ -267,16 +270,36 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro endpoint.EndpointProperties.Origins = &origins } - future, err := client.Create(ctx, resourceGroup, profileName, name, endpoint) + profile, err := profilesClient.Get(ctx, resourceGroup, profileName) + if err != nil { + return fmt.Errorf("Error creating CDN Endpoint %q while getting CDN Profile (Profile %q / Resource Group %q): %+v", name, profileName, resourceGroup, err) + } + + if profile.Sku != nil { + globalDeliveryRulesRaw := d.Get("global_delivery_rule").([]interface{}) + deliveryRulesRaw := d.Get("delivery_rule").([]interface{}) + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(globalDeliveryRulesRaw, deliveryRulesRaw) + if err != nil { + return fmt.Errorf("Error expanding `global_delivery_rule` or `delivery_rule`: %s", err) + } + + if profile.Sku.Name != cdn.StandardMicrosoft && len(*deliveryPolicy.Rules) > 0 { + return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) + } + + endpoint.EndpointProperties.DeliveryPolicy = deliveryPolicy + } + + future, err := endpointsClient.Create(ctx, resourceGroup, profileName, name, endpoint) if err != nil { return fmt.Errorf("Error creating CDN Endpoint %q (Profile %q / Resource Group %q): %+v", name, profileName, resourceGroup, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + if err = future.WaitForCompletionRef(ctx, endpointsClient.Client); err != nil { return fmt.Errorf("Error waiting for CDN Endpoint %q (Profile %q / Resource Group %q) to finish creating: %+v", name, profileName, resourceGroup, err) } - read, err := client.Get(ctx, resourceGroup, profileName, name) + read, err := endpointsClient.Get(ctx, resourceGroup, profileName, name) if err != nil { return fmt.Errorf("Error retrieving CDN Endpoint %q (Profile %q / Resource Group %q): %+v", name, profileName, resourceGroup, err) } @@ -305,12 +328,13 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) + geoFilters := expandCdnEndpointGeoFilters(d) t := d.Get("tags").(map[string]interface{}) endpoint := cdn.EndpointUpdateParameters{ EndpointPropertiesUpdateParameters: &cdn.EndpointPropertiesUpdateParameters{ ContentTypesToCompress: &contentTypes, - GeoFilters: expandArmCdnEndpointGeoFilters(d), + GeoFilters: geoFilters, IsHTTPAllowed: utils.Bool(httpAllowed), IsHTTPSAllowed: utils.Bool(httpsAllowed), IsCompressionEnabled: utils.Bool(compressionEnabled), @@ -330,6 +354,30 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro endpoint.EndpointPropertiesUpdateParameters.ProbePath = utils.String(probePath) } + profilesClient := meta.(*clients.Client).Cdn.ProfilesClient + profileGetCtx, profileGetCancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer profileGetCancel() + + profile, err := profilesClient.Get(profileGetCtx, id.ResourceGroup, id.ProfileName) + if err != nil { + return fmt.Errorf("Error creating CDN Endpoint %q while getting CDN Profile (Profile %q / Resource Group %q): %+v", id.Name, id.ProfileName, id.ResourceGroup, err) + } + + if profile.Sku != nil { + globalDeliveryRulesRaw := d.Get("global_delivery_rule").([]interface{}) + deliveryRulesRaw := d.Get("delivery_rule").([]interface{}) + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(globalDeliveryRulesRaw, deliveryRulesRaw) + if err != nil { + return fmt.Errorf("Error expanding `global_delivery_rule` or `delivery_rule`: %s", err) + } + + if profile.Sku.Name != cdn.StandardMicrosoft && len(*deliveryPolicy.Rules) > 0 { + return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) + } + + endpoint.EndpointPropertiesUpdateParameters.DeliveryPolicy = deliveryPolicy + } + future, err := endpointsClient.Update(ctx, id.ResourceGroup, id.ProfileName, id.Name, endpoint) if err != nil { return fmt.Errorf("Error updating CDN Endpoint %q (Profile %q / Resource Group %q): %s", id.Name, id.ProfileName, id.ResourceGroup, err) @@ -397,6 +445,17 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("origin", origins); err != nil { return fmt.Errorf("Error setting `origin`: %+v", err) } + + flattenedDeliveryPolicies, err := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) + if err != nil { + return err + } + if err := d.Set("global_delivery_rule", flattenedDeliveryPolicies.globalDeliveryRules); err != nil { + return fmt.Errorf("Error setting `global_delivery_rule`: %+v", err) + } + if err := d.Set("delivery_rule", flattenedDeliveryPolicies.deliveryRules); err != nil { + return fmt.Errorf("Error setting `delivery_rule`: %+v", err) + } } return tags.FlattenAndSet(d, resp.Tags) @@ -430,7 +489,7 @@ func resourceArmCdnEndpointDelete(d *schema.ResourceData, meta interface{}) erro return nil } -func expandArmCdnEndpointGeoFilters(d *schema.ResourceData) *[]cdn.GeoFilter { +func expandCdnEndpointGeoFilters(d *schema.ResourceData) *[]cdn.GeoFilter { filters := make([]cdn.GeoFilter, 0) inputFilters := d.Get("geo_filter").([]interface{}) @@ -463,11 +522,9 @@ func flattenCdnEndpointGeoFilters(input *[]cdn.GeoFilter) []interface{} { if filters := input; filters != nil { for _, filter := range *filters { - output := make(map[string]interface{}) - - output["action"] = string(filter.Action) - if path := filter.RelativePath; path != nil { - output["relative_path"] = *path + relativePath := "" + if filter.RelativePath != nil { + relativePath = *filter.RelativePath } outputCodes := make([]interface{}, 0) @@ -476,9 +533,12 @@ func flattenCdnEndpointGeoFilters(input *[]cdn.GeoFilter) []interface{} { outputCodes = append(outputCodes, code) } } - output["country_codes"] = outputCodes - results = append(results, output) + results = append(results, map[string]interface{}{ + "action": string(filter.Action), + "country_codes": outputCodes, + "relative_path": relativePath, + }) } } @@ -547,27 +607,102 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface if list := input; list != nil { for _, i := range *list { - output := map[string]interface{}{} - - if name := i.Name; name != nil { - output["name"] = *name + name := "" + if i.Name != nil { + name = *i.Name } + hostName := "" + httpPort := 0 + httpsPort := 0 if props := i.DeepCreatedOriginProperties; props != nil { - if hostName := props.HostName; hostName != nil { - output["host_name"] = *hostName + if props.HostName != nil { + hostName = *props.HostName } if port := props.HTTPPort; port != nil { - output["http_port"] = int(*port) + httpPort = int(*port) } if port := props.HTTPSPort; port != nil { - output["https_port"] = int(*port) + httpsPort = int(*port) } } - results = append(results, output) + results = append(results, map[string]interface{}{ + "name": name, + "host_name": hostName, + "http_port": httpPort, + "https_port": httpsPort, + }) } } return results } + +func expandArmCdnEndpointDeliveryPolicy(globalRulesRaw []interface{}, deliveryRulesRaw []interface{}) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { + deliveryRules := make([]cdn.DeliveryRule, 0) + deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{ + Description: utils.String(""), + Rules: &deliveryRules, + } + + if len(globalRulesRaw) > 0 { + ruleRaw := globalRulesRaw[0].(map[string]interface{}) + rule, err := expandArmCdnEndpointGlobalDeliveryRule(ruleRaw) + if err != nil { + return nil, err + } + deliveryRules = append(deliveryRules, *rule) + } + + for _, ruleV := range deliveryRulesRaw { + ruleRaw := ruleV.(map[string]interface{}) + rule, err := expandArmCdnEndpointDeliveryRule(ruleRaw) + if err != nil { + return nil, err + } + deliveryRules = append(deliveryRules, *rule) + } + + return &deliveryPolicy, nil +} + +type flattenedEndpointDeliveryPolicies struct { + globalDeliveryRules []interface{} + deliveryRules []interface{} +} + +func flattenArmCdnEndpointDeliveryPolicy(input *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) (*flattenedEndpointDeliveryPolicies, error) { + output := flattenedEndpointDeliveryPolicies{ + globalDeliveryRules: make([]interface{}, 0), + deliveryRules: make([]interface{}, 0), + } + if input == nil || input.Rules == nil { + return &output, nil + } + + for _, rule := range *input.Rules { + if rule.Order == nil { + continue + } + + if int(*rule.Order) == 0 { + flattenedRule, err := flattenArmCdnEndpointGlobalDeliveryRule(rule) + if err != nil { + return nil, err + } + + output.globalDeliveryRules = append(output.globalDeliveryRules, flattenedRule) + continue + } + + flattenedRule, err := flattenArmCdnEndpointDeliveryRule(rule) + if err != nil { + return nil, err + } + + output.deliveryRules = append(output.deliveryRules, flattenedRule) + } + + return &output, nil +} diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_profile.go b/azurerm/internal/services/cdn/resource_arm_cdn_profile.go index cafb2ab44f64..062b1dc8b999 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_profile.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_profile.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn" + "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/azurerm/internal/services/cdn/tests/resource_arm_cdn_endpoint_test.go b/azurerm/internal/services/cdn/tests/resource_arm_cdn_endpoint_test.go index c26d75417704..fcaa06f29257 100644 --- a/azurerm/internal/services/cdn/tests/resource_arm_cdn_endpoint_test.go +++ b/azurerm/internal/services/cdn/tests/resource_arm_cdn_endpoint_test.go @@ -172,6 +172,7 @@ func TestAccAzureRMCdnEndpoint_withGeoFilters(t *testing.T) { }, }) } + func TestAccAzureRMCdnEndpoint_fullFields(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_cdn_endpoint", "test") @@ -230,6 +231,119 @@ func TestAccAzureRMCdnEndpoint_isHttpAndHttpsAllowedUpdate(t *testing.T) { }) } +func TestAccAzureRMCdnEndpoint_globalDeliveryRule(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cdn_endpoint", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMCdnEndpointDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMCdnEndpoint_globalDeliveryRule(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMCdnEndpointExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.cache_expiration_action.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.cache_expiration_action.0.behavior", "Override"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.cache_expiration_action.0.duration", "5.04:44:23"), + ), + }, + { + Config: testAccAzureRMCdnEndpoint_globalDeliveryRuleUpdate(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMCdnEndpointExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.cache_expiration_action.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.cache_expiration_action.0.behavior", "SetIfMissing"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.cache_expiration_action.0.duration", "12.04:11:22"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.modify_response_header_action.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.modify_response_header_action.0.action", "Overwrite"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.modify_response_header_action.0.name", "Content-Type"), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.0.modify_response_header_action.0.value", "application/json"), + ), + }, + { + Config: testAccAzureRMCdnEndpoint_globalDeliveryRuleRemove(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMCdnEndpointExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "global_delivery_rule.#", "0"), + ), + }, + }, + }) +} + +func TestAccAzureRMCdnEndpoint_deliveryRule(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cdn_endpoint", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMCdnEndpointDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMCdnEndpoint_deliveryRule(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMCdnEndpointExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.name", "http2https"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.order", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.0.match_values.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.0.redirect_type", "Found"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.0.protocol", "Https"), + ), + }, + { + Config: testAccAzureRMCdnEndpoint_deliveryRuleUpdate1(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMCdnEndpointExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.name", "http2https"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.order", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.0.negate_condition", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.0.match_values.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.0.redirect_type", "Found"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.0.protocol", "Https"), + ), + }, + { + Config: testAccAzureRMCdnEndpoint_deliveryRuleUpdate2(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMCdnEndpointExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.#", "2"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.name", "http2https"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.order", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.0.negate_condition", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.request_scheme_condition.0.match_values.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.0.redirect_type", "Found"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.0.url_redirect_action.0.protocol", "Https"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.1.name", "test"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.1.order", "2"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.1.device_condition.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.1.device_condition.0.match_values.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.1.modify_response_header_action.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.1.modify_response_header_action.0.action", "Delete"), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.1.modify_response_header_action.0.name", "Content-Language"), + ), + }, + { + Config: testAccAzureRMCdnEndpoint_deliveryRuleRemove(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMCdnEndpointExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "delivery_rule.#", "0"), + ), + }, + }, + }) +} + func testCheckAzureRMCdnEndpointExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { conn := acceptance.AzureProvider.Meta().(*clients.Client).Cdn.EndpointsClient @@ -664,3 +778,333 @@ resource "azurerm_cdn_endpoint" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, isHttpAllowed, isHttpsAllowed) } + +func testAccAzureRMCdnEndpoint_globalDeliveryRule(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_cdn_profile" "test" { + name = "acctestcdnprof%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard_Microsoft" +} + +resource "azurerm_cdn_endpoint" "test" { + name = "acctestcdnend%d" + profile_name = azurerm_cdn_profile.test.name + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + origin_host_header = "www.example.com" + + origin { + name = "acceptanceTestCdnOrigin1" + host_name = "www.example.com" + https_port = 443 + http_port = 80 + } + + global_delivery_rule { + cache_expiration_action { + behavior = "Override" + duration = "5.04:44:23" + } + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMCdnEndpoint_globalDeliveryRuleUpdate(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_cdn_profile" "test" { + name = "acctestcdnprof%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard_Microsoft" +} + +resource "azurerm_cdn_endpoint" "test" { + name = "acctestcdnend%d" + profile_name = azurerm_cdn_profile.test.name + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + origin_host_header = "www.example.com" + + origin { + name = "acceptanceTestCdnOrigin1" + host_name = "www.example.com" + https_port = 443 + http_port = 80 + } + + global_delivery_rule { + cache_expiration_action { + behavior = "SetIfMissing" + duration = "12.04:11:22" + } + + modify_response_header_action { + action = "Overwrite" + name = "Content-Type" + value = "application/json" + } + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMCdnEndpoint_globalDeliveryRuleRemove(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_cdn_profile" "test" { + name = "acctestcdnprof%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard_Microsoft" +} + +resource "azurerm_cdn_endpoint" "test" { + name = "acctestcdnend%d" + profile_name = azurerm_cdn_profile.test.name + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + origin_host_header = "www.example.com" + + origin { + name = "acceptanceTestCdnOrigin1" + host_name = "www.example.com" + https_port = 443 + http_port = 80 + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMCdnEndpoint_deliveryRule(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_cdn_profile" "test" { + name = "acctestcdnprof%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard_Microsoft" +} + +resource "azurerm_cdn_endpoint" "test" { + name = "acctestcdnend%d" + profile_name = azurerm_cdn_profile.test.name + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + origin_host_header = "www.example.com" + + origin { + name = "acceptanceTestCdnOrigin1" + host_name = "www.example.com" + https_port = 443 + http_port = 80 + } + + delivery_rule { + name = "http2https" + order = 1 + + request_scheme_condition { + match_values = ["HTTP"] + } + + url_redirect_action { + redirect_type = "Found" + protocol = "Https" + } + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMCdnEndpoint_deliveryRuleUpdate1(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_cdn_profile" "test" { + name = "acctestcdnprof%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard_Microsoft" +} + +resource "azurerm_cdn_endpoint" "test" { + name = "acctestcdnend%d" + profile_name = azurerm_cdn_profile.test.name + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + origin_host_header = "www.example.com" + + origin { + name = "acceptanceTestCdnOrigin1" + host_name = "www.example.com" + https_port = 443 + http_port = 80 + } + + delivery_rule { + name = "http2https" + order = 1 + + request_scheme_condition { + negate_condition = true + match_values = ["HTTPS"] + } + + url_redirect_action { + redirect_type = "Found" + protocol = "Https" + } + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMCdnEndpoint_deliveryRuleUpdate2(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_cdn_profile" "test" { + name = "acctestcdnprof%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard_Microsoft" +} + +resource "azurerm_cdn_endpoint" "test" { + name = "acctestcdnend%d" + profile_name = azurerm_cdn_profile.test.name + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + origin_host_header = "www.example.com" + + origin { + name = "acceptanceTestCdnOrigin1" + host_name = "www.example.com" + https_port = 443 + http_port = 80 + } + + delivery_rule { + name = "http2https" + order = 1 + + request_scheme_condition { + negate_condition = true + match_values = ["HTTPS"] + } + + url_redirect_action { + redirect_type = "Found" + protocol = "Https" + } + } + + delivery_rule { + name = "test" + order = 2 + + device_condition { + match_values = ["Mobile"] + } + + modify_response_header_action { + action = "Delete" + name = "Content-Language" + } + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} + +func testAccAzureRMCdnEndpoint_deliveryRuleRemove(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_cdn_profile" "test" { + name = "acctestcdnprof%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard_Microsoft" +} + +resource "azurerm_cdn_endpoint" "test" { + name = "acctestcdnend%d" + profile_name = azurerm_cdn_profile.test.name + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + origin_host_header = "www.example.com" + + origin { + name = "acceptanceTestCdnOrigin1" + host_name = "www.example.com" + https_port = 443 + http_port = 80 + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/models.go deleted file mode 100644 index 6181e03ee133..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/models.go +++ /dev/null @@ -1,3305 +0,0 @@ -package cdn - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn" - -// CacheBehavior enumerates the values for cache behavior. -type CacheBehavior string - -const ( - // BypassCache ... - BypassCache CacheBehavior = "BypassCache" - // Override ... - Override CacheBehavior = "Override" - // SetIfMissing ... - SetIfMissing CacheBehavior = "SetIfMissing" -) - -// PossibleCacheBehaviorValues returns an array of possible values for the CacheBehavior const type. -func PossibleCacheBehaviorValues() []CacheBehavior { - return []CacheBehavior{BypassCache, Override, SetIfMissing} -} - -// CertificateSource enumerates the values for certificate source. -type CertificateSource string - -const ( - // CertificateSourceAzureKeyVault ... - CertificateSourceAzureKeyVault CertificateSource = "AzureKeyVault" - // CertificateSourceCdn ... - CertificateSourceCdn CertificateSource = "Cdn" - // CertificateSourceCustomDomainHTTPSParameters ... - CertificateSourceCustomDomainHTTPSParameters CertificateSource = "CustomDomainHttpsParameters" -) - -// PossibleCertificateSourceValues returns an array of possible values for the CertificateSource const type. -func PossibleCertificateSourceValues() []CertificateSource { - return []CertificateSource{CertificateSourceAzureKeyVault, CertificateSourceCdn, CertificateSourceCustomDomainHTTPSParameters} -} - -// CertificateType enumerates the values for certificate type. -type CertificateType string - -const ( - // Dedicated ... - Dedicated CertificateType = "Dedicated" - // Shared ... - Shared CertificateType = "Shared" -) - -// PossibleCertificateTypeValues returns an array of possible values for the CertificateType const type. -func PossibleCertificateTypeValues() []CertificateType { - return []CertificateType{Dedicated, Shared} -} - -// CustomDomainResourceState enumerates the values for custom domain resource state. -type CustomDomainResourceState string - -const ( - // Active ... - Active CustomDomainResourceState = "Active" - // Creating ... - Creating CustomDomainResourceState = "Creating" - // Deleting ... - Deleting CustomDomainResourceState = "Deleting" -) - -// PossibleCustomDomainResourceStateValues returns an array of possible values for the CustomDomainResourceState const type. -func PossibleCustomDomainResourceStateValues() []CustomDomainResourceState { - return []CustomDomainResourceState{Active, Creating, Deleting} -} - -// CustomHTTPSProvisioningState enumerates the values for custom https provisioning state. -type CustomHTTPSProvisioningState string - -const ( - // Disabled ... - Disabled CustomHTTPSProvisioningState = "Disabled" - // Disabling ... - Disabling CustomHTTPSProvisioningState = "Disabling" - // Enabled ... - Enabled CustomHTTPSProvisioningState = "Enabled" - // Enabling ... - Enabling CustomHTTPSProvisioningState = "Enabling" - // Failed ... - Failed CustomHTTPSProvisioningState = "Failed" -) - -// PossibleCustomHTTPSProvisioningStateValues returns an array of possible values for the CustomHTTPSProvisioningState const type. -func PossibleCustomHTTPSProvisioningStateValues() []CustomHTTPSProvisioningState { - return []CustomHTTPSProvisioningState{Disabled, Disabling, Enabled, Enabling, Failed} -} - -// CustomHTTPSProvisioningSubstate enumerates the values for custom https provisioning substate. -type CustomHTTPSProvisioningSubstate string - -const ( - // CertificateDeleted ... - CertificateDeleted CustomHTTPSProvisioningSubstate = "CertificateDeleted" - // CertificateDeployed ... - CertificateDeployed CustomHTTPSProvisioningSubstate = "CertificateDeployed" - // DeletingCertificate ... - DeletingCertificate CustomHTTPSProvisioningSubstate = "DeletingCertificate" - // DeployingCertificate ... - DeployingCertificate CustomHTTPSProvisioningSubstate = "DeployingCertificate" - // DomainControlValidationRequestApproved ... - DomainControlValidationRequestApproved CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestApproved" - // DomainControlValidationRequestRejected ... - DomainControlValidationRequestRejected CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestRejected" - // DomainControlValidationRequestTimedOut ... - DomainControlValidationRequestTimedOut CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestTimedOut" - // IssuingCertificate ... - IssuingCertificate CustomHTTPSProvisioningSubstate = "IssuingCertificate" - // PendingDomainControlValidationREquestApproval ... - PendingDomainControlValidationREquestApproval CustomHTTPSProvisioningSubstate = "PendingDomainControlValidationREquestApproval" - // SubmittingDomainControlValidationRequest ... - SubmittingDomainControlValidationRequest CustomHTTPSProvisioningSubstate = "SubmittingDomainControlValidationRequest" -) - -// PossibleCustomHTTPSProvisioningSubstateValues returns an array of possible values for the CustomHTTPSProvisioningSubstate const type. -func PossibleCustomHTTPSProvisioningSubstateValues() []CustomHTTPSProvisioningSubstate { - return []CustomHTTPSProvisioningSubstate{CertificateDeleted, CertificateDeployed, DeletingCertificate, DeployingCertificate, DomainControlValidationRequestApproved, DomainControlValidationRequestRejected, DomainControlValidationRequestTimedOut, IssuingCertificate, PendingDomainControlValidationREquestApproval, SubmittingDomainControlValidationRequest} -} - -// EndpointResourceState enumerates the values for endpoint resource state. -type EndpointResourceState string - -const ( - // EndpointResourceStateCreating ... - EndpointResourceStateCreating EndpointResourceState = "Creating" - // EndpointResourceStateDeleting ... - EndpointResourceStateDeleting EndpointResourceState = "Deleting" - // EndpointResourceStateRunning ... - EndpointResourceStateRunning EndpointResourceState = "Running" - // EndpointResourceStateStarting ... - EndpointResourceStateStarting EndpointResourceState = "Starting" - // EndpointResourceStateStopped ... - EndpointResourceStateStopped EndpointResourceState = "Stopped" - // EndpointResourceStateStopping ... - EndpointResourceStateStopping EndpointResourceState = "Stopping" -) - -// PossibleEndpointResourceStateValues returns an array of possible values for the EndpointResourceState const type. -func PossibleEndpointResourceStateValues() []EndpointResourceState { - return []EndpointResourceState{EndpointResourceStateCreating, EndpointResourceStateDeleting, EndpointResourceStateRunning, EndpointResourceStateStarting, EndpointResourceStateStopped, EndpointResourceStateStopping} -} - -// GeoFilterActions enumerates the values for geo filter actions. -type GeoFilterActions string - -const ( - // Allow ... - Allow GeoFilterActions = "Allow" - // Block ... - Block GeoFilterActions = "Block" -) - -// PossibleGeoFilterActionsValues returns an array of possible values for the GeoFilterActions const type. -func PossibleGeoFilterActionsValues() []GeoFilterActions { - return []GeoFilterActions{Allow, Block} -} - -// MatchType enumerates the values for match type. -type MatchType string - -const ( - // Literal ... - Literal MatchType = "Literal" - // Wildcard ... - Wildcard MatchType = "Wildcard" -) - -// PossibleMatchTypeValues returns an array of possible values for the MatchType const type. -func PossibleMatchTypeValues() []MatchType { - return []MatchType{Literal, Wildcard} -} - -// Name enumerates the values for name. -type Name string - -const ( - // NameCacheExpiration ... - NameCacheExpiration Name = "CacheExpiration" - // NameDeliveryRuleAction ... - NameDeliveryRuleAction Name = "DeliveryRuleAction" -) - -// PossibleNameValues returns an array of possible values for the Name const type. -func PossibleNameValues() []Name { - return []Name{NameCacheExpiration, NameDeliveryRuleAction} -} - -// NameBasicDeliveryRuleCondition enumerates the values for name basic delivery rule condition. -type NameBasicDeliveryRuleCondition string - -const ( - // NameDeliveryRuleCondition ... - NameDeliveryRuleCondition NameBasicDeliveryRuleCondition = "DeliveryRuleCondition" - // NameURLFileExtension ... - NameURLFileExtension NameBasicDeliveryRuleCondition = "UrlFileExtension" - // NameURLPath ... - NameURLPath NameBasicDeliveryRuleCondition = "UrlPath" -) - -// PossibleNameBasicDeliveryRuleConditionValues returns an array of possible values for the NameBasicDeliveryRuleCondition const type. -func PossibleNameBasicDeliveryRuleConditionValues() []NameBasicDeliveryRuleCondition { - return []NameBasicDeliveryRuleCondition{NameDeliveryRuleCondition, NameURLFileExtension, NameURLPath} -} - -// OptimizationType enumerates the values for optimization type. -type OptimizationType string - -const ( - // DynamicSiteAcceleration ... - DynamicSiteAcceleration OptimizationType = "DynamicSiteAcceleration" - // GeneralMediaStreaming ... - GeneralMediaStreaming OptimizationType = "GeneralMediaStreaming" - // GeneralWebDelivery ... - GeneralWebDelivery OptimizationType = "GeneralWebDelivery" - // LargeFileDownload ... - LargeFileDownload OptimizationType = "LargeFileDownload" - // VideoOnDemandMediaStreaming ... - VideoOnDemandMediaStreaming OptimizationType = "VideoOnDemandMediaStreaming" -) - -// PossibleOptimizationTypeValues returns an array of possible values for the OptimizationType const type. -func PossibleOptimizationTypeValues() []OptimizationType { - return []OptimizationType{DynamicSiteAcceleration, GeneralMediaStreaming, GeneralWebDelivery, LargeFileDownload, VideoOnDemandMediaStreaming} -} - -// OriginResourceState enumerates the values for origin resource state. -type OriginResourceState string - -const ( - // OriginResourceStateActive ... - OriginResourceStateActive OriginResourceState = "Active" - // OriginResourceStateCreating ... - OriginResourceStateCreating OriginResourceState = "Creating" - // OriginResourceStateDeleting ... - OriginResourceStateDeleting OriginResourceState = "Deleting" -) - -// PossibleOriginResourceStateValues returns an array of possible values for the OriginResourceState const type. -func PossibleOriginResourceStateValues() []OriginResourceState { - return []OriginResourceState{OriginResourceStateActive, OriginResourceStateCreating, OriginResourceStateDeleting} -} - -// ProfileResourceState enumerates the values for profile resource state. -type ProfileResourceState string - -const ( - // ProfileResourceStateActive ... - ProfileResourceStateActive ProfileResourceState = "Active" - // ProfileResourceStateCreating ... - ProfileResourceStateCreating ProfileResourceState = "Creating" - // ProfileResourceStateDeleting ... - ProfileResourceStateDeleting ProfileResourceState = "Deleting" - // ProfileResourceStateDisabled ... - ProfileResourceStateDisabled ProfileResourceState = "Disabled" -) - -// PossibleProfileResourceStateValues returns an array of possible values for the ProfileResourceState const type. -func PossibleProfileResourceStateValues() []ProfileResourceState { - return []ProfileResourceState{ProfileResourceStateActive, ProfileResourceStateCreating, ProfileResourceStateDeleting, ProfileResourceStateDisabled} -} - -// ProtocolType enumerates the values for protocol type. -type ProtocolType string - -const ( - // IPBased ... - IPBased ProtocolType = "IPBased" - // ServerNameIndication ... - ServerNameIndication ProtocolType = "ServerNameIndication" -) - -// PossibleProtocolTypeValues returns an array of possible values for the ProtocolType const type. -func PossibleProtocolTypeValues() []ProtocolType { - return []ProtocolType{IPBased, ServerNameIndication} -} - -// QueryStringCachingBehavior enumerates the values for query string caching behavior. -type QueryStringCachingBehavior string - -const ( - // BypassCaching ... - BypassCaching QueryStringCachingBehavior = "BypassCaching" - // IgnoreQueryString ... - IgnoreQueryString QueryStringCachingBehavior = "IgnoreQueryString" - // NotSet ... - NotSet QueryStringCachingBehavior = "NotSet" - // UseQueryString ... - UseQueryString QueryStringCachingBehavior = "UseQueryString" -) - -// PossibleQueryStringCachingBehaviorValues returns an array of possible values for the QueryStringCachingBehavior const type. -func PossibleQueryStringCachingBehaviorValues() []QueryStringCachingBehavior { - return []QueryStringCachingBehavior{BypassCaching, IgnoreQueryString, NotSet, UseQueryString} -} - -// ResourceType enumerates the values for resource type. -type ResourceType string - -const ( - // MicrosoftCdnProfilesEndpoints ... - MicrosoftCdnProfilesEndpoints ResourceType = "Microsoft.Cdn/Profiles/Endpoints" -) - -// PossibleResourceTypeValues returns an array of possible values for the ResourceType const type. -func PossibleResourceTypeValues() []ResourceType { - return []ResourceType{MicrosoftCdnProfilesEndpoints} -} - -// SkuName enumerates the values for sku name. -type SkuName string - -const ( - // CustomVerizon ... - CustomVerizon SkuName = "Custom_Verizon" - // PremiumChinaCdn ... - PremiumChinaCdn SkuName = "Premium_ChinaCdn" - // PremiumVerizon ... - PremiumVerizon SkuName = "Premium_Verizon" - // StandardAkamai ... - StandardAkamai SkuName = "Standard_Akamai" - // StandardChinaCdn ... - StandardChinaCdn SkuName = "Standard_ChinaCdn" - // StandardMicrosoft ... - StandardMicrosoft SkuName = "Standard_Microsoft" - // StandardVerizon ... - StandardVerizon SkuName = "Standard_Verizon" -) - -// PossibleSkuNameValues returns an array of possible values for the SkuName const type. -func PossibleSkuNameValues() []SkuName { - return []SkuName{CustomVerizon, PremiumChinaCdn, PremiumVerizon, StandardAkamai, StandardChinaCdn, StandardMicrosoft, StandardVerizon} -} - -// CacheExpirationActionParameters defines the parameters for the cache expiration action. -type CacheExpirationActionParameters struct { - OdataType *string `json:"@odata.type,omitempty"` - // CacheBehavior - Caching behavior for the requests that include query strings. Possible values include: 'BypassCache', 'Override', 'SetIfMissing' - CacheBehavior CacheBehavior `json:"cacheBehavior,omitempty"` - // CacheType - The level at which the content needs to be cached. - CacheType *string `json:"cacheType,omitempty"` - // CacheDuration - The duration for which the content needs to be cached. Allowed format is [d.]hh:mm:ss - CacheDuration *string `json:"cacheDuration,omitempty"` -} - -// CertificateSourceParameters defines the parameters for using CDN managed certificate for securing custom -// domain. -type CertificateSourceParameters struct { - OdataType *string `json:"@odata.type,omitempty"` - // CertificateType - Type of certificate used. Possible values include: 'Shared', 'Dedicated' - CertificateType CertificateType `json:"certificateType,omitempty"` -} - -// CheckNameAvailabilityInput input of CheckNameAvailability API. -type CheckNameAvailabilityInput struct { - // Name - The resource name to validate. - Name *string `json:"name,omitempty"` - // Type - The type of the resource whose name is to be validated. - Type *string `json:"type,omitempty"` -} - -// CheckNameAvailabilityOutput output of check name availability API. -type CheckNameAvailabilityOutput struct { - autorest.Response `json:"-"` - // NameAvailable - READ-ONLY; Indicates whether the name is available. - NameAvailable *bool `json:"nameAvailable,omitempty"` - // Reason - READ-ONLY; The reason why the name is not available. - Reason *string `json:"reason,omitempty"` - // Message - READ-ONLY; The detailed error message describing why the name is not available. - Message *string `json:"message,omitempty"` -} - -// CidrIPAddress CIDR Ip address -type CidrIPAddress struct { - // BaseIPAddress - Ip address itself. - BaseIPAddress *string `json:"baseIpAddress,omitempty"` - // PrefixLength - The length of the prefix of the ip address. - PrefixLength *int32 `json:"prefixLength,omitempty"` -} - -// CustomDomain friendly domain name mapping to the endpoint hostname that the customer provides for -// branding purposes, e.g. www.contoso.com. -type CustomDomain struct { - autorest.Response `json:"-"` - *CustomDomainProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for CustomDomain. -func (cd CustomDomain) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cd.CustomDomainProperties != nil { - objectMap["properties"] = cd.CustomDomainProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CustomDomain struct. -func (cd *CustomDomain) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var customDomainProperties CustomDomainProperties - err = json.Unmarshal(*v, &customDomainProperties) - if err != nil { - return err - } - cd.CustomDomainProperties = &customDomainProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - cd.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - cd.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - cd.Type = &typeVar - } - } - } - - return nil -} - -// BasicCustomDomainHTTPSParameters the JSON object that contains the properties to secure a custom domain. -type BasicCustomDomainHTTPSParameters interface { - AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) - AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) - AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) -} - -// CustomDomainHTTPSParameters the JSON object that contains the properties to secure a custom domain. -type CustomDomainHTTPSParameters struct { - // ProtocolType - Defines the TLS extension protocol that is used for secure delivery. Possible values include: 'ServerNameIndication', 'IPBased' - ProtocolType ProtocolType `json:"protocolType,omitempty"` - // CertificateSource - Possible values include: 'CertificateSourceCustomDomainHTTPSParameters', 'CertificateSourceCdn', 'CertificateSourceAzureKeyVault' - CertificateSource CertificateSource `json:"certificateSource,omitempty"` -} - -func unmarshalBasicCustomDomainHTTPSParameters(body []byte) (BasicCustomDomainHTTPSParameters, error) { - var m map[string]interface{} - err := json.Unmarshal(body, &m) - if err != nil { - return nil, err - } - - switch m["certificateSource"] { - case string(CertificateSourceCdn): - var mhp ManagedHTTPSParameters - err := json.Unmarshal(body, &mhp) - return mhp, err - case string(CertificateSourceAzureKeyVault): - var umhp UserManagedHTTPSParameters - err := json.Unmarshal(body, &umhp) - return umhp, err - default: - var cdhp CustomDomainHTTPSParameters - err := json.Unmarshal(body, &cdhp) - return cdhp, err - } -} -func unmarshalBasicCustomDomainHTTPSParametersArray(body []byte) ([]BasicCustomDomainHTTPSParameters, error) { - var rawMessages []*json.RawMessage - err := json.Unmarshal(body, &rawMessages) - if err != nil { - return nil, err - } - - cdhpArray := make([]BasicCustomDomainHTTPSParameters, len(rawMessages)) - - for index, rawMessage := range rawMessages { - cdhp, err := unmarshalBasicCustomDomainHTTPSParameters(*rawMessage) - if err != nil { - return nil, err - } - cdhpArray[index] = cdhp - } - return cdhpArray, nil -} - -// MarshalJSON is the custom marshaler for CustomDomainHTTPSParameters. -func (cdhp CustomDomainHTTPSParameters) MarshalJSON() ([]byte, error) { - cdhp.CertificateSource = CertificateSourceCustomDomainHTTPSParameters - objectMap := make(map[string]interface{}) - if cdhp.ProtocolType != "" { - objectMap["protocolType"] = cdhp.ProtocolType - } - if cdhp.CertificateSource != "" { - objectMap["certificateSource"] = cdhp.CertificateSource - } - return json.Marshal(objectMap) -} - -// AsManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. -func (cdhp CustomDomainHTTPSParameters) AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) { - return nil, false -} - -// AsUserManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. -func (cdhp CustomDomainHTTPSParameters) AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) { - return nil, false -} - -// AsCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. -func (cdhp CustomDomainHTTPSParameters) AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) { - return &cdhp, true -} - -// AsBasicCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. -func (cdhp CustomDomainHTTPSParameters) AsBasicCustomDomainHTTPSParameters() (BasicCustomDomainHTTPSParameters, bool) { - return &cdhp, true -} - -// CustomDomainListResult result of the request to list custom domains. It contains a list of custom domain -// objects and a URL link to get the next set of results. -type CustomDomainListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of CDN CustomDomains within an endpoint. - Value *[]CustomDomain `json:"value,omitempty"` - // NextLink - URL to get the next set of custom domain objects if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// CustomDomainListResultIterator provides access to a complete listing of CustomDomain values. -type CustomDomainListResultIterator struct { - i int - page CustomDomainListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *CustomDomainListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CustomDomainListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *CustomDomainListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter CustomDomainListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter CustomDomainListResultIterator) Response() CustomDomainListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter CustomDomainListResultIterator) Value() CustomDomain { - if !iter.page.NotDone() { - return CustomDomain{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the CustomDomainListResultIterator type. -func NewCustomDomainListResultIterator(page CustomDomainListResultPage) CustomDomainListResultIterator { - return CustomDomainListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (cdlr CustomDomainListResult) IsEmpty() bool { - return cdlr.Value == nil || len(*cdlr.Value) == 0 -} - -// customDomainListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (cdlr CustomDomainListResult) customDomainListResultPreparer(ctx context.Context) (*http.Request, error) { - if cdlr.NextLink == nil || len(to.String(cdlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(cdlr.NextLink))) -} - -// CustomDomainListResultPage contains a page of CustomDomain values. -type CustomDomainListResultPage struct { - fn func(context.Context, CustomDomainListResult) (CustomDomainListResult, error) - cdlr CustomDomainListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *CustomDomainListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/CustomDomainListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.cdlr) - if err != nil { - return err - } - page.cdlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *CustomDomainListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page CustomDomainListResultPage) NotDone() bool { - return !page.cdlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page CustomDomainListResultPage) Response() CustomDomainListResult { - return page.cdlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page CustomDomainListResultPage) Values() []CustomDomain { - if page.cdlr.IsEmpty() { - return nil - } - return *page.cdlr.Value -} - -// Creates a new instance of the CustomDomainListResultPage type. -func NewCustomDomainListResultPage(getNextPage func(context.Context, CustomDomainListResult) (CustomDomainListResult, error)) CustomDomainListResultPage { - return CustomDomainListResultPage{fn: getNextPage} -} - -// CustomDomainParameters the customDomain JSON object required for custom domain creation or update. -type CustomDomainParameters struct { - *CustomDomainPropertiesParameters `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for CustomDomainParameters. -func (cdp CustomDomainParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cdp.CustomDomainPropertiesParameters != nil { - objectMap["properties"] = cdp.CustomDomainPropertiesParameters - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CustomDomainParameters struct. -func (cdp *CustomDomainParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var customDomainPropertiesParameters CustomDomainPropertiesParameters - err = json.Unmarshal(*v, &customDomainPropertiesParameters) - if err != nil { - return err - } - cdp.CustomDomainPropertiesParameters = &customDomainPropertiesParameters - } - } - } - - return nil -} - -// CustomDomainProperties the JSON object that contains the properties of the custom domain to create. -type CustomDomainProperties struct { - // HostName - The host name of the custom domain. Must be a domain name. - HostName *string `json:"hostName,omitempty"` - // ResourceState - READ-ONLY; Resource status of the custom domain. Possible values include: 'Creating', 'Active', 'Deleting' - ResourceState CustomDomainResourceState `json:"resourceState,omitempty"` - // CustomHTTPSProvisioningState - READ-ONLY; Provisioning status of Custom Https of the custom domain. Possible values include: 'Enabling', 'Enabled', 'Disabling', 'Disabled', 'Failed' - CustomHTTPSProvisioningState CustomHTTPSProvisioningState `json:"customHttpsProvisioningState,omitempty"` - // CustomHTTPSProvisioningSubstate - READ-ONLY; Provisioning substate shows the progress of custom HTTPS enabling/disabling process step by step. Possible values include: 'SubmittingDomainControlValidationRequest', 'PendingDomainControlValidationREquestApproval', 'DomainControlValidationRequestApproved', 'DomainControlValidationRequestRejected', 'DomainControlValidationRequestTimedOut', 'IssuingCertificate', 'DeployingCertificate', 'CertificateDeployed', 'DeletingCertificate', 'CertificateDeleted' - CustomHTTPSProvisioningSubstate CustomHTTPSProvisioningSubstate `json:"customHttpsProvisioningSubstate,omitempty"` - // ValidationData - Special validation or data may be required when delivering CDN to some regions due to local compliance reasons. E.g. ICP license number of a custom domain is required to deliver content in China. - ValidationData *string `json:"validationData,omitempty"` - // ProvisioningState - READ-ONLY; Provisioning status of the custom domain. - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// CustomDomainPropertiesParameters the JSON object that contains the properties of the custom domain to -// create. -type CustomDomainPropertiesParameters struct { - // HostName - The host name of the custom domain. Must be a domain name. - HostName *string `json:"hostName,omitempty"` -} - -// CustomDomainsCreateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type CustomDomainsCreateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *CustomDomainsCreateFuture) Result(client CustomDomainsClient) (cd CustomDomain, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.CustomDomainsCreateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if cd.Response.Response, err = future.GetResult(sender); err == nil && cd.Response.Response.StatusCode != http.StatusNoContent { - cd, err = client.CreateResponder(cd.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsCreateFuture", "Result", cd.Response.Response, "Failure responding to request") - } - } - return -} - -// CustomDomainsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type CustomDomainsDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *CustomDomainsDeleteFuture) Result(client CustomDomainsClient) (cd CustomDomain, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.CustomDomainsDeleteFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if cd.Response.Response, err = future.GetResult(sender); err == nil && cd.Response.Response.StatusCode != http.StatusNoContent { - cd, err = client.DeleteResponder(cd.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.CustomDomainsDeleteFuture", "Result", cd.Response.Response, "Failure responding to request") - } - } - return -} - -// DeepCreatedOrigin the main origin of CDN content which is added when creating a CDN endpoint. -type DeepCreatedOrigin struct { - // Name - Origin name - Name *string `json:"name,omitempty"` - *DeepCreatedOriginProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for DeepCreatedOrigin. -func (dco DeepCreatedOrigin) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dco.Name != nil { - objectMap["name"] = dco.Name - } - if dco.DeepCreatedOriginProperties != nil { - objectMap["properties"] = dco.DeepCreatedOriginProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DeepCreatedOrigin struct. -func (dco *DeepCreatedOrigin) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - dco.Name = &name - } - case "properties": - if v != nil { - var deepCreatedOriginProperties DeepCreatedOriginProperties - err = json.Unmarshal(*v, &deepCreatedOriginProperties) - if err != nil { - return err - } - dco.DeepCreatedOriginProperties = &deepCreatedOriginProperties - } - } - } - - return nil -} - -// DeepCreatedOriginProperties properties of the origin created on the CDN endpoint. -type DeepCreatedOriginProperties struct { - // HostName - The address of the origin. It can be a domain name, IPv4 address, or IPv6 address. - HostName *string `json:"hostName,omitempty"` - // HTTPPort - The value of the HTTP port. Must be between 1 and 65535 - HTTPPort *int32 `json:"httpPort,omitempty"` - // HTTPSPort - The value of the HTTPS port. Must be between 1 and 65535 - HTTPSPort *int32 `json:"httpsPort,omitempty"` -} - -// DeliveryRule a rule that specifies a set of actions and conditions -type DeliveryRule struct { - // Order - The order in which the rules are applied for the endpoint. Possible values {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. Rule with order 0 is a special rule. It does not require any condition and actions listed in it will always be applied. - Order *int32 `json:"order,omitempty"` - // Actions - A list of actions that are executed when all the conditions of a rule are satisfied. - Actions *[]BasicDeliveryRuleAction `json:"actions,omitempty"` - // Conditions - A list of conditions that must be matched for the actions to be executed - Conditions *[]BasicDeliveryRuleCondition `json:"conditions,omitempty"` -} - -// UnmarshalJSON is the custom unmarshaler for DeliveryRule struct. -func (dr *DeliveryRule) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "order": - if v != nil { - var order int32 - err = json.Unmarshal(*v, &order) - if err != nil { - return err - } - dr.Order = &order - } - case "actions": - if v != nil { - actions, err := unmarshalBasicDeliveryRuleActionArray(*v) - if err != nil { - return err - } - dr.Actions = &actions - } - case "conditions": - if v != nil { - conditions, err := unmarshalBasicDeliveryRuleConditionArray(*v) - if err != nil { - return err - } - dr.Conditions = &conditions - } - } - } - - return nil -} - -// BasicDeliveryRuleAction an action for the delivery rule. -type BasicDeliveryRuleAction interface { - AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) - AsDeliveryRuleAction() (*DeliveryRuleAction, bool) -} - -// DeliveryRuleAction an action for the delivery rule. -type DeliveryRuleAction struct { - // Name - Possible values include: 'NameDeliveryRuleAction', 'NameCacheExpiration' - Name Name `json:"name,omitempty"` -} - -func unmarshalBasicDeliveryRuleAction(body []byte) (BasicDeliveryRuleAction, error) { - var m map[string]interface{} - err := json.Unmarshal(body, &m) - if err != nil { - return nil, err - } - - switch m["name"] { - case string(NameCacheExpiration): - var drcea DeliveryRuleCacheExpirationAction - err := json.Unmarshal(body, &drcea) - return drcea, err - default: - var dra DeliveryRuleAction - err := json.Unmarshal(body, &dra) - return dra, err - } -} -func unmarshalBasicDeliveryRuleActionArray(body []byte) ([]BasicDeliveryRuleAction, error) { - var rawMessages []*json.RawMessage - err := json.Unmarshal(body, &rawMessages) - if err != nil { - return nil, err - } - - draArray := make([]BasicDeliveryRuleAction, len(rawMessages)) - - for index, rawMessage := range rawMessages { - dra, err := unmarshalBasicDeliveryRuleAction(*rawMessage) - if err != nil { - return nil, err - } - draArray[index] = dra - } - return draArray, nil -} - -// MarshalJSON is the custom marshaler for DeliveryRuleAction. -func (dra DeliveryRuleAction) MarshalJSON() ([]byte, error) { - dra.Name = NameDeliveryRuleAction - objectMap := make(map[string]interface{}) - if dra.Name != "" { - objectMap["name"] = dra.Name - } - return json.Marshal(objectMap) -} - -// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. -func (dra DeliveryRuleAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { - return nil, false -} - -// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. -func (dra DeliveryRuleAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { - return &dra, true -} - -// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. -func (dra DeliveryRuleAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { - return &dra, true -} - -// DeliveryRuleCacheExpirationAction defines the cache expiration action for the delivery rule. -type DeliveryRuleCacheExpirationAction struct { - // Parameters - Defines the parameters for the action. - Parameters *CacheExpirationActionParameters `json:"parameters,omitempty"` - // Name - Possible values include: 'NameDeliveryRuleAction', 'NameCacheExpiration' - Name Name `json:"name,omitempty"` -} - -// MarshalJSON is the custom marshaler for DeliveryRuleCacheExpirationAction. -func (drcea DeliveryRuleCacheExpirationAction) MarshalJSON() ([]byte, error) { - drcea.Name = NameCacheExpiration - objectMap := make(map[string]interface{}) - if drcea.Parameters != nil { - objectMap["parameters"] = drcea.Parameters - } - if drcea.Name != "" { - objectMap["name"] = drcea.Name - } - return json.Marshal(objectMap) -} - -// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. -func (drcea DeliveryRuleCacheExpirationAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { - return &drcea, true -} - -// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. -func (drcea DeliveryRuleCacheExpirationAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { - return nil, false -} - -// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. -func (drcea DeliveryRuleCacheExpirationAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { - return &drcea, true -} - -// BasicDeliveryRuleCondition a condition for the delivery rule. -type BasicDeliveryRuleCondition interface { - AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) - AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) - AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) -} - -// DeliveryRuleCondition a condition for the delivery rule. -type DeliveryRuleCondition struct { - // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameURLPath', 'NameURLFileExtension' - Name NameBasicDeliveryRuleCondition `json:"name,omitempty"` -} - -func unmarshalBasicDeliveryRuleCondition(body []byte) (BasicDeliveryRuleCondition, error) { - var m map[string]interface{} - err := json.Unmarshal(body, &m) - if err != nil { - return nil, err - } - - switch m["name"] { - case string(NameURLPath): - var drupc DeliveryRuleURLPathCondition - err := json.Unmarshal(body, &drupc) - return drupc, err - case string(NameURLFileExtension): - var drufec DeliveryRuleURLFileExtensionCondition - err := json.Unmarshal(body, &drufec) - return drufec, err - default: - var drc DeliveryRuleCondition - err := json.Unmarshal(body, &drc) - return drc, err - } -} -func unmarshalBasicDeliveryRuleConditionArray(body []byte) ([]BasicDeliveryRuleCondition, error) { - var rawMessages []*json.RawMessage - err := json.Unmarshal(body, &rawMessages) - if err != nil { - return nil, err - } - - drcArray := make([]BasicDeliveryRuleCondition, len(rawMessages)) - - for index, rawMessage := range rawMessages { - drc, err := unmarshalBasicDeliveryRuleCondition(*rawMessage) - if err != nil { - return nil, err - } - drcArray[index] = drc - } - return drcArray, nil -} - -// MarshalJSON is the custom marshaler for DeliveryRuleCondition. -func (drc DeliveryRuleCondition) MarshalJSON() ([]byte, error) { - drc.Name = NameDeliveryRuleCondition - objectMap := make(map[string]interface{}) - if drc.Name != "" { - objectMap["name"] = drc.Name - } - return json.Marshal(objectMap) -} - -// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. -func (drc DeliveryRuleCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { - return nil, false -} - -// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. -func (drc DeliveryRuleCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { - return nil, false -} - -// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. -func (drc DeliveryRuleCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { - return &drc, true -} - -// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. -func (drc DeliveryRuleCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { - return &drc, true -} - -// DeliveryRuleURLFileExtensionCondition defines the URL file extension condition for the delivery rule. -type DeliveryRuleURLFileExtensionCondition struct { - // Parameters - Defines the parameters for the condition. - Parameters *URLFileExtensionConditionParameters `json:"parameters,omitempty"` - // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameURLPath', 'NameURLFileExtension' - Name NameBasicDeliveryRuleCondition `json:"name,omitempty"` -} - -// MarshalJSON is the custom marshaler for DeliveryRuleURLFileExtensionCondition. -func (drufec DeliveryRuleURLFileExtensionCondition) MarshalJSON() ([]byte, error) { - drufec.Name = NameURLFileExtension - objectMap := make(map[string]interface{}) - if drufec.Parameters != nil { - objectMap["parameters"] = drufec.Parameters - } - if drufec.Name != "" { - objectMap["name"] = drufec.Name - } - return json.Marshal(objectMap) -} - -// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. -func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { - return nil, false -} - -// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. -func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { - return &drufec, true -} - -// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. -func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { - return nil, false -} - -// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. -func (drufec DeliveryRuleURLFileExtensionCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { - return &drufec, true -} - -// DeliveryRuleURLPathCondition defines the URL path condition for the delivery rule. -type DeliveryRuleURLPathCondition struct { - // Parameters - Defines the parameters for the condition. - Parameters *URLPathConditionParameters `json:"parameters,omitempty"` - // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameURLPath', 'NameURLFileExtension' - Name NameBasicDeliveryRuleCondition `json:"name,omitempty"` -} - -// MarshalJSON is the custom marshaler for DeliveryRuleURLPathCondition. -func (drupc DeliveryRuleURLPathCondition) MarshalJSON() ([]byte, error) { - drupc.Name = NameURLPath - objectMap := make(map[string]interface{}) - if drupc.Parameters != nil { - objectMap["parameters"] = drupc.Parameters - } - if drupc.Name != "" { - objectMap["name"] = drupc.Name - } - return json.Marshal(objectMap) -} - -// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. -func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { - return &drupc, true -} - -// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. -func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { - return nil, false -} - -// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. -func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { - return nil, false -} - -// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. -func (drupc DeliveryRuleURLPathCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { - return &drupc, true -} - -// EdgeNode edgenode is a global Point of Presence (POP) location used to deliver CDN content to end users. -type EdgeNode struct { - *EdgeNodeProperties `json:"properties,omitempty"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for EdgeNode. -func (en EdgeNode) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if en.EdgeNodeProperties != nil { - objectMap["properties"] = en.EdgeNodeProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for EdgeNode struct. -func (en *EdgeNode) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var edgeNodeProperties EdgeNodeProperties - err = json.Unmarshal(*v, &edgeNodeProperties) - if err != nil { - return err - } - en.EdgeNodeProperties = &edgeNodeProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - en.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - en.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - en.Type = &typeVar - } - } - } - - return nil -} - -// EdgeNodeProperties the JSON object that contains the properties required to create an edgenode. -type EdgeNodeProperties struct { - // IPAddressGroups - List of ip address groups. - IPAddressGroups *[]IPAddressGroup `json:"ipAddressGroups,omitempty"` -} - -// EdgenodeResult result of the request to list CDN edgenodes. It contains a list of ip address group and a -// URL link to get the next set of results. -type EdgenodeResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; Edge node of CDN service. - Value *[]EdgeNode `json:"value,omitempty"` - // NextLink - URL to get the next set of edgenode list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// EdgenodeResultIterator provides access to a complete listing of EdgeNode values. -type EdgenodeResultIterator struct { - i int - page EdgenodeResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *EdgenodeResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EdgenodeResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *EdgenodeResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter EdgenodeResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter EdgenodeResultIterator) Response() EdgenodeResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter EdgenodeResultIterator) Value() EdgeNode { - if !iter.page.NotDone() { - return EdgeNode{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the EdgenodeResultIterator type. -func NewEdgenodeResultIterator(page EdgenodeResultPage) EdgenodeResultIterator { - return EdgenodeResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (er EdgenodeResult) IsEmpty() bool { - return er.Value == nil || len(*er.Value) == 0 -} - -// edgenodeResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (er EdgenodeResult) edgenodeResultPreparer(ctx context.Context) (*http.Request, error) { - if er.NextLink == nil || len(to.String(er.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(er.NextLink))) -} - -// EdgenodeResultPage contains a page of EdgeNode values. -type EdgenodeResultPage struct { - fn func(context.Context, EdgenodeResult) (EdgenodeResult, error) - er EdgenodeResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *EdgenodeResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EdgenodeResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.er) - if err != nil { - return err - } - page.er = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *EdgenodeResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page EdgenodeResultPage) NotDone() bool { - return !page.er.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page EdgenodeResultPage) Response() EdgenodeResult { - return page.er -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page EdgenodeResultPage) Values() []EdgeNode { - if page.er.IsEmpty() { - return nil - } - return *page.er.Value -} - -// Creates a new instance of the EdgenodeResultPage type. -func NewEdgenodeResultPage(getNextPage func(context.Context, EdgenodeResult) (EdgenodeResult, error)) EdgenodeResultPage { - return EdgenodeResultPage{fn: getNextPage} -} - -// Endpoint CDN endpoint is the entity within a CDN profile containing configuration information such as -// origin, protocol, content caching and delivery behavior. The CDN endpoint uses the URL format -// .azureedge.net. -type Endpoint struct { - autorest.Response `json:"-"` - *EndpointProperties `json:"properties,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Endpoint. -func (e Endpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if e.EndpointProperties != nil { - objectMap["properties"] = e.EndpointProperties - } - if e.Location != nil { - objectMap["location"] = e.Location - } - if e.Tags != nil { - objectMap["tags"] = e.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Endpoint struct. -func (e *Endpoint) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var endpointProperties EndpointProperties - err = json.Unmarshal(*v, &endpointProperties) - if err != nil { - return err - } - e.EndpointProperties = &endpointProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - e.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - e.Tags = tags - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - e.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - e.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - e.Type = &typeVar - } - } - } - - return nil -} - -// EndpointListResult result of the request to list endpoints. It contains a list of endpoint objects and a -// URL link to get the next set of results. -type EndpointListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of CDN endpoints within a profile - Value *[]Endpoint `json:"value,omitempty"` - // NextLink - URL to get the next set of endpoint objects if there is any. - NextLink *string `json:"nextLink,omitempty"` -} - -// EndpointListResultIterator provides access to a complete listing of Endpoint values. -type EndpointListResultIterator struct { - i int - page EndpointListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *EndpointListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EndpointListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *EndpointListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter EndpointListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter EndpointListResultIterator) Response() EndpointListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter EndpointListResultIterator) Value() Endpoint { - if !iter.page.NotDone() { - return Endpoint{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the EndpointListResultIterator type. -func NewEndpointListResultIterator(page EndpointListResultPage) EndpointListResultIterator { - return EndpointListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (elr EndpointListResult) IsEmpty() bool { - return elr.Value == nil || len(*elr.Value) == 0 -} - -// endpointListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (elr EndpointListResult) endpointListResultPreparer(ctx context.Context) (*http.Request, error) { - if elr.NextLink == nil || len(to.String(elr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(elr.NextLink))) -} - -// EndpointListResultPage contains a page of Endpoint values. -type EndpointListResultPage struct { - fn func(context.Context, EndpointListResult) (EndpointListResult, error) - elr EndpointListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *EndpointListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EndpointListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.elr) - if err != nil { - return err - } - page.elr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *EndpointListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page EndpointListResultPage) NotDone() bool { - return !page.elr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page EndpointListResultPage) Response() EndpointListResult { - return page.elr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page EndpointListResultPage) Values() []Endpoint { - if page.elr.IsEmpty() { - return nil - } - return *page.elr.Value -} - -// Creates a new instance of the EndpointListResultPage type. -func NewEndpointListResultPage(getNextPage func(context.Context, EndpointListResult) (EndpointListResult, error)) EndpointListResultPage { - return EndpointListResultPage{fn: getNextPage} -} - -// EndpointProperties the JSON object that contains the properties required to create an endpoint. -type EndpointProperties struct { - // HostName - READ-ONLY; The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. contoso.azureedge.net - HostName *string `json:"hostName,omitempty"` - // Origins - The source of the content being delivered via CDN. - Origins *[]DeepCreatedOrigin `json:"origins,omitempty"` - // ResourceState - READ-ONLY; Resource status of the endpoint. Possible values include: 'EndpointResourceStateCreating', 'EndpointResourceStateDeleting', 'EndpointResourceStateRunning', 'EndpointResourceStateStarting', 'EndpointResourceStateStopped', 'EndpointResourceStateStopping' - ResourceState EndpointResourceState `json:"resourceState,omitempty"` - // ProvisioningState - READ-ONLY; Provisioning status of the endpoint. - ProvisioningState *string `json:"provisioningState,omitempty"` - // OriginHostHeader - The host header value sent to the origin with each request. If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default. - OriginHostHeader *string `json:"originHostHeader,omitempty"` - // OriginPath - A directory path on the origin that CDN can use to retrieve content from, e.g. contoso.cloudapp.net/originpath. - OriginPath *string `json:"originPath,omitempty"` - // ContentTypesToCompress - List of content types on which compression applies. The value should be a valid MIME type. - ContentTypesToCompress *[]string `json:"contentTypesToCompress,omitempty"` - // IsCompressionEnabled - Indicates whether content compression is enabled on CDN. Default value is false. If compression is enabled, content will be served as compressed if user requests for a compressed version. Content won't be compressed on CDN when requested content is smaller than 1 byte or larger than 1 MB. - IsCompressionEnabled *bool `json:"isCompressionEnabled,omitempty"` - // IsHTTPAllowed - Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. - IsHTTPAllowed *bool `json:"isHttpAllowed,omitempty"` - // IsHTTPSAllowed - Indicates whether HTTPS traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. - IsHTTPSAllowed *bool `json:"isHttpsAllowed,omitempty"` - // QueryStringCachingBehavior - Defines how CDN caches requests that include query strings. You can ignore any query strings when caching, bypass caching to prevent requests that contain query strings from being cached, or cache every request with a unique URL. Possible values include: 'IgnoreQueryString', 'BypassCaching', 'UseQueryString', 'NotSet' - QueryStringCachingBehavior QueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` - // OptimizationType - Specifies what scenario the customer wants this CDN endpoint to optimize for, e.g. Download, Media services. With this information, CDN can apply scenario driven optimization. Possible values include: 'GeneralWebDelivery', 'GeneralMediaStreaming', 'VideoOnDemandMediaStreaming', 'LargeFileDownload', 'DynamicSiteAcceleration' - OptimizationType OptimizationType `json:"optimizationType,omitempty"` - // ProbePath - Path to a file hosted on the origin which helps accelerate delivery of the dynamic content and calculate the most optimal routes for the CDN. This is relative to the origin path. - ProbePath *string `json:"probePath,omitempty"` - // GeoFilters - List of rules defining the user's geo access within a CDN endpoint. Each geo filter defines an access rule to a specified path or content, e.g. block APAC for path /pictures/ - GeoFilters *[]GeoFilter `json:"geoFilters,omitempty"` - // DeliveryPolicy - A policy that specifies the delivery rules to be used for an endpoint. - DeliveryPolicy *EndpointPropertiesUpdateParametersDeliveryPolicy `json:"deliveryPolicy,omitempty"` -} - -// EndpointPropertiesUpdateParameters the JSON object containing endpoint update parameters. -type EndpointPropertiesUpdateParameters struct { - // OriginHostHeader - The host header value sent to the origin with each request. If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default. - OriginHostHeader *string `json:"originHostHeader,omitempty"` - // OriginPath - A directory path on the origin that CDN can use to retrieve content from, e.g. contoso.cloudapp.net/originpath. - OriginPath *string `json:"originPath,omitempty"` - // ContentTypesToCompress - List of content types on which compression applies. The value should be a valid MIME type. - ContentTypesToCompress *[]string `json:"contentTypesToCompress,omitempty"` - // IsCompressionEnabled - Indicates whether content compression is enabled on CDN. Default value is false. If compression is enabled, content will be served as compressed if user requests for a compressed version. Content won't be compressed on CDN when requested content is smaller than 1 byte or larger than 1 MB. - IsCompressionEnabled *bool `json:"isCompressionEnabled,omitempty"` - // IsHTTPAllowed - Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. - IsHTTPAllowed *bool `json:"isHttpAllowed,omitempty"` - // IsHTTPSAllowed - Indicates whether HTTPS traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. - IsHTTPSAllowed *bool `json:"isHttpsAllowed,omitempty"` - // QueryStringCachingBehavior - Defines how CDN caches requests that include query strings. You can ignore any query strings when caching, bypass caching to prevent requests that contain query strings from being cached, or cache every request with a unique URL. Possible values include: 'IgnoreQueryString', 'BypassCaching', 'UseQueryString', 'NotSet' - QueryStringCachingBehavior QueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` - // OptimizationType - Specifies what scenario the customer wants this CDN endpoint to optimize for, e.g. Download, Media services. With this information, CDN can apply scenario driven optimization. Possible values include: 'GeneralWebDelivery', 'GeneralMediaStreaming', 'VideoOnDemandMediaStreaming', 'LargeFileDownload', 'DynamicSiteAcceleration' - OptimizationType OptimizationType `json:"optimizationType,omitempty"` - // ProbePath - Path to a file hosted on the origin which helps accelerate delivery of the dynamic content and calculate the most optimal routes for the CDN. This is relative to the origin path. - ProbePath *string `json:"probePath,omitempty"` - // GeoFilters - List of rules defining the user's geo access within a CDN endpoint. Each geo filter defines an access rule to a specified path or content, e.g. block APAC for path /pictures/ - GeoFilters *[]GeoFilter `json:"geoFilters,omitempty"` - // DeliveryPolicy - A policy that specifies the delivery rules to be used for an endpoint. - DeliveryPolicy *EndpointPropertiesUpdateParametersDeliveryPolicy `json:"deliveryPolicy,omitempty"` -} - -// EndpointPropertiesUpdateParametersDeliveryPolicy a policy that specifies the delivery rules to be used -// for an endpoint. -type EndpointPropertiesUpdateParametersDeliveryPolicy struct { - // Description - User-friendly description of the policy. - Description *string `json:"description,omitempty"` - // Rules - A list of the delivery rules. - Rules *[]DeliveryRule `json:"rules,omitempty"` -} - -// EndpointsCreateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type EndpointsCreateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EndpointsCreateFuture) Result(client EndpointsClient) (e Endpoint, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.EndpointsCreateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { - e, err = client.CreateResponder(e.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsCreateFuture", "Result", e.Response.Response, "Failure responding to request") - } - } - return -} - -// EndpointsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type EndpointsDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EndpointsDeleteFuture) Result(client EndpointsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.EndpointsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// EndpointsLoadContentFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type EndpointsLoadContentFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EndpointsLoadContentFuture) Result(client EndpointsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsLoadContentFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.EndpointsLoadContentFuture") - return - } - ar.Response = future.Response() - return -} - -// EndpointsPurgeContentFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type EndpointsPurgeContentFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EndpointsPurgeContentFuture) Result(client EndpointsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsPurgeContentFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.EndpointsPurgeContentFuture") - return - } - ar.Response = future.Response() - return -} - -// EndpointsStartFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type EndpointsStartFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EndpointsStartFuture) Result(client EndpointsClient) (e Endpoint, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsStartFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.EndpointsStartFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { - e, err = client.StartResponder(e.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsStartFuture", "Result", e.Response.Response, "Failure responding to request") - } - } - return -} - -// EndpointsStopFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type EndpointsStopFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EndpointsStopFuture) Result(client EndpointsClient) (e Endpoint, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsStopFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.EndpointsStopFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { - e, err = client.StopResponder(e.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsStopFuture", "Result", e.Response.Response, "Failure responding to request") - } - } - return -} - -// EndpointsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type EndpointsUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *EndpointsUpdateFuture) Result(client EndpointsClient) (e Endpoint, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.EndpointsUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { - e, err = client.UpdateResponder(e.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.EndpointsUpdateFuture", "Result", e.Response.Response, "Failure responding to request") - } - } - return -} - -// EndpointUpdateParameters properties required to create or update an endpoint. -type EndpointUpdateParameters struct { - // Tags - Endpoint tags. - Tags map[string]*string `json:"tags"` - *EndpointPropertiesUpdateParameters `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for EndpointUpdateParameters. -func (eup EndpointUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if eup.Tags != nil { - objectMap["tags"] = eup.Tags - } - if eup.EndpointPropertiesUpdateParameters != nil { - objectMap["properties"] = eup.EndpointPropertiesUpdateParameters - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for EndpointUpdateParameters struct. -func (eup *EndpointUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - eup.Tags = tags - } - case "properties": - if v != nil { - var endpointPropertiesUpdateParameters EndpointPropertiesUpdateParameters - err = json.Unmarshal(*v, &endpointPropertiesUpdateParameters) - if err != nil { - return err - } - eup.EndpointPropertiesUpdateParameters = &endpointPropertiesUpdateParameters - } - } - } - - return nil -} - -// ErrorResponse error response indicates CDN service is not able to process the incoming request. The -// reason is provided in the error message. -type ErrorResponse struct { - // Code - READ-ONLY; Error code. - Code *string `json:"code,omitempty"` - // Message - READ-ONLY; Error message indicating why the operation failed. - Message *string `json:"message,omitempty"` -} - -// GeoFilter rules defining user's geo access within a CDN endpoint. -type GeoFilter struct { - // RelativePath - Relative path applicable to geo filter. (e.g. '/mypictures', '/mypicture/kitty.jpg', and etc.) - RelativePath *string `json:"relativePath,omitempty"` - // Action - Action of the geo filter, i.e. allow or block access. Possible values include: 'Block', 'Allow' - Action GeoFilterActions `json:"action,omitempty"` - // CountryCodes - Two letter country codes defining user country access in a geo filter, e.g. AU, MX, US. - CountryCodes *[]string `json:"countryCodes,omitempty"` -} - -// IPAddressGroup CDN Ip address group -type IPAddressGroup struct { - // DeliveryRegion - The delivery region of the ip address group - DeliveryRegion *string `json:"deliveryRegion,omitempty"` - // Ipv4Addresses - The list of ip v4 addresses. - Ipv4Addresses *[]CidrIPAddress `json:"ipv4Addresses,omitempty"` - // Ipv6Addresses - The list of ip v6 addresses. - Ipv6Addresses *[]CidrIPAddress `json:"ipv6Addresses,omitempty"` -} - -// KeyVaultCertificateSourceParameters describes the parameters for using a user's KeyVault certificate for -// securing custom domain. -type KeyVaultCertificateSourceParameters struct { - OdataType *string `json:"@odata.type,omitempty"` - // SubscriptionID - Subscription Id of the user's Key Vault containing the SSL certificate - SubscriptionID *string `json:"subscriptionId,omitempty"` - // ResourceGroupName - Resource group of the user's Key Vault containing the SSL certificate - ResourceGroupName *string `json:"resourceGroupName,omitempty"` - // VaultName - The name of the user's Key Vault containing the SSL certificate - VaultName *string `json:"vaultName,omitempty"` - // SecretName - The name of Key Vault Secret (representing the full certificate PFX) in Key Vault. - SecretName *string `json:"secretName,omitempty"` - // SecretVersion - The version(GUID) of Key Vault Secret in Key Vault. - SecretVersion *string `json:"secretVersion,omitempty"` - // UpdateRule - Describes the action that shall be taken when the certificate is updated in Key Vault. - UpdateRule *string `json:"updateRule,omitempty"` - // DeleteRule - Describes the action that shall be taken when the certificate is removed from Key Vault. - DeleteRule *string `json:"deleteRule,omitempty"` -} - -// LoadParameters parameters required for content load. -type LoadParameters struct { - // ContentPaths - The path to the content to be loaded. Path should be a relative file URL of the origin. - ContentPaths *[]string `json:"contentPaths,omitempty"` -} - -// ManagedHTTPSParameters defines the certificate source parameters using CDN managed certificate for -// enabling SSL. -type ManagedHTTPSParameters struct { - // CertificateSourceParameters - Defines the certificate source parameters using CDN managed certificate for enabling SSL. - CertificateSourceParameters *CertificateSourceParameters `json:"certificateSourceParameters,omitempty"` - // ProtocolType - Defines the TLS extension protocol that is used for secure delivery. Possible values include: 'ServerNameIndication', 'IPBased' - ProtocolType ProtocolType `json:"protocolType,omitempty"` - // CertificateSource - Possible values include: 'CertificateSourceCustomDomainHTTPSParameters', 'CertificateSourceCdn', 'CertificateSourceAzureKeyVault' - CertificateSource CertificateSource `json:"certificateSource,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagedHTTPSParameters. -func (mhp ManagedHTTPSParameters) MarshalJSON() ([]byte, error) { - mhp.CertificateSource = CertificateSourceCdn - objectMap := make(map[string]interface{}) - if mhp.CertificateSourceParameters != nil { - objectMap["certificateSourceParameters"] = mhp.CertificateSourceParameters - } - if mhp.ProtocolType != "" { - objectMap["protocolType"] = mhp.ProtocolType - } - if mhp.CertificateSource != "" { - objectMap["certificateSource"] = mhp.CertificateSource - } - return json.Marshal(objectMap) -} - -// AsManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. -func (mhp ManagedHTTPSParameters) AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) { - return &mhp, true -} - -// AsUserManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. -func (mhp ManagedHTTPSParameters) AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) { - return nil, false -} - -// AsCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. -func (mhp ManagedHTTPSParameters) AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) { - return nil, false -} - -// AsBasicCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. -func (mhp ManagedHTTPSParameters) AsBasicCustomDomainHTTPSParameters() (BasicCustomDomainHTTPSParameters, bool) { - return &mhp, true -} - -// Operation CDN REST API operation -type Operation struct { - // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - // Display - The object that represents the operation. - Display *OperationDisplay `json:"display,omitempty"` -} - -// OperationDisplay the object that represents the operation. -type OperationDisplay struct { - // Provider - READ-ONLY; Service provider: Microsoft.Cdn - Provider *string `json:"provider,omitempty"` - // Resource - READ-ONLY; Resource on which the operation is performed: Profile, endpoint, etc. - Resource *string `json:"resource,omitempty"` - // Operation - READ-ONLY; Operation type: Read, write, delete, etc. - Operation *string `json:"operation,omitempty"` -} - -// OperationsListResult result of the request to list CDN operations. It contains a list of operations and -// a URL link to get the next set of results. -type OperationsListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of CDN operations supported by the CDN resource provider. - Value *[]Operation `json:"value,omitempty"` - // NextLink - URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// OperationsListResultIterator provides access to a complete listing of Operation values. -type OperationsListResultIterator struct { - i int - page OperationsListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OperationsListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OperationsListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationsListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OperationsListResultIterator) Response() OperationsListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OperationsListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationsListResultIterator type. -func NewOperationsListResultIterator(page OperationsListResultPage) OperationsListResultIterator { - return OperationsListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationsListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// operationsListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationsListResult) operationsListResultPreparer(ctx context.Context) (*http.Request, error) { - if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationsListResultPage contains a page of Operation values. -type OperationsListResultPage struct { - fn func(context.Context, OperationsListResult) (OperationsListResult, error) - olr OperationsListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OperationsListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OperationsListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationsListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationsListResultPage) Response() OperationsListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationsListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationsListResultPage type. -func NewOperationsListResultPage(getNextPage func(context.Context, OperationsListResult) (OperationsListResult, error)) OperationsListResultPage { - return OperationsListResultPage{fn: getNextPage} -} - -// Origin CDN origin is the source of the content being delivered via CDN. When the edge nodes represented -// by an endpoint do not have the requested content cached, they attempt to fetch it from one or more of -// the configured origins. -type Origin struct { - autorest.Response `json:"-"` - *OriginProperties `json:"properties,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Origin. -func (o Origin) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if o.OriginProperties != nil { - objectMap["properties"] = o.OriginProperties - } - if o.Location != nil { - objectMap["location"] = o.Location - } - if o.Tags != nil { - objectMap["tags"] = o.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Origin struct. -func (o *Origin) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var originProperties OriginProperties - err = json.Unmarshal(*v, &originProperties) - if err != nil { - return err - } - o.OriginProperties = &originProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - o.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - o.Tags = tags - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - o.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - o.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - o.Type = &typeVar - } - } - } - - return nil -} - -// OriginListResult result of the request to list origins. It contains a list of origin objects and a URL -// link to get the next set of results. -type OriginListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of CDN origins within an endpoint - Value *[]Origin `json:"value,omitempty"` - // NextLink - URL to get the next set of origin objects if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// OriginListResultIterator provides access to a complete listing of Origin values. -type OriginListResultIterator struct { - i int - page OriginListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OriginListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OriginListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OriginListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OriginListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OriginListResultIterator) Response() OriginListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OriginListResultIterator) Value() Origin { - if !iter.page.NotDone() { - return Origin{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OriginListResultIterator type. -func NewOriginListResultIterator(page OriginListResultPage) OriginListResultIterator { - return OriginListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OriginListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// originListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OriginListResult) originListResultPreparer(ctx context.Context) (*http.Request, error) { - if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OriginListResultPage contains a page of Origin values. -type OriginListResultPage struct { - fn func(context.Context, OriginListResult) (OriginListResult, error) - olr OriginListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OriginListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OriginListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OriginListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OriginListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OriginListResultPage) Response() OriginListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OriginListResultPage) Values() []Origin { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OriginListResultPage type. -func NewOriginListResultPage(getNextPage func(context.Context, OriginListResult) (OriginListResult, error)) OriginListResultPage { - return OriginListResultPage{fn: getNextPage} -} - -// OriginProperties the JSON object that contains the properties of the origin. -type OriginProperties struct { - // HostName - The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported. - HostName *string `json:"hostName,omitempty"` - // HTTPPort - The value of the HTTP port. Must be between 1 and 65535. - HTTPPort *int32 `json:"httpPort,omitempty"` - // HTTPSPort - The value of the https port. Must be between 1 and 65535. - HTTPSPort *int32 `json:"httpsPort,omitempty"` - // ResourceState - READ-ONLY; Resource status of the origin. Possible values include: 'OriginResourceStateCreating', 'OriginResourceStateActive', 'OriginResourceStateDeleting' - ResourceState OriginResourceState `json:"resourceState,omitempty"` - // ProvisioningState - READ-ONLY; Provisioning status of the origin. - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// OriginPropertiesParameters the JSON object that contains the properties of the origin. -type OriginPropertiesParameters struct { - // HostName - The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported. - HostName *string `json:"hostName,omitempty"` - // HTTPPort - The value of the HTTP port. Must be between 1 and 65535. - HTTPPort *int32 `json:"httpPort,omitempty"` - // HTTPSPort - The value of the HTTPS port. Must be between 1 and 65535. - HTTPSPort *int32 `json:"httpsPort,omitempty"` -} - -// OriginsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type OriginsUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *OriginsUpdateFuture) Result(client OriginsClient) (o Origin, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.OriginsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.OriginsUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if o.Response.Response, err = future.GetResult(sender); err == nil && o.Response.Response.StatusCode != http.StatusNoContent { - o, err = client.UpdateResponder(o.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.OriginsUpdateFuture", "Result", o.Response.Response, "Failure responding to request") - } - } - return -} - -// OriginUpdateParameters origin properties needed for origin creation or update. -type OriginUpdateParameters struct { - *OriginPropertiesParameters `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for OriginUpdateParameters. -func (oup OriginUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if oup.OriginPropertiesParameters != nil { - objectMap["properties"] = oup.OriginPropertiesParameters - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for OriginUpdateParameters struct. -func (oup *OriginUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var originPropertiesParameters OriginPropertiesParameters - err = json.Unmarshal(*v, &originPropertiesParameters) - if err != nil { - return err - } - oup.OriginPropertiesParameters = &originPropertiesParameters - } - } - } - - return nil -} - -// Profile CDN profile is a logical grouping of endpoints that share the same settings, such as CDN -// provider and pricing tier. -type Profile struct { - autorest.Response `json:"-"` - // Sku - The pricing tier (defines a CDN provider, feature list and rate) of the CDN profile. - Sku *Sku `json:"sku,omitempty"` - *ProfileProperties `json:"properties,omitempty"` - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for Profile. -func (p Profile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if p.Sku != nil { - objectMap["sku"] = p.Sku - } - if p.ProfileProperties != nil { - objectMap["properties"] = p.ProfileProperties - } - if p.Location != nil { - objectMap["location"] = p.Location - } - if p.Tags != nil { - objectMap["tags"] = p.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Profile struct. -func (p *Profile) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - p.Sku = &sku - } - case "properties": - if v != nil { - var profileProperties ProfileProperties - err = json.Unmarshal(*v, &profileProperties) - if err != nil { - return err - } - p.ProfileProperties = &profileProperties - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - p.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - p.Tags = tags - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - p.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - p.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - p.Type = &typeVar - } - } - } - - return nil -} - -// ProfileListResult result of the request to list profiles. It contains a list of profile objects and a -// URL link to get the next set of results. -type ProfileListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of CDN profiles within a resource group. - Value *[]Profile `json:"value,omitempty"` - // NextLink - URL to get the next set of profile objects if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// ProfileListResultIterator provides access to a complete listing of Profile values. -type ProfileListResultIterator struct { - i int - page ProfileListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ProfileListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProfileListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ProfileListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ProfileListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ProfileListResultIterator) Response() ProfileListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ProfileListResultIterator) Value() Profile { - if !iter.page.NotDone() { - return Profile{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ProfileListResultIterator type. -func NewProfileListResultIterator(page ProfileListResultPage) ProfileListResultIterator { - return ProfileListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (plr ProfileListResult) IsEmpty() bool { - return plr.Value == nil || len(*plr.Value) == 0 -} - -// profileListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (plr ProfileListResult) profileListResultPreparer(ctx context.Context) (*http.Request, error) { - if plr.NextLink == nil || len(to.String(plr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(plr.NextLink))) -} - -// ProfileListResultPage contains a page of Profile values. -type ProfileListResultPage struct { - fn func(context.Context, ProfileListResult) (ProfileListResult, error) - plr ProfileListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ProfileListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ProfileListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.plr) - if err != nil { - return err - } - page.plr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ProfileListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ProfileListResultPage) NotDone() bool { - return !page.plr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ProfileListResultPage) Response() ProfileListResult { - return page.plr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ProfileListResultPage) Values() []Profile { - if page.plr.IsEmpty() { - return nil - } - return *page.plr.Value -} - -// Creates a new instance of the ProfileListResultPage type. -func NewProfileListResultPage(getNextPage func(context.Context, ProfileListResult) (ProfileListResult, error)) ProfileListResultPage { - return ProfileListResultPage{fn: getNextPage} -} - -// ProfileProperties the JSON object that contains the properties required to create a profile. -type ProfileProperties struct { - // ResourceState - READ-ONLY; Resource status of the profile. Possible values include: 'ProfileResourceStateCreating', 'ProfileResourceStateActive', 'ProfileResourceStateDeleting', 'ProfileResourceStateDisabled' - ResourceState ProfileResourceState `json:"resourceState,omitempty"` - // ProvisioningState - READ-ONLY; Provisioning status of the profile. - ProvisioningState *string `json:"provisioningState,omitempty"` -} - -// ProfilesCreateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ProfilesCreateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ProfilesCreateFuture) Result(client ProfilesClient) (p Profile, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.ProfilesCreateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if p.Response.Response, err = future.GetResult(sender); err == nil && p.Response.Response.StatusCode != http.StatusNoContent { - p, err = client.CreateResponder(p.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesCreateFuture", "Result", p.Response.Response, "Failure responding to request") - } - } - return -} - -// ProfilesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ProfilesDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ProfilesDeleteFuture) Result(client ProfilesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.ProfilesDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// ProfilesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ProfilesUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ProfilesUpdateFuture) Result(client ProfilesClient) (p Profile, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("cdn.ProfilesUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if p.Response.Response, err = future.GetResult(sender); err == nil && p.Response.Response.StatusCode != http.StatusNoContent { - p, err = client.UpdateResponder(p.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "cdn.ProfilesUpdateFuture", "Result", p.Response.Response, "Failure responding to request") - } - } - return -} - -// ProfileUpdateParameters properties required to update a profile. -type ProfileUpdateParameters struct { - // Tags - Profile tags - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ProfileUpdateParameters. -func (pup ProfileUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if pup.Tags != nil { - objectMap["tags"] = pup.Tags - } - return json.Marshal(objectMap) -} - -// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than -// required location and tags -type ProxyResource struct { - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// PurgeParameters parameters required for content purge. -type PurgeParameters struct { - // ContentPaths - The path to the content to be purged. Can describe a file path or a wild card directory. - ContentPaths *[]string `json:"contentPaths,omitempty"` -} - -// Resource the core properties of ARM resources -type Resource struct { - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// ResourceUsage output of check resource usage API. -type ResourceUsage struct { - // ResourceType - READ-ONLY; Resource type for which the usage is provided. - ResourceType *string `json:"resourceType,omitempty"` - // Unit - READ-ONLY; Unit of the usage. e.g. Count. - Unit *string `json:"unit,omitempty"` - // CurrentValue - READ-ONLY; Actual value of usage on the specified resource type. - CurrentValue *int32 `json:"currentValue,omitempty"` - // Limit - READ-ONLY; Quota of the specified resource type. - Limit *int32 `json:"limit,omitempty"` -} - -// ResourceUsageListResult output of check resource usage API. -type ResourceUsageListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of resource usages. - Value *[]ResourceUsage `json:"value,omitempty"` - // NextLink - URL to get the next set of custom domain objects if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// ResourceUsageListResultIterator provides access to a complete listing of ResourceUsage values. -type ResourceUsageListResultIterator struct { - i int - page ResourceUsageListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ResourceUsageListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ResourceUsageListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ResourceUsageListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ResourceUsageListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ResourceUsageListResultIterator) Response() ResourceUsageListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ResourceUsageListResultIterator) Value() ResourceUsage { - if !iter.page.NotDone() { - return ResourceUsage{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ResourceUsageListResultIterator type. -func NewResourceUsageListResultIterator(page ResourceUsageListResultPage) ResourceUsageListResultIterator { - return ResourceUsageListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (rulr ResourceUsageListResult) IsEmpty() bool { - return rulr.Value == nil || len(*rulr.Value) == 0 -} - -// resourceUsageListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (rulr ResourceUsageListResult) resourceUsageListResultPreparer(ctx context.Context) (*http.Request, error) { - if rulr.NextLink == nil || len(to.String(rulr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(rulr.NextLink))) -} - -// ResourceUsageListResultPage contains a page of ResourceUsage values. -type ResourceUsageListResultPage struct { - fn func(context.Context, ResourceUsageListResult) (ResourceUsageListResult, error) - rulr ResourceUsageListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ResourceUsageListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ResourceUsageListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.rulr) - if err != nil { - return err - } - page.rulr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ResourceUsageListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ResourceUsageListResultPage) NotDone() bool { - return !page.rulr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ResourceUsageListResultPage) Response() ResourceUsageListResult { - return page.rulr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ResourceUsageListResultPage) Values() []ResourceUsage { - if page.rulr.IsEmpty() { - return nil - } - return *page.rulr.Value -} - -// Creates a new instance of the ResourceUsageListResultPage type. -func NewResourceUsageListResultPage(getNextPage func(context.Context, ResourceUsageListResult) (ResourceUsageListResult, error)) ResourceUsageListResultPage { - return ResourceUsageListResultPage{fn: getNextPage} -} - -// Sku the pricing tier (defines a CDN provider, feature list and rate) of the CDN profile. -type Sku struct { - // Name - Name of the pricing tier. Possible values include: 'StandardVerizon', 'PremiumVerizon', 'CustomVerizon', 'StandardAkamai', 'StandardChinaCdn', 'PremiumChinaCdn', 'StandardMicrosoft' - Name SkuName `json:"name,omitempty"` -} - -// SsoURI the URI required to login to the supplemental portal from the Azure portal. -type SsoURI struct { - autorest.Response `json:"-"` - // SsoURIValue - READ-ONLY; The URI used to login to the supplemental portal. - SsoURIValue *string `json:"ssoUriValue,omitempty"` -} - -// SupportedOptimizationTypesListResult the result of the GetSupportedOptimizationTypes API -type SupportedOptimizationTypesListResult struct { - autorest.Response `json:"-"` - // SupportedOptimizationTypes - READ-ONLY; Supported optimization types for a profile. - SupportedOptimizationTypes *[]OptimizationType `json:"supportedOptimizationTypes,omitempty"` -} - -// TrackedResource the resource model definition for a ARM tracked top level resource. -type TrackedResource struct { - // Location - Resource location. - Location *string `json:"location,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` - // ID - READ-ONLY; Resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; Resource name. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; Resource type. - Type *string `json:"type,omitempty"` -} - -// MarshalJSON is the custom marshaler for TrackedResource. -func (tr TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if tr.Location != nil { - objectMap["location"] = tr.Location - } - if tr.Tags != nil { - objectMap["tags"] = tr.Tags - } - return json.Marshal(objectMap) -} - -// URLFileExtensionConditionParameters defines the parameters for the URL file extension condition. -type URLFileExtensionConditionParameters struct { - OdataType *string `json:"@odata.type,omitempty"` - // Extensions - A list of extensions for the condition of the delivery rule. - Extensions *[]string `json:"extensions,omitempty"` -} - -// URLPathConditionParameters defines the parameters for the URL path condition. -type URLPathConditionParameters struct { - OdataType *string `json:"@odata.type,omitempty"` - // Path - A URL path for the condition of the delivery rule - Path *string `json:"path,omitempty"` - // MatchType - The match type for the condition of the delivery rule. Possible values include: 'Literal', 'Wildcard' - MatchType MatchType `json:"matchType,omitempty"` -} - -// UserManagedHTTPSParameters defines the certificate source parameters using user's keyvault certificate -// for enabling SSL. -type UserManagedHTTPSParameters struct { - // CertificateSourceParameters - Defines the certificate source parameters using user's keyvault certificate for enabling SSL. - CertificateSourceParameters *KeyVaultCertificateSourceParameters `json:"certificateSourceParameters,omitempty"` - // ProtocolType - Defines the TLS extension protocol that is used for secure delivery. Possible values include: 'ServerNameIndication', 'IPBased' - ProtocolType ProtocolType `json:"protocolType,omitempty"` - // CertificateSource - Possible values include: 'CertificateSourceCustomDomainHTTPSParameters', 'CertificateSourceCdn', 'CertificateSourceAzureKeyVault' - CertificateSource CertificateSource `json:"certificateSource,omitempty"` -} - -// MarshalJSON is the custom marshaler for UserManagedHTTPSParameters. -func (umhp UserManagedHTTPSParameters) MarshalJSON() ([]byte, error) { - umhp.CertificateSource = CertificateSourceAzureKeyVault - objectMap := make(map[string]interface{}) - if umhp.CertificateSourceParameters != nil { - objectMap["certificateSourceParameters"] = umhp.CertificateSourceParameters - } - if umhp.ProtocolType != "" { - objectMap["protocolType"] = umhp.ProtocolType - } - if umhp.CertificateSource != "" { - objectMap["certificateSource"] = umhp.CertificateSource - } - return json.Marshal(objectMap) -} - -// AsManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. -func (umhp UserManagedHTTPSParameters) AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) { - return nil, false -} - -// AsUserManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. -func (umhp UserManagedHTTPSParameters) AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) { - return &umhp, true -} - -// AsCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. -func (umhp UserManagedHTTPSParameters) AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) { - return nil, false -} - -// AsBasicCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. -func (umhp UserManagedHTTPSParameters) AsBasicCustomDomainHTTPSParameters() (BasicCustomDomainHTTPSParameters, bool) { - return &umhp, true -} - -// ValidateCustomDomainInput input of the custom domain to be validated for DNS mapping. -type ValidateCustomDomainInput struct { - // HostName - The host name of the custom domain. Must be a domain name. - HostName *string `json:"hostName,omitempty"` -} - -// ValidateCustomDomainOutput output of custom domain validation. -type ValidateCustomDomainOutput struct { - autorest.Response `json:"-"` - // CustomDomainValidated - READ-ONLY; Indicates whether the custom domain is valid or not. - CustomDomainValidated *bool `json:"customDomainValidated,omitempty"` - // Reason - READ-ONLY; The reason why the custom domain is not valid. - Reason *string `json:"reason,omitempty"` - // Message - READ-ONLY; Error message describing why the custom domain is not valid. - Message *string `json:"message,omitempty"` -} - -// ValidateProbeInput input of the validate probe API. -type ValidateProbeInput struct { - // ProbeURL - The probe URL to validate. - ProbeURL *string `json:"probeURL,omitempty"` -} - -// ValidateProbeOutput output of the validate probe API. -type ValidateProbeOutput struct { - autorest.Response `json:"-"` - // IsValid - READ-ONLY; Indicates whether the probe URL is accepted or not. - IsValid *bool `json:"isValid,omitempty"` - // ErrorCode - READ-ONLY; Specifies the error code when the probe url is not accepted. - ErrorCode *string `json:"errorCode,omitempty"` - // Message - READ-ONLY; The detailed error message describing why the probe URL is not accepted. - Message *string `json:"message,omitempty"` -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/client.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/client.go index c3ca71296cca..8953f0fdebdb 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/client.go @@ -1,4 +1,4 @@ -// Package cdn implements the Azure ARM Cdn service API version 2017-10-12. +// Package cdn implements the Azure ARM Cdn service API version 2019-04-15. // // Cdn Management Client package cdn @@ -101,7 +101,7 @@ func (client BaseClient) CheckNameAvailability(ctx context.Context, checkNameAva // CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. func (client BaseClient) CheckNameAvailabilityPreparer(ctx context.Context, checkNameAvailabilityInput CheckNameAvailabilityInput) (*http.Request, error) { - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -184,7 +184,7 @@ func (client BaseClient) CheckNameAvailabilityWithSubscriptionPreparer(ctx conte "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -267,7 +267,7 @@ func (client BaseClient) ValidateProbePreparer(ctx context.Context, validateProb "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/customdomains.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/customdomains.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/customdomains.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/customdomains.go index 12efd820ed9d..ae4203eeab88 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/customdomains.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/customdomains.go @@ -96,7 +96,7 @@ func (client CustomDomainsClient) CreatePreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -186,7 +186,7 @@ func (client CustomDomainsClient) DeletePreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -280,7 +280,7 @@ func (client CustomDomainsClient) DisableCustomHTTPSPreparer(ctx context.Context "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -371,7 +371,7 @@ func (client CustomDomainsClient) EnableCustomHTTPSPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -464,7 +464,7 @@ func (client CustomDomainsClient) GetPreparer(ctx context.Context, resourceGroup "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -551,7 +551,7 @@ func (client CustomDomainsClient) ListByEndpointPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/edgenodes.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/edgenodes.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/edgenodes.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/edgenodes.go index 259612f2978f..4848a165ce86 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/edgenodes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/edgenodes.go @@ -77,7 +77,7 @@ func (client EdgeNodesClient) List(ctx context.Context) (result EdgenodeResultPa // ListPreparer prepares the List request. func (client EdgeNodesClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/endpoints.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/endpoints.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/endpoints.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/endpoints.go index d9db2eb1d50f..77bb75a8d88f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/endpoints.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/endpoints.go @@ -95,7 +95,7 @@ func (client EndpointsClient) CreatePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -184,7 +184,7 @@ func (client EndpointsClient) DeletePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -276,7 +276,7 @@ func (client EndpointsClient) GetPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -361,7 +361,7 @@ func (client EndpointsClient) ListByProfilePreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -485,7 +485,7 @@ func (client EndpointsClient) ListResourceUsagePreparer(ctx context.Context, res "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -606,7 +606,7 @@ func (client EndpointsClient) LoadContentPreparer(ctx context.Context, resourceG "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -698,7 +698,7 @@ func (client EndpointsClient) PurgeContentPreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -785,7 +785,7 @@ func (client EndpointsClient) StartPreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -871,7 +871,7 @@ func (client EndpointsClient) StopPreparer(ctx context.Context, resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -960,7 +960,7 @@ func (client EndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupN "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -1057,7 +1057,7 @@ func (client EndpointsClient) ValidateCustomDomainPreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/models.go new file mode 100644 index 000000000000..ddf37c0fded2 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/models.go @@ -0,0 +1,5859 @@ +package cdn + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" + +// CacheBehavior enumerates the values for cache behavior. +type CacheBehavior string + +const ( + // BypassCache ... + BypassCache CacheBehavior = "BypassCache" + // Override ... + Override CacheBehavior = "Override" + // SetIfMissing ... + SetIfMissing CacheBehavior = "SetIfMissing" +) + +// PossibleCacheBehaviorValues returns an array of possible values for the CacheBehavior const type. +func PossibleCacheBehaviorValues() []CacheBehavior { + return []CacheBehavior{BypassCache, Override, SetIfMissing} +} + +// CertificateSource enumerates the values for certificate source. +type CertificateSource string + +const ( + // CertificateSourceAzureKeyVault ... + CertificateSourceAzureKeyVault CertificateSource = "AzureKeyVault" + // CertificateSourceCdn ... + CertificateSourceCdn CertificateSource = "Cdn" + // CertificateSourceCustomDomainHTTPSParameters ... + CertificateSourceCustomDomainHTTPSParameters CertificateSource = "CustomDomainHttpsParameters" +) + +// PossibleCertificateSourceValues returns an array of possible values for the CertificateSource const type. +func PossibleCertificateSourceValues() []CertificateSource { + return []CertificateSource{CertificateSourceAzureKeyVault, CertificateSourceCdn, CertificateSourceCustomDomainHTTPSParameters} +} + +// CertificateType enumerates the values for certificate type. +type CertificateType string + +const ( + // Dedicated ... + Dedicated CertificateType = "Dedicated" + // Shared ... + Shared CertificateType = "Shared" +) + +// PossibleCertificateTypeValues returns an array of possible values for the CertificateType const type. +func PossibleCertificateTypeValues() []CertificateType { + return []CertificateType{Dedicated, Shared} +} + +// CookiesOperator enumerates the values for cookies operator. +type CookiesOperator string + +const ( + // Any ... + Any CookiesOperator = "Any" + // BeginsWith ... + BeginsWith CookiesOperator = "BeginsWith" + // Contains ... + Contains CookiesOperator = "Contains" + // EndsWith ... + EndsWith CookiesOperator = "EndsWith" + // Equal ... + Equal CookiesOperator = "Equal" + // GreaterThan ... + GreaterThan CookiesOperator = "GreaterThan" + // GreaterThanOrEqual ... + GreaterThanOrEqual CookiesOperator = "GreaterThanOrEqual" + // LessThan ... + LessThan CookiesOperator = "LessThan" + // LessThanOrEqual ... + LessThanOrEqual CookiesOperator = "LessThanOrEqual" +) + +// PossibleCookiesOperatorValues returns an array of possible values for the CookiesOperator const type. +func PossibleCookiesOperatorValues() []CookiesOperator { + return []CookiesOperator{Any, BeginsWith, Contains, EndsWith, Equal, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual} +} + +// CustomDomainResourceState enumerates the values for custom domain resource state. +type CustomDomainResourceState string + +const ( + // Active ... + Active CustomDomainResourceState = "Active" + // Creating ... + Creating CustomDomainResourceState = "Creating" + // Deleting ... + Deleting CustomDomainResourceState = "Deleting" +) + +// PossibleCustomDomainResourceStateValues returns an array of possible values for the CustomDomainResourceState const type. +func PossibleCustomDomainResourceStateValues() []CustomDomainResourceState { + return []CustomDomainResourceState{Active, Creating, Deleting} +} + +// CustomHTTPSProvisioningState enumerates the values for custom https provisioning state. +type CustomHTTPSProvisioningState string + +const ( + // Disabled ... + Disabled CustomHTTPSProvisioningState = "Disabled" + // Disabling ... + Disabling CustomHTTPSProvisioningState = "Disabling" + // Enabled ... + Enabled CustomHTTPSProvisioningState = "Enabled" + // Enabling ... + Enabling CustomHTTPSProvisioningState = "Enabling" + // Failed ... + Failed CustomHTTPSProvisioningState = "Failed" +) + +// PossibleCustomHTTPSProvisioningStateValues returns an array of possible values for the CustomHTTPSProvisioningState const type. +func PossibleCustomHTTPSProvisioningStateValues() []CustomHTTPSProvisioningState { + return []CustomHTTPSProvisioningState{Disabled, Disabling, Enabled, Enabling, Failed} +} + +// CustomHTTPSProvisioningSubstate enumerates the values for custom https provisioning substate. +type CustomHTTPSProvisioningSubstate string + +const ( + // CertificateDeleted ... + CertificateDeleted CustomHTTPSProvisioningSubstate = "CertificateDeleted" + // CertificateDeployed ... + CertificateDeployed CustomHTTPSProvisioningSubstate = "CertificateDeployed" + // DeletingCertificate ... + DeletingCertificate CustomHTTPSProvisioningSubstate = "DeletingCertificate" + // DeployingCertificate ... + DeployingCertificate CustomHTTPSProvisioningSubstate = "DeployingCertificate" + // DomainControlValidationRequestApproved ... + DomainControlValidationRequestApproved CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestApproved" + // DomainControlValidationRequestRejected ... + DomainControlValidationRequestRejected CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestRejected" + // DomainControlValidationRequestTimedOut ... + DomainControlValidationRequestTimedOut CustomHTTPSProvisioningSubstate = "DomainControlValidationRequestTimedOut" + // IssuingCertificate ... + IssuingCertificate CustomHTTPSProvisioningSubstate = "IssuingCertificate" + // PendingDomainControlValidationREquestApproval ... + PendingDomainControlValidationREquestApproval CustomHTTPSProvisioningSubstate = "PendingDomainControlValidationREquestApproval" + // SubmittingDomainControlValidationRequest ... + SubmittingDomainControlValidationRequest CustomHTTPSProvisioningSubstate = "SubmittingDomainControlValidationRequest" +) + +// PossibleCustomHTTPSProvisioningSubstateValues returns an array of possible values for the CustomHTTPSProvisioningSubstate const type. +func PossibleCustomHTTPSProvisioningSubstateValues() []CustomHTTPSProvisioningSubstate { + return []CustomHTTPSProvisioningSubstate{CertificateDeleted, CertificateDeployed, DeletingCertificate, DeployingCertificate, DomainControlValidationRequestApproved, DomainControlValidationRequestRejected, DomainControlValidationRequestTimedOut, IssuingCertificate, PendingDomainControlValidationREquestApproval, SubmittingDomainControlValidationRequest} +} + +// DestinationProtocol enumerates the values for destination protocol. +type DestinationProtocol string + +const ( + // HTTP ... + HTTP DestinationProtocol = "Http" + // HTTPS ... + HTTPS DestinationProtocol = "Https" + // MatchRequest ... + MatchRequest DestinationProtocol = "MatchRequest" +) + +// PossibleDestinationProtocolValues returns an array of possible values for the DestinationProtocol const type. +func PossibleDestinationProtocolValues() []DestinationProtocol { + return []DestinationProtocol{HTTP, HTTPS, MatchRequest} +} + +// EndpointResourceState enumerates the values for endpoint resource state. +type EndpointResourceState string + +const ( + // EndpointResourceStateCreating ... + EndpointResourceStateCreating EndpointResourceState = "Creating" + // EndpointResourceStateDeleting ... + EndpointResourceStateDeleting EndpointResourceState = "Deleting" + // EndpointResourceStateRunning ... + EndpointResourceStateRunning EndpointResourceState = "Running" + // EndpointResourceStateStarting ... + EndpointResourceStateStarting EndpointResourceState = "Starting" + // EndpointResourceStateStopped ... + EndpointResourceStateStopped EndpointResourceState = "Stopped" + // EndpointResourceStateStopping ... + EndpointResourceStateStopping EndpointResourceState = "Stopping" +) + +// PossibleEndpointResourceStateValues returns an array of possible values for the EndpointResourceState const type. +func PossibleEndpointResourceStateValues() []EndpointResourceState { + return []EndpointResourceState{EndpointResourceStateCreating, EndpointResourceStateDeleting, EndpointResourceStateRunning, EndpointResourceStateStarting, EndpointResourceStateStopped, EndpointResourceStateStopping} +} + +// GeoFilterActions enumerates the values for geo filter actions. +type GeoFilterActions string + +const ( + // Allow ... + Allow GeoFilterActions = "Allow" + // Block ... + Block GeoFilterActions = "Block" +) + +// PossibleGeoFilterActionsValues returns an array of possible values for the GeoFilterActions const type. +func PossibleGeoFilterActionsValues() []GeoFilterActions { + return []GeoFilterActions{Allow, Block} +} + +// HeaderAction enumerates the values for header action. +type HeaderAction string + +const ( + // Append ... + Append HeaderAction = "Append" + // Delete ... + Delete HeaderAction = "Delete" + // Overwrite ... + Overwrite HeaderAction = "Overwrite" +) + +// PossibleHeaderActionValues returns an array of possible values for the HeaderAction const type. +func PossibleHeaderActionValues() []HeaderAction { + return []HeaderAction{Append, Delete, Overwrite} +} + +// MinimumTLSVersion enumerates the values for minimum tls version. +type MinimumTLSVersion string + +const ( + // None ... + None MinimumTLSVersion = "None" + // TLS10 ... + TLS10 MinimumTLSVersion = "TLS10" + // TLS12 ... + TLS12 MinimumTLSVersion = "TLS12" +) + +// PossibleMinimumTLSVersionValues returns an array of possible values for the MinimumTLSVersion const type. +func PossibleMinimumTLSVersionValues() []MinimumTLSVersion { + return []MinimumTLSVersion{None, TLS10, TLS12} +} + +// Name enumerates the values for name. +type Name string + +const ( + // NameCookies ... + NameCookies Name = "Cookies" + // NameDeliveryRuleCondition ... + NameDeliveryRuleCondition Name = "DeliveryRuleCondition" + // NameHTTPVersion ... + NameHTTPVersion Name = "HttpVersion" + // NameIsDevice ... + NameIsDevice Name = "IsDevice" + // NamePostArgs ... + NamePostArgs Name = "PostArgs" + // NameQueryString ... + NameQueryString Name = "QueryString" + // NameRemoteAddress ... + NameRemoteAddress Name = "RemoteAddress" + // NameRequestBody ... + NameRequestBody Name = "RequestBody" + // NameRequestHeader ... + NameRequestHeader Name = "RequestHeader" + // NameRequestMethod ... + NameRequestMethod Name = "RequestMethod" + // NameRequestScheme ... + NameRequestScheme Name = "RequestScheme" + // NameRequestURI ... + NameRequestURI Name = "RequestUri" + // NameURLFileExtension ... + NameURLFileExtension Name = "UrlFileExtension" + // NameURLFileName ... + NameURLFileName Name = "UrlFileName" + // NameURLPath ... + NameURLPath Name = "UrlPath" +) + +// PossibleNameValues returns an array of possible values for the Name const type. +func PossibleNameValues() []Name { + return []Name{NameCookies, NameDeliveryRuleCondition, NameHTTPVersion, NameIsDevice, NamePostArgs, NameQueryString, NameRemoteAddress, NameRequestBody, NameRequestHeader, NameRequestMethod, NameRequestScheme, NameRequestURI, NameURLFileExtension, NameURLFileName, NameURLPath} +} + +// NameBasicDeliveryRuleAction enumerates the values for name basic delivery rule action. +type NameBasicDeliveryRuleAction string + +const ( + // NameCacheExpiration ... + NameCacheExpiration NameBasicDeliveryRuleAction = "CacheExpiration" + // NameCacheKeyQueryString ... + NameCacheKeyQueryString NameBasicDeliveryRuleAction = "CacheKeyQueryString" + // NameDeliveryRuleAction ... + NameDeliveryRuleAction NameBasicDeliveryRuleAction = "DeliveryRuleAction" + // NameModifyRequestHeader ... + NameModifyRequestHeader NameBasicDeliveryRuleAction = "ModifyRequestHeader" + // NameModifyResponseHeader ... + NameModifyResponseHeader NameBasicDeliveryRuleAction = "ModifyResponseHeader" + // NameURLRedirect ... + NameURLRedirect NameBasicDeliveryRuleAction = "UrlRedirect" + // NameURLRewrite ... + NameURLRewrite NameBasicDeliveryRuleAction = "UrlRewrite" +) + +// PossibleNameBasicDeliveryRuleActionValues returns an array of possible values for the NameBasicDeliveryRuleAction const type. +func PossibleNameBasicDeliveryRuleActionValues() []NameBasicDeliveryRuleAction { + return []NameBasicDeliveryRuleAction{NameCacheExpiration, NameCacheKeyQueryString, NameDeliveryRuleAction, NameModifyRequestHeader, NameModifyResponseHeader, NameURLRedirect, NameURLRewrite} +} + +// OptimizationType enumerates the values for optimization type. +type OptimizationType string + +const ( + // DynamicSiteAcceleration ... + DynamicSiteAcceleration OptimizationType = "DynamicSiteAcceleration" + // GeneralMediaStreaming ... + GeneralMediaStreaming OptimizationType = "GeneralMediaStreaming" + // GeneralWebDelivery ... + GeneralWebDelivery OptimizationType = "GeneralWebDelivery" + // LargeFileDownload ... + LargeFileDownload OptimizationType = "LargeFileDownload" + // VideoOnDemandMediaStreaming ... + VideoOnDemandMediaStreaming OptimizationType = "VideoOnDemandMediaStreaming" +) + +// PossibleOptimizationTypeValues returns an array of possible values for the OptimizationType const type. +func PossibleOptimizationTypeValues() []OptimizationType { + return []OptimizationType{DynamicSiteAcceleration, GeneralMediaStreaming, GeneralWebDelivery, LargeFileDownload, VideoOnDemandMediaStreaming} +} + +// OriginResourceState enumerates the values for origin resource state. +type OriginResourceState string + +const ( + // OriginResourceStateActive ... + OriginResourceStateActive OriginResourceState = "Active" + // OriginResourceStateCreating ... + OriginResourceStateCreating OriginResourceState = "Creating" + // OriginResourceStateDeleting ... + OriginResourceStateDeleting OriginResourceState = "Deleting" +) + +// PossibleOriginResourceStateValues returns an array of possible values for the OriginResourceState const type. +func PossibleOriginResourceStateValues() []OriginResourceState { + return []OriginResourceState{OriginResourceStateActive, OriginResourceStateCreating, OriginResourceStateDeleting} +} + +// PostArgsOperator enumerates the values for post args operator. +type PostArgsOperator string + +const ( + // PostArgsOperatorAny ... + PostArgsOperatorAny PostArgsOperator = "Any" + // PostArgsOperatorBeginsWith ... + PostArgsOperatorBeginsWith PostArgsOperator = "BeginsWith" + // PostArgsOperatorContains ... + PostArgsOperatorContains PostArgsOperator = "Contains" + // PostArgsOperatorEndsWith ... + PostArgsOperatorEndsWith PostArgsOperator = "EndsWith" + // PostArgsOperatorEqual ... + PostArgsOperatorEqual PostArgsOperator = "Equal" + // PostArgsOperatorGreaterThan ... + PostArgsOperatorGreaterThan PostArgsOperator = "GreaterThan" + // PostArgsOperatorGreaterThanOrEqual ... + PostArgsOperatorGreaterThanOrEqual PostArgsOperator = "GreaterThanOrEqual" + // PostArgsOperatorLessThan ... + PostArgsOperatorLessThan PostArgsOperator = "LessThan" + // PostArgsOperatorLessThanOrEqual ... + PostArgsOperatorLessThanOrEqual PostArgsOperator = "LessThanOrEqual" +) + +// PossiblePostArgsOperatorValues returns an array of possible values for the PostArgsOperator const type. +func PossiblePostArgsOperatorValues() []PostArgsOperator { + return []PostArgsOperator{PostArgsOperatorAny, PostArgsOperatorBeginsWith, PostArgsOperatorContains, PostArgsOperatorEndsWith, PostArgsOperatorEqual, PostArgsOperatorGreaterThan, PostArgsOperatorGreaterThanOrEqual, PostArgsOperatorLessThan, PostArgsOperatorLessThanOrEqual} +} + +// ProfileResourceState enumerates the values for profile resource state. +type ProfileResourceState string + +const ( + // ProfileResourceStateActive ... + ProfileResourceStateActive ProfileResourceState = "Active" + // ProfileResourceStateCreating ... + ProfileResourceStateCreating ProfileResourceState = "Creating" + // ProfileResourceStateDeleting ... + ProfileResourceStateDeleting ProfileResourceState = "Deleting" + // ProfileResourceStateDisabled ... + ProfileResourceStateDisabled ProfileResourceState = "Disabled" +) + +// PossibleProfileResourceStateValues returns an array of possible values for the ProfileResourceState const type. +func PossibleProfileResourceStateValues() []ProfileResourceState { + return []ProfileResourceState{ProfileResourceStateActive, ProfileResourceStateCreating, ProfileResourceStateDeleting, ProfileResourceStateDisabled} +} + +// ProtocolType enumerates the values for protocol type. +type ProtocolType string + +const ( + // IPBased ... + IPBased ProtocolType = "IPBased" + // ServerNameIndication ... + ServerNameIndication ProtocolType = "ServerNameIndication" +) + +// PossibleProtocolTypeValues returns an array of possible values for the ProtocolType const type. +func PossibleProtocolTypeValues() []ProtocolType { + return []ProtocolType{IPBased, ServerNameIndication} +} + +// QueryStringBehavior enumerates the values for query string behavior. +type QueryStringBehavior string + +const ( + // Exclude ... + Exclude QueryStringBehavior = "Exclude" + // ExcludeAll ... + ExcludeAll QueryStringBehavior = "ExcludeAll" + // Include ... + Include QueryStringBehavior = "Include" + // IncludeAll ... + IncludeAll QueryStringBehavior = "IncludeAll" +) + +// PossibleQueryStringBehaviorValues returns an array of possible values for the QueryStringBehavior const type. +func PossibleQueryStringBehaviorValues() []QueryStringBehavior { + return []QueryStringBehavior{Exclude, ExcludeAll, Include, IncludeAll} +} + +// QueryStringCachingBehavior enumerates the values for query string caching behavior. +type QueryStringCachingBehavior string + +const ( + // BypassCaching ... + BypassCaching QueryStringCachingBehavior = "BypassCaching" + // IgnoreQueryString ... + IgnoreQueryString QueryStringCachingBehavior = "IgnoreQueryString" + // NotSet ... + NotSet QueryStringCachingBehavior = "NotSet" + // UseQueryString ... + UseQueryString QueryStringCachingBehavior = "UseQueryString" +) + +// PossibleQueryStringCachingBehaviorValues returns an array of possible values for the QueryStringCachingBehavior const type. +func PossibleQueryStringCachingBehaviorValues() []QueryStringCachingBehavior { + return []QueryStringCachingBehavior{BypassCaching, IgnoreQueryString, NotSet, UseQueryString} +} + +// QueryStringOperator enumerates the values for query string operator. +type QueryStringOperator string + +const ( + // QueryStringOperatorAny ... + QueryStringOperatorAny QueryStringOperator = "Any" + // QueryStringOperatorBeginsWith ... + QueryStringOperatorBeginsWith QueryStringOperator = "BeginsWith" + // QueryStringOperatorContains ... + QueryStringOperatorContains QueryStringOperator = "Contains" + // QueryStringOperatorEndsWith ... + QueryStringOperatorEndsWith QueryStringOperator = "EndsWith" + // QueryStringOperatorEqual ... + QueryStringOperatorEqual QueryStringOperator = "Equal" + // QueryStringOperatorGreaterThan ... + QueryStringOperatorGreaterThan QueryStringOperator = "GreaterThan" + // QueryStringOperatorGreaterThanOrEqual ... + QueryStringOperatorGreaterThanOrEqual QueryStringOperator = "GreaterThanOrEqual" + // QueryStringOperatorLessThan ... + QueryStringOperatorLessThan QueryStringOperator = "LessThan" + // QueryStringOperatorLessThanOrEqual ... + QueryStringOperatorLessThanOrEqual QueryStringOperator = "LessThanOrEqual" +) + +// PossibleQueryStringOperatorValues returns an array of possible values for the QueryStringOperator const type. +func PossibleQueryStringOperatorValues() []QueryStringOperator { + return []QueryStringOperator{QueryStringOperatorAny, QueryStringOperatorBeginsWith, QueryStringOperatorContains, QueryStringOperatorEndsWith, QueryStringOperatorEqual, QueryStringOperatorGreaterThan, QueryStringOperatorGreaterThanOrEqual, QueryStringOperatorLessThan, QueryStringOperatorLessThanOrEqual} +} + +// RedirectType enumerates the values for redirect type. +type RedirectType string + +const ( + // Found ... + Found RedirectType = "Found" + // Moved ... + Moved RedirectType = "Moved" + // PermanentRedirect ... + PermanentRedirect RedirectType = "PermanentRedirect" + // TemporaryRedirect ... + TemporaryRedirect RedirectType = "TemporaryRedirect" +) + +// PossibleRedirectTypeValues returns an array of possible values for the RedirectType const type. +func PossibleRedirectTypeValues() []RedirectType { + return []RedirectType{Found, Moved, PermanentRedirect, TemporaryRedirect} +} + +// RemoteAddressOperator enumerates the values for remote address operator. +type RemoteAddressOperator string + +const ( + // RemoteAddressOperatorAny ... + RemoteAddressOperatorAny RemoteAddressOperator = "Any" + // RemoteAddressOperatorGeoMatch ... + RemoteAddressOperatorGeoMatch RemoteAddressOperator = "GeoMatch" + // RemoteAddressOperatorIPMatch ... + RemoteAddressOperatorIPMatch RemoteAddressOperator = "IPMatch" +) + +// PossibleRemoteAddressOperatorValues returns an array of possible values for the RemoteAddressOperator const type. +func PossibleRemoteAddressOperatorValues() []RemoteAddressOperator { + return []RemoteAddressOperator{RemoteAddressOperatorAny, RemoteAddressOperatorGeoMatch, RemoteAddressOperatorIPMatch} +} + +// RequestBodyOperator enumerates the values for request body operator. +type RequestBodyOperator string + +const ( + // RequestBodyOperatorAny ... + RequestBodyOperatorAny RequestBodyOperator = "Any" + // RequestBodyOperatorBeginsWith ... + RequestBodyOperatorBeginsWith RequestBodyOperator = "BeginsWith" + // RequestBodyOperatorContains ... + RequestBodyOperatorContains RequestBodyOperator = "Contains" + // RequestBodyOperatorEndsWith ... + RequestBodyOperatorEndsWith RequestBodyOperator = "EndsWith" + // RequestBodyOperatorEqual ... + RequestBodyOperatorEqual RequestBodyOperator = "Equal" + // RequestBodyOperatorGreaterThan ... + RequestBodyOperatorGreaterThan RequestBodyOperator = "GreaterThan" + // RequestBodyOperatorGreaterThanOrEqual ... + RequestBodyOperatorGreaterThanOrEqual RequestBodyOperator = "GreaterThanOrEqual" + // RequestBodyOperatorLessThan ... + RequestBodyOperatorLessThan RequestBodyOperator = "LessThan" + // RequestBodyOperatorLessThanOrEqual ... + RequestBodyOperatorLessThanOrEqual RequestBodyOperator = "LessThanOrEqual" +) + +// PossibleRequestBodyOperatorValues returns an array of possible values for the RequestBodyOperator const type. +func PossibleRequestBodyOperatorValues() []RequestBodyOperator { + return []RequestBodyOperator{RequestBodyOperatorAny, RequestBodyOperatorBeginsWith, RequestBodyOperatorContains, RequestBodyOperatorEndsWith, RequestBodyOperatorEqual, RequestBodyOperatorGreaterThan, RequestBodyOperatorGreaterThanOrEqual, RequestBodyOperatorLessThan, RequestBodyOperatorLessThanOrEqual} +} + +// RequestHeaderOperator enumerates the values for request header operator. +type RequestHeaderOperator string + +const ( + // RequestHeaderOperatorAny ... + RequestHeaderOperatorAny RequestHeaderOperator = "Any" + // RequestHeaderOperatorBeginsWith ... + RequestHeaderOperatorBeginsWith RequestHeaderOperator = "BeginsWith" + // RequestHeaderOperatorContains ... + RequestHeaderOperatorContains RequestHeaderOperator = "Contains" + // RequestHeaderOperatorEndsWith ... + RequestHeaderOperatorEndsWith RequestHeaderOperator = "EndsWith" + // RequestHeaderOperatorEqual ... + RequestHeaderOperatorEqual RequestHeaderOperator = "Equal" + // RequestHeaderOperatorGreaterThan ... + RequestHeaderOperatorGreaterThan RequestHeaderOperator = "GreaterThan" + // RequestHeaderOperatorGreaterThanOrEqual ... + RequestHeaderOperatorGreaterThanOrEqual RequestHeaderOperator = "GreaterThanOrEqual" + // RequestHeaderOperatorLessThan ... + RequestHeaderOperatorLessThan RequestHeaderOperator = "LessThan" + // RequestHeaderOperatorLessThanOrEqual ... + RequestHeaderOperatorLessThanOrEqual RequestHeaderOperator = "LessThanOrEqual" +) + +// PossibleRequestHeaderOperatorValues returns an array of possible values for the RequestHeaderOperator const type. +func PossibleRequestHeaderOperatorValues() []RequestHeaderOperator { + return []RequestHeaderOperator{RequestHeaderOperatorAny, RequestHeaderOperatorBeginsWith, RequestHeaderOperatorContains, RequestHeaderOperatorEndsWith, RequestHeaderOperatorEqual, RequestHeaderOperatorGreaterThan, RequestHeaderOperatorGreaterThanOrEqual, RequestHeaderOperatorLessThan, RequestHeaderOperatorLessThanOrEqual} +} + +// RequestURIOperator enumerates the values for request uri operator. +type RequestURIOperator string + +const ( + // RequestURIOperatorAny ... + RequestURIOperatorAny RequestURIOperator = "Any" + // RequestURIOperatorBeginsWith ... + RequestURIOperatorBeginsWith RequestURIOperator = "BeginsWith" + // RequestURIOperatorContains ... + RequestURIOperatorContains RequestURIOperator = "Contains" + // RequestURIOperatorEndsWith ... + RequestURIOperatorEndsWith RequestURIOperator = "EndsWith" + // RequestURIOperatorEqual ... + RequestURIOperatorEqual RequestURIOperator = "Equal" + // RequestURIOperatorGreaterThan ... + RequestURIOperatorGreaterThan RequestURIOperator = "GreaterThan" + // RequestURIOperatorGreaterThanOrEqual ... + RequestURIOperatorGreaterThanOrEqual RequestURIOperator = "GreaterThanOrEqual" + // RequestURIOperatorLessThan ... + RequestURIOperatorLessThan RequestURIOperator = "LessThan" + // RequestURIOperatorLessThanOrEqual ... + RequestURIOperatorLessThanOrEqual RequestURIOperator = "LessThanOrEqual" +) + +// PossibleRequestURIOperatorValues returns an array of possible values for the RequestURIOperator const type. +func PossibleRequestURIOperatorValues() []RequestURIOperator { + return []RequestURIOperator{RequestURIOperatorAny, RequestURIOperatorBeginsWith, RequestURIOperatorContains, RequestURIOperatorEndsWith, RequestURIOperatorEqual, RequestURIOperatorGreaterThan, RequestURIOperatorGreaterThanOrEqual, RequestURIOperatorLessThan, RequestURIOperatorLessThanOrEqual} +} + +// ResourceType enumerates the values for resource type. +type ResourceType string + +const ( + // MicrosoftCdnProfilesEndpoints ... + MicrosoftCdnProfilesEndpoints ResourceType = "Microsoft.Cdn/Profiles/Endpoints" +) + +// PossibleResourceTypeValues returns an array of possible values for the ResourceType const type. +func PossibleResourceTypeValues() []ResourceType { + return []ResourceType{MicrosoftCdnProfilesEndpoints} +} + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // CustomVerizon ... + CustomVerizon SkuName = "Custom_Verizon" + // PremiumChinaCdn ... + PremiumChinaCdn SkuName = "Premium_ChinaCdn" + // PremiumVerizon ... + PremiumVerizon SkuName = "Premium_Verizon" + // StandardAkamai ... + StandardAkamai SkuName = "Standard_Akamai" + // StandardChinaCdn ... + StandardChinaCdn SkuName = "Standard_ChinaCdn" + // StandardMicrosoft ... + StandardMicrosoft SkuName = "Standard_Microsoft" + // StandardVerizon ... + StandardVerizon SkuName = "Standard_Verizon" +) + +// PossibleSkuNameValues returns an array of possible values for the SkuName const type. +func PossibleSkuNameValues() []SkuName { + return []SkuName{CustomVerizon, PremiumChinaCdn, PremiumVerizon, StandardAkamai, StandardChinaCdn, StandardMicrosoft, StandardVerizon} +} + +// Transform enumerates the values for transform. +type Transform string + +const ( + // Lowercase ... + Lowercase Transform = "Lowercase" + // Uppercase ... + Uppercase Transform = "Uppercase" +) + +// PossibleTransformValues returns an array of possible values for the Transform const type. +func PossibleTransformValues() []Transform { + return []Transform{Lowercase, Uppercase} +} + +// URLFileExtensionOperator enumerates the values for url file extension operator. +type URLFileExtensionOperator string + +const ( + // URLFileExtensionOperatorAny ... + URLFileExtensionOperatorAny URLFileExtensionOperator = "Any" + // URLFileExtensionOperatorBeginsWith ... + URLFileExtensionOperatorBeginsWith URLFileExtensionOperator = "BeginsWith" + // URLFileExtensionOperatorContains ... + URLFileExtensionOperatorContains URLFileExtensionOperator = "Contains" + // URLFileExtensionOperatorEndsWith ... + URLFileExtensionOperatorEndsWith URLFileExtensionOperator = "EndsWith" + // URLFileExtensionOperatorEqual ... + URLFileExtensionOperatorEqual URLFileExtensionOperator = "Equal" + // URLFileExtensionOperatorGreaterThan ... + URLFileExtensionOperatorGreaterThan URLFileExtensionOperator = "GreaterThan" + // URLFileExtensionOperatorGreaterThanOrEqual ... + URLFileExtensionOperatorGreaterThanOrEqual URLFileExtensionOperator = "GreaterThanOrEqual" + // URLFileExtensionOperatorLessThan ... + URLFileExtensionOperatorLessThan URLFileExtensionOperator = "LessThan" + // URLFileExtensionOperatorLessThanOrEqual ... + URLFileExtensionOperatorLessThanOrEqual URLFileExtensionOperator = "LessThanOrEqual" +) + +// PossibleURLFileExtensionOperatorValues returns an array of possible values for the URLFileExtensionOperator const type. +func PossibleURLFileExtensionOperatorValues() []URLFileExtensionOperator { + return []URLFileExtensionOperator{URLFileExtensionOperatorAny, URLFileExtensionOperatorBeginsWith, URLFileExtensionOperatorContains, URLFileExtensionOperatorEndsWith, URLFileExtensionOperatorEqual, URLFileExtensionOperatorGreaterThan, URLFileExtensionOperatorGreaterThanOrEqual, URLFileExtensionOperatorLessThan, URLFileExtensionOperatorLessThanOrEqual} +} + +// URLFileNameOperator enumerates the values for url file name operator. +type URLFileNameOperator string + +const ( + // URLFileNameOperatorAny ... + URLFileNameOperatorAny URLFileNameOperator = "Any" + // URLFileNameOperatorBeginsWith ... + URLFileNameOperatorBeginsWith URLFileNameOperator = "BeginsWith" + // URLFileNameOperatorContains ... + URLFileNameOperatorContains URLFileNameOperator = "Contains" + // URLFileNameOperatorEndsWith ... + URLFileNameOperatorEndsWith URLFileNameOperator = "EndsWith" + // URLFileNameOperatorEqual ... + URLFileNameOperatorEqual URLFileNameOperator = "Equal" + // URLFileNameOperatorGreaterThan ... + URLFileNameOperatorGreaterThan URLFileNameOperator = "GreaterThan" + // URLFileNameOperatorGreaterThanOrEqual ... + URLFileNameOperatorGreaterThanOrEqual URLFileNameOperator = "GreaterThanOrEqual" + // URLFileNameOperatorLessThan ... + URLFileNameOperatorLessThan URLFileNameOperator = "LessThan" + // URLFileNameOperatorLessThanOrEqual ... + URLFileNameOperatorLessThanOrEqual URLFileNameOperator = "LessThanOrEqual" +) + +// PossibleURLFileNameOperatorValues returns an array of possible values for the URLFileNameOperator const type. +func PossibleURLFileNameOperatorValues() []URLFileNameOperator { + return []URLFileNameOperator{URLFileNameOperatorAny, URLFileNameOperatorBeginsWith, URLFileNameOperatorContains, URLFileNameOperatorEndsWith, URLFileNameOperatorEqual, URLFileNameOperatorGreaterThan, URLFileNameOperatorGreaterThanOrEqual, URLFileNameOperatorLessThan, URLFileNameOperatorLessThanOrEqual} +} + +// URLPathOperator enumerates the values for url path operator. +type URLPathOperator string + +const ( + // URLPathOperatorAny ... + URLPathOperatorAny URLPathOperator = "Any" + // URLPathOperatorBeginsWith ... + URLPathOperatorBeginsWith URLPathOperator = "BeginsWith" + // URLPathOperatorContains ... + URLPathOperatorContains URLPathOperator = "Contains" + // URLPathOperatorEndsWith ... + URLPathOperatorEndsWith URLPathOperator = "EndsWith" + // URLPathOperatorEqual ... + URLPathOperatorEqual URLPathOperator = "Equal" + // URLPathOperatorGreaterThan ... + URLPathOperatorGreaterThan URLPathOperator = "GreaterThan" + // URLPathOperatorGreaterThanOrEqual ... + URLPathOperatorGreaterThanOrEqual URLPathOperator = "GreaterThanOrEqual" + // URLPathOperatorLessThan ... + URLPathOperatorLessThan URLPathOperator = "LessThan" + // URLPathOperatorLessThanOrEqual ... + URLPathOperatorLessThanOrEqual URLPathOperator = "LessThanOrEqual" + // URLPathOperatorWildcard ... + URLPathOperatorWildcard URLPathOperator = "Wildcard" +) + +// PossibleURLPathOperatorValues returns an array of possible values for the URLPathOperator const type. +func PossibleURLPathOperatorValues() []URLPathOperator { + return []URLPathOperator{URLPathOperatorAny, URLPathOperatorBeginsWith, URLPathOperatorContains, URLPathOperatorEndsWith, URLPathOperatorEqual, URLPathOperatorGreaterThan, URLPathOperatorGreaterThanOrEqual, URLPathOperatorLessThan, URLPathOperatorLessThanOrEqual, URLPathOperatorWildcard} +} + +// CacheExpirationActionParameters defines the parameters for the cache expiration action. +type CacheExpirationActionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // CacheBehavior - Caching behavior for the requests. Possible values include: 'BypassCache', 'Override', 'SetIfMissing' + CacheBehavior CacheBehavior `json:"cacheBehavior,omitempty"` + // CacheType - The level at which the content needs to be cached. + CacheType *string `json:"cacheType,omitempty"` + // CacheDuration - The duration for which the content needs to be cached. Allowed format is [d.]hh:mm:ss + CacheDuration *string `json:"cacheDuration,omitempty"` +} + +// CacheKeyQueryStringActionParameters defines the parameters for the cache-key query string action. +type CacheKeyQueryStringActionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // QueryStringBehavior - Caching behavior for the requests. Possible values include: 'Include', 'IncludeAll', 'Exclude', 'ExcludeAll' + QueryStringBehavior QueryStringBehavior `json:"queryStringBehavior,omitempty"` + // QueryParameters - query parameters to include or exclude (comma separated). + QueryParameters *string `json:"queryParameters,omitempty"` +} + +// CertificateSourceParameters defines the parameters for using CDN managed certificate for securing custom +// domain. +type CertificateSourceParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // CertificateType - Type of certificate used. Possible values include: 'Shared', 'Dedicated' + CertificateType CertificateType `json:"certificateType,omitempty"` +} + +// CheckNameAvailabilityInput input of CheckNameAvailability API. +type CheckNameAvailabilityInput struct { + // Name - The resource name to validate. + Name *string `json:"name,omitempty"` + // Type - The type of the resource whose name is to be validated. + Type *string `json:"type,omitempty"` +} + +// CheckNameAvailabilityOutput output of check name availability API. +type CheckNameAvailabilityOutput struct { + autorest.Response `json:"-"` + // NameAvailable - READ-ONLY; Indicates whether the name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - READ-ONLY; The reason why the name is not available. + Reason *string `json:"reason,omitempty"` + // Message - READ-ONLY; The detailed error message describing why the name is not available. + Message *string `json:"message,omitempty"` +} + +// CidrIPAddress CIDR Ip address +type CidrIPAddress struct { + // BaseIPAddress - Ip address itself. + BaseIPAddress *string `json:"baseIpAddress,omitempty"` + // PrefixLength - The length of the prefix of the ip address. + PrefixLength *int32 `json:"prefixLength,omitempty"` +} + +// CookiesMatchConditionParameters defines the parameters for Cookies match conditions +type CookiesMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Selector - Name of Cookies to be matched + Selector *string `json:"selector,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + Operator CookiesOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// CustomDomain friendly domain name mapping to the endpoint hostname that the customer provides for +// branding purposes, e.g. www.contoso.com. +type CustomDomain struct { + autorest.Response `json:"-"` + *CustomDomainProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CustomDomain. +func (cd CustomDomain) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cd.CustomDomainProperties != nil { + objectMap["properties"] = cd.CustomDomainProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CustomDomain struct. +func (cd *CustomDomain) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var customDomainProperties CustomDomainProperties + err = json.Unmarshal(*v, &customDomainProperties) + if err != nil { + return err + } + cd.CustomDomainProperties = &customDomainProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cd.Type = &typeVar + } + } + } + + return nil +} + +// BasicCustomDomainHTTPSParameters the JSON object that contains the properties to secure a custom domain. +type BasicCustomDomainHTTPSParameters interface { + AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) + AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) + AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) +} + +// CustomDomainHTTPSParameters the JSON object that contains the properties to secure a custom domain. +type CustomDomainHTTPSParameters struct { + // ProtocolType - Defines the TLS extension protocol that is used for secure delivery. Possible values include: 'ServerNameIndication', 'IPBased' + ProtocolType ProtocolType `json:"protocolType,omitempty"` + // MinimumTLSVersion - TLS protocol version that will be used for Https. Possible values include: 'None', 'TLS10', 'TLS12' + MinimumTLSVersion MinimumTLSVersion `json:"minimumTlsVersion,omitempty"` + // CertificateSource - Possible values include: 'CertificateSourceCustomDomainHTTPSParameters', 'CertificateSourceCdn', 'CertificateSourceAzureKeyVault' + CertificateSource CertificateSource `json:"certificateSource,omitempty"` +} + +func unmarshalBasicCustomDomainHTTPSParameters(body []byte) (BasicCustomDomainHTTPSParameters, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["certificateSource"] { + case string(CertificateSourceCdn): + var mhp ManagedHTTPSParameters + err := json.Unmarshal(body, &mhp) + return mhp, err + case string(CertificateSourceAzureKeyVault): + var umhp UserManagedHTTPSParameters + err := json.Unmarshal(body, &umhp) + return umhp, err + default: + var cdhp CustomDomainHTTPSParameters + err := json.Unmarshal(body, &cdhp) + return cdhp, err + } +} +func unmarshalBasicCustomDomainHTTPSParametersArray(body []byte) ([]BasicCustomDomainHTTPSParameters, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + cdhpArray := make([]BasicCustomDomainHTTPSParameters, len(rawMessages)) + + for index, rawMessage := range rawMessages { + cdhp, err := unmarshalBasicCustomDomainHTTPSParameters(*rawMessage) + if err != nil { + return nil, err + } + cdhpArray[index] = cdhp + } + return cdhpArray, nil +} + +// MarshalJSON is the custom marshaler for CustomDomainHTTPSParameters. +func (cdhp CustomDomainHTTPSParameters) MarshalJSON() ([]byte, error) { + cdhp.CertificateSource = CertificateSourceCustomDomainHTTPSParameters + objectMap := make(map[string]interface{}) + if cdhp.ProtocolType != "" { + objectMap["protocolType"] = cdhp.ProtocolType + } + if cdhp.MinimumTLSVersion != "" { + objectMap["minimumTlsVersion"] = cdhp.MinimumTLSVersion + } + if cdhp.CertificateSource != "" { + objectMap["certificateSource"] = cdhp.CertificateSource + } + return json.Marshal(objectMap) +} + +// AsManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. +func (cdhp CustomDomainHTTPSParameters) AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) { + return nil, false +} + +// AsUserManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. +func (cdhp CustomDomainHTTPSParameters) AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) { + return nil, false +} + +// AsCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. +func (cdhp CustomDomainHTTPSParameters) AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) { + return &cdhp, true +} + +// AsBasicCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for CustomDomainHTTPSParameters. +func (cdhp CustomDomainHTTPSParameters) AsBasicCustomDomainHTTPSParameters() (BasicCustomDomainHTTPSParameters, bool) { + return &cdhp, true +} + +// CustomDomainListResult result of the request to list custom domains. It contains a list of custom domain +// objects and a URL link to get the next set of results. +type CustomDomainListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of CDN CustomDomains within an endpoint. + Value *[]CustomDomain `json:"value,omitempty"` + // NextLink - URL to get the next set of custom domain objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// CustomDomainListResultIterator provides access to a complete listing of CustomDomain values. +type CustomDomainListResultIterator struct { + i int + page CustomDomainListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CustomDomainListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomDomainListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *CustomDomainListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CustomDomainListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CustomDomainListResultIterator) Response() CustomDomainListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CustomDomainListResultIterator) Value() CustomDomain { + if !iter.page.NotDone() { + return CustomDomain{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CustomDomainListResultIterator type. +func NewCustomDomainListResultIterator(page CustomDomainListResultPage) CustomDomainListResultIterator { + return CustomDomainListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (cdlr CustomDomainListResult) IsEmpty() bool { + return cdlr.Value == nil || len(*cdlr.Value) == 0 +} + +// customDomainListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (cdlr CustomDomainListResult) customDomainListResultPreparer(ctx context.Context) (*http.Request, error) { + if cdlr.NextLink == nil || len(to.String(cdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(cdlr.NextLink))) +} + +// CustomDomainListResultPage contains a page of CustomDomain values. +type CustomDomainListResultPage struct { + fn func(context.Context, CustomDomainListResult) (CustomDomainListResult, error) + cdlr CustomDomainListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CustomDomainListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomDomainListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.cdlr) + if err != nil { + return err + } + page.cdlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CustomDomainListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CustomDomainListResultPage) NotDone() bool { + return !page.cdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CustomDomainListResultPage) Response() CustomDomainListResult { + return page.cdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CustomDomainListResultPage) Values() []CustomDomain { + if page.cdlr.IsEmpty() { + return nil + } + return *page.cdlr.Value +} + +// Creates a new instance of the CustomDomainListResultPage type. +func NewCustomDomainListResultPage(getNextPage func(context.Context, CustomDomainListResult) (CustomDomainListResult, error)) CustomDomainListResultPage { + return CustomDomainListResultPage{fn: getNextPage} +} + +// CustomDomainParameters the customDomain JSON object required for custom domain creation or update. +type CustomDomainParameters struct { + *CustomDomainPropertiesParameters `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for CustomDomainParameters. +func (cdp CustomDomainParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cdp.CustomDomainPropertiesParameters != nil { + objectMap["properties"] = cdp.CustomDomainPropertiesParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CustomDomainParameters struct. +func (cdp *CustomDomainParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var customDomainPropertiesParameters CustomDomainPropertiesParameters + err = json.Unmarshal(*v, &customDomainPropertiesParameters) + if err != nil { + return err + } + cdp.CustomDomainPropertiesParameters = &customDomainPropertiesParameters + } + } + } + + return nil +} + +// CustomDomainProperties the JSON object that contains the properties of the custom domain to create. +type CustomDomainProperties struct { + // HostName - The host name of the custom domain. Must be a domain name. + HostName *string `json:"hostName,omitempty"` + // ResourceState - READ-ONLY; Resource status of the custom domain. Possible values include: 'Creating', 'Active', 'Deleting' + ResourceState CustomDomainResourceState `json:"resourceState,omitempty"` + // CustomHTTPSProvisioningState - READ-ONLY; Provisioning status of Custom Https of the custom domain. Possible values include: 'Enabling', 'Enabled', 'Disabling', 'Disabled', 'Failed' + CustomHTTPSProvisioningState CustomHTTPSProvisioningState `json:"customHttpsProvisioningState,omitempty"` + // CustomHTTPSProvisioningSubstate - READ-ONLY; Provisioning substate shows the progress of custom HTTPS enabling/disabling process step by step. Possible values include: 'SubmittingDomainControlValidationRequest', 'PendingDomainControlValidationREquestApproval', 'DomainControlValidationRequestApproved', 'DomainControlValidationRequestRejected', 'DomainControlValidationRequestTimedOut', 'IssuingCertificate', 'DeployingCertificate', 'CertificateDeployed', 'DeletingCertificate', 'CertificateDeleted' + CustomHTTPSProvisioningSubstate CustomHTTPSProvisioningSubstate `json:"customHttpsProvisioningSubstate,omitempty"` + // CustomHTTPSParameters - Certificate parameters for securing custom HTTPS + CustomHTTPSParameters BasicCustomDomainHTTPSParameters `json:"customHttpsParameters,omitempty"` + // ValidationData - Special validation or data may be required when delivering CDN to some regions due to local compliance reasons. E.g. ICP license number of a custom domain is required to deliver content in China. + ValidationData *string `json:"validationData,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning status of the custom domain. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for CustomDomainProperties struct. +func (cdp *CustomDomainProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "hostName": + if v != nil { + var hostName string + err = json.Unmarshal(*v, &hostName) + if err != nil { + return err + } + cdp.HostName = &hostName + } + case "resourceState": + if v != nil { + var resourceState CustomDomainResourceState + err = json.Unmarshal(*v, &resourceState) + if err != nil { + return err + } + cdp.ResourceState = resourceState + } + case "customHttpsProvisioningState": + if v != nil { + var customHTTPSProvisioningState CustomHTTPSProvisioningState + err = json.Unmarshal(*v, &customHTTPSProvisioningState) + if err != nil { + return err + } + cdp.CustomHTTPSProvisioningState = customHTTPSProvisioningState + } + case "customHttpsProvisioningSubstate": + if v != nil { + var customHTTPSProvisioningSubstate CustomHTTPSProvisioningSubstate + err = json.Unmarshal(*v, &customHTTPSProvisioningSubstate) + if err != nil { + return err + } + cdp.CustomHTTPSProvisioningSubstate = customHTTPSProvisioningSubstate + } + case "customHttpsParameters": + if v != nil { + customHTTPSParameters, err := unmarshalBasicCustomDomainHTTPSParameters(*v) + if err != nil { + return err + } + cdp.CustomHTTPSParameters = customHTTPSParameters + } + case "validationData": + if v != nil { + var validationData string + err = json.Unmarshal(*v, &validationData) + if err != nil { + return err + } + cdp.ValidationData = &validationData + } + case "provisioningState": + if v != nil { + var provisioningState string + err = json.Unmarshal(*v, &provisioningState) + if err != nil { + return err + } + cdp.ProvisioningState = &provisioningState + } + } + } + + return nil +} + +// CustomDomainPropertiesParameters the JSON object that contains the properties of the custom domain to +// create. +type CustomDomainPropertiesParameters struct { + // HostName - The host name of the custom domain. Must be a domain name. + HostName *string `json:"hostName,omitempty"` +} + +// CustomDomainsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CustomDomainsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CustomDomainsCreateFuture) Result(client CustomDomainsClient) (cd CustomDomain, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.CustomDomainsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if cd.Response.Response, err = future.GetResult(sender); err == nil && cd.Response.Response.StatusCode != http.StatusNoContent { + cd, err = client.CreateResponder(cd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsCreateFuture", "Result", cd.Response.Response, "Failure responding to request") + } + } + return +} + +// CustomDomainsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CustomDomainsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *CustomDomainsDeleteFuture) Result(client CustomDomainsClient) (cd CustomDomain, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.CustomDomainsDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if cd.Response.Response, err = future.GetResult(sender); err == nil && cd.Response.Response.StatusCode != http.StatusNoContent { + cd, err = client.DeleteResponder(cd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.CustomDomainsDeleteFuture", "Result", cd.Response.Response, "Failure responding to request") + } + } + return +} + +// DeepCreatedOrigin the main origin of CDN content which is added when creating a CDN endpoint. +type DeepCreatedOrigin struct { + // Name - Origin name + Name *string `json:"name,omitempty"` + *DeepCreatedOriginProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeepCreatedOrigin. +func (dco DeepCreatedOrigin) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dco.Name != nil { + objectMap["name"] = dco.Name + } + if dco.DeepCreatedOriginProperties != nil { + objectMap["properties"] = dco.DeepCreatedOriginProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DeepCreatedOrigin struct. +func (dco *DeepCreatedOrigin) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dco.Name = &name + } + case "properties": + if v != nil { + var deepCreatedOriginProperties DeepCreatedOriginProperties + err = json.Unmarshal(*v, &deepCreatedOriginProperties) + if err != nil { + return err + } + dco.DeepCreatedOriginProperties = &deepCreatedOriginProperties + } + } + } + + return nil +} + +// DeepCreatedOriginProperties properties of the origin created on the CDN endpoint. +type DeepCreatedOriginProperties struct { + // HostName - The address of the origin. It can be a domain name, IPv4 address, or IPv6 address. + HostName *string `json:"hostName,omitempty"` + // HTTPPort - The value of the HTTP port. Must be between 1 and 65535 + HTTPPort *int32 `json:"httpPort,omitempty"` + // HTTPSPort - The value of the HTTPS port. Must be between 1 and 65535 + HTTPSPort *int32 `json:"httpsPort,omitempty"` +} + +// DeliveryRule a rule that specifies a set of actions and conditions +type DeliveryRule struct { + // Name - Name of the rule + Name *string `json:"name,omitempty"` + // Order - The order in which the rules are applied for the endpoint. Possible values {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. Rule with order 0 is a special rule. It does not require any condition and actions listed in it will always be applied. + Order *int32 `json:"order,omitempty"` + // Conditions - A list of conditions that must be matched for the actions to be executed + Conditions *[]BasicDeliveryRuleCondition `json:"conditions,omitempty"` + // Actions - A list of actions that are executed when all the conditions of a rule are satisfied. + Actions *[]BasicDeliveryRuleAction `json:"actions,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for DeliveryRule struct. +func (dr *DeliveryRule) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dr.Name = &name + } + case "order": + if v != nil { + var order int32 + err = json.Unmarshal(*v, &order) + if err != nil { + return err + } + dr.Order = &order + } + case "conditions": + if v != nil { + conditions, err := unmarshalBasicDeliveryRuleConditionArray(*v) + if err != nil { + return err + } + dr.Conditions = &conditions + } + case "actions": + if v != nil { + actions, err := unmarshalBasicDeliveryRuleActionArray(*v) + if err != nil { + return err + } + dr.Actions = &actions + } + } + } + + return nil +} + +// BasicDeliveryRuleAction an action for the delivery rule. +type BasicDeliveryRuleAction interface { + AsURLRedirectAction() (*URLRedirectAction, bool) + AsURLRewriteAction() (*URLRewriteAction, bool) + AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) + AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) + AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) + AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) + AsDeliveryRuleAction() (*DeliveryRuleAction, bool) +} + +// DeliveryRuleAction an action for the delivery rule. +type DeliveryRuleAction struct { + // Name - Possible values include: 'NameDeliveryRuleAction', 'NameURLRedirect', 'NameURLRewrite', 'NameModifyRequestHeader', 'NameModifyResponseHeader', 'NameCacheExpiration', 'NameCacheKeyQueryString' + Name NameBasicDeliveryRuleAction `json:"name,omitempty"` +} + +func unmarshalBasicDeliveryRuleAction(body []byte) (BasicDeliveryRuleAction, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["name"] { + case string(NameURLRedirect): + var ura URLRedirectAction + err := json.Unmarshal(body, &ura) + return ura, err + case string(NameURLRewrite): + var ura URLRewriteAction + err := json.Unmarshal(body, &ura) + return ura, err + case string(NameModifyRequestHeader): + var drrha DeliveryRuleRequestHeaderAction + err := json.Unmarshal(body, &drrha) + return drrha, err + case string(NameModifyResponseHeader): + var drrha DeliveryRuleResponseHeaderAction + err := json.Unmarshal(body, &drrha) + return drrha, err + case string(NameCacheExpiration): + var drcea DeliveryRuleCacheExpirationAction + err := json.Unmarshal(body, &drcea) + return drcea, err + case string(NameCacheKeyQueryString): + var drckqsa DeliveryRuleCacheKeyQueryStringAction + err := json.Unmarshal(body, &drckqsa) + return drckqsa, err + default: + var dra DeliveryRuleAction + err := json.Unmarshal(body, &dra) + return dra, err + } +} +func unmarshalBasicDeliveryRuleActionArray(body []byte) ([]BasicDeliveryRuleAction, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + draArray := make([]BasicDeliveryRuleAction, len(rawMessages)) + + for index, rawMessage := range rawMessages { + dra, err := unmarshalBasicDeliveryRuleAction(*rawMessage) + if err != nil { + return nil, err + } + draArray[index] = dra + } + return draArray, nil +} + +// MarshalJSON is the custom marshaler for DeliveryRuleAction. +func (dra DeliveryRuleAction) MarshalJSON() ([]byte, error) { + dra.Name = NameDeliveryRuleAction + objectMap := make(map[string]interface{}) + if dra.Name != "" { + objectMap["name"] = dra.Name + } + return json.Marshal(objectMap) +} + +// AsURLRedirectAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsURLRedirectAction() (*URLRedirectAction, bool) { + return nil, false +} + +// AsURLRewriteAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsURLRewriteAction() (*URLRewriteAction, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleResponseHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheKeyQueryStringAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) { + return nil, false +} + +// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { + return &dra, true +} + +// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleAction. +func (dra DeliveryRuleAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { + return &dra, true +} + +// DeliveryRuleCacheExpirationAction defines the cache expiration action for the delivery rule. +type DeliveryRuleCacheExpirationAction struct { + // Parameters - Defines the parameters for the action. + Parameters *CacheExpirationActionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleAction', 'NameURLRedirect', 'NameURLRewrite', 'NameModifyRequestHeader', 'NameModifyResponseHeader', 'NameCacheExpiration', 'NameCacheKeyQueryString' + Name NameBasicDeliveryRuleAction `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) MarshalJSON() ([]byte, error) { + drcea.Name = NameCacheExpiration + objectMap := make(map[string]interface{}) + if drcea.Parameters != nil { + objectMap["parameters"] = drcea.Parameters + } + if drcea.Name != "" { + objectMap["name"] = drcea.Name + } + return json.Marshal(objectMap) +} + +// AsURLRedirectAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsURLRedirectAction() (*URLRedirectAction, bool) { + return nil, false +} + +// AsURLRewriteAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsURLRewriteAction() (*URLRewriteAction, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleResponseHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { + return &drcea, true +} + +// AsDeliveryRuleCacheKeyQueryStringAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) { + return nil, false +} + +// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { + return nil, false +} + +// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheExpirationAction. +func (drcea DeliveryRuleCacheExpirationAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { + return &drcea, true +} + +// DeliveryRuleCacheKeyQueryStringAction defines the cache-key query string action for the delivery rule. +type DeliveryRuleCacheKeyQueryStringAction struct { + // Parameters - Defines the parameters for the action. + Parameters *CacheKeyQueryStringActionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleAction', 'NameURLRedirect', 'NameURLRewrite', 'NameModifyRequestHeader', 'NameModifyResponseHeader', 'NameCacheExpiration', 'NameCacheKeyQueryString' + Name NameBasicDeliveryRuleAction `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) MarshalJSON() ([]byte, error) { + drckqsa.Name = NameCacheKeyQueryString + objectMap := make(map[string]interface{}) + if drckqsa.Parameters != nil { + objectMap["parameters"] = drckqsa.Parameters + } + if drckqsa.Name != "" { + objectMap["name"] = drckqsa.Name + } + return json.Marshal(objectMap) +} + +// AsURLRedirectAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsURLRedirectAction() (*URLRedirectAction, bool) { + return nil, false +} + +// AsURLRewriteAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsURLRewriteAction() (*URLRewriteAction, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleResponseHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheKeyQueryStringAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) { + return &drckqsa, true +} + +// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { + return nil, false +} + +// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleCacheKeyQueryStringAction. +func (drckqsa DeliveryRuleCacheKeyQueryStringAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { + return &drckqsa, true +} + +// BasicDeliveryRuleCondition a condition for the delivery rule. +type BasicDeliveryRuleCondition interface { + AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) + AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) + AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) + AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) + AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) + AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) + AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) + AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) + AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) + AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) + AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) + AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) + AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) + AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) + AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) +} + +// DeliveryRuleCondition a condition for the delivery rule. +type DeliveryRuleCondition struct { + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +func unmarshalBasicDeliveryRuleCondition(body []byte) (BasicDeliveryRuleCondition, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["name"] { + case string(NameRemoteAddress): + var drrac DeliveryRuleRemoteAddressCondition + err := json.Unmarshal(body, &drrac) + return drrac, err + case string(NameRequestMethod): + var drrmc DeliveryRuleRequestMethodCondition + err := json.Unmarshal(body, &drrmc) + return drrmc, err + case string(NameQueryString): + var drqsc DeliveryRuleQueryStringCondition + err := json.Unmarshal(body, &drqsc) + return drqsc, err + case string(NamePostArgs): + var drpac DeliveryRulePostArgsCondition + err := json.Unmarshal(body, &drpac) + return drpac, err + case string(NameRequestURI): + var drruc DeliveryRuleRequestURICondition + err := json.Unmarshal(body, &drruc) + return drruc, err + case string(NameRequestHeader): + var drrhc DeliveryRuleRequestHeaderCondition + err := json.Unmarshal(body, &drrhc) + return drrhc, err + case string(NameRequestBody): + var drrbc DeliveryRuleRequestBodyCondition + err := json.Unmarshal(body, &drrbc) + return drrbc, err + case string(NameRequestScheme): + var drrsc DeliveryRuleRequestSchemeCondition + err := json.Unmarshal(body, &drrsc) + return drrsc, err + case string(NameURLPath): + var drupc DeliveryRuleURLPathCondition + err := json.Unmarshal(body, &drupc) + return drupc, err + case string(NameURLFileExtension): + var drufec DeliveryRuleURLFileExtensionCondition + err := json.Unmarshal(body, &drufec) + return drufec, err + case string(NameURLFileName): + var drufnc DeliveryRuleURLFileNameCondition + err := json.Unmarshal(body, &drufnc) + return drufnc, err + case string(NameHTTPVersion): + var drhvc DeliveryRuleHTTPVersionCondition + err := json.Unmarshal(body, &drhvc) + return drhvc, err + case string(NameCookies): + var drcc DeliveryRuleCookiesCondition + err := json.Unmarshal(body, &drcc) + return drcc, err + case string(NameIsDevice): + var dridc DeliveryRuleIsDeviceCondition + err := json.Unmarshal(body, &dridc) + return dridc, err + default: + var drc DeliveryRuleCondition + err := json.Unmarshal(body, &drc) + return drc, err + } +} +func unmarshalBasicDeliveryRuleConditionArray(body []byte) ([]BasicDeliveryRuleCondition, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + drcArray := make([]BasicDeliveryRuleCondition, len(rawMessages)) + + for index, rawMessage := range rawMessages { + drc, err := unmarshalBasicDeliveryRuleCondition(*rawMessage) + if err != nil { + return nil, err + } + drcArray[index] = drc + } + return drcArray, nil +} + +// MarshalJSON is the custom marshaler for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) MarshalJSON() ([]byte, error) { + drc.Name = NameDeliveryRuleCondition + objectMap := make(map[string]interface{}) + if drc.Name != "" { + objectMap["name"] = drc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return &drc, true +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCondition. +func (drc DeliveryRuleCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drc, true +} + +// DeliveryRuleCookiesCondition defines the Cookies condition for the delivery rule. +type DeliveryRuleCookiesCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *CookiesMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) MarshalJSON() ([]byte, error) { + drcc.Name = NameCookies + objectMap := make(map[string]interface{}) + if drcc.Parameters != nil { + objectMap["parameters"] = drcc.Parameters + } + if drcc.Name != "" { + objectMap["name"] = drcc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return &drcc, true +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleCookiesCondition. +func (drcc DeliveryRuleCookiesCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drcc, true +} + +// DeliveryRuleHTTPVersionCondition defines the HttpVersion condition for the delivery rule. +type DeliveryRuleHTTPVersionCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *HTTPVersionMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) MarshalJSON() ([]byte, error) { + drhvc.Name = NameHTTPVersion + objectMap := make(map[string]interface{}) + if drhvc.Parameters != nil { + objectMap["parameters"] = drhvc.Parameters + } + if drhvc.Name != "" { + objectMap["name"] = drhvc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return &drhvc, true +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleHTTPVersionCondition. +func (drhvc DeliveryRuleHTTPVersionCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drhvc, true +} + +// DeliveryRuleIsDeviceCondition defines the IsDevice condition for the delivery rule. +type DeliveryRuleIsDeviceCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *IsDeviceMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) MarshalJSON() ([]byte, error) { + dridc.Name = NameIsDevice + objectMap := make(map[string]interface{}) + if dridc.Parameters != nil { + objectMap["parameters"] = dridc.Parameters + } + if dridc.Name != "" { + objectMap["name"] = dridc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return &dridc, true +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleIsDeviceCondition. +func (dridc DeliveryRuleIsDeviceCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &dridc, true +} + +// DeliveryRulePostArgsCondition defines the PostArgs condition for the delivery rule. +type DeliveryRulePostArgsCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *PostArgsMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) MarshalJSON() ([]byte, error) { + drpac.Name = NamePostArgs + objectMap := make(map[string]interface{}) + if drpac.Parameters != nil { + objectMap["parameters"] = drpac.Parameters + } + if drpac.Name != "" { + objectMap["name"] = drpac.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return &drpac, true +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRulePostArgsCondition. +func (drpac DeliveryRulePostArgsCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drpac, true +} + +// DeliveryRuleQueryStringCondition defines the QueryString condition for the delivery rule. +type DeliveryRuleQueryStringCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *QueryStringMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) MarshalJSON() ([]byte, error) { + drqsc.Name = NameQueryString + objectMap := make(map[string]interface{}) + if drqsc.Parameters != nil { + objectMap["parameters"] = drqsc.Parameters + } + if drqsc.Name != "" { + objectMap["name"] = drqsc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return &drqsc, true +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleQueryStringCondition. +func (drqsc DeliveryRuleQueryStringCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drqsc, true +} + +// DeliveryRuleRemoteAddressCondition defines the RemoteAddress condition for the delivery rule. +type DeliveryRuleRemoteAddressCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *RemoteAddressMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) MarshalJSON() ([]byte, error) { + drrac.Name = NameRemoteAddress + objectMap := make(map[string]interface{}) + if drrac.Parameters != nil { + objectMap["parameters"] = drrac.Parameters + } + if drrac.Name != "" { + objectMap["name"] = drrac.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return &drrac, true +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRemoteAddressCondition. +func (drrac DeliveryRuleRemoteAddressCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drrac, true +} + +// DeliveryRuleRequestBodyCondition defines the RequestBody condition for the delivery rule. +type DeliveryRuleRequestBodyCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *RequestBodyMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) MarshalJSON() ([]byte, error) { + drrbc.Name = NameRequestBody + objectMap := make(map[string]interface{}) + if drrbc.Parameters != nil { + objectMap["parameters"] = drrbc.Parameters + } + if drrbc.Name != "" { + objectMap["name"] = drrbc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return &drrbc, true +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestBodyCondition. +func (drrbc DeliveryRuleRequestBodyCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drrbc, true +} + +// DeliveryRuleRequestHeaderAction defines the request header action for the delivery rule. +type DeliveryRuleRequestHeaderAction struct { + // Parameters - Defines the parameters for the action. + Parameters *HeaderActionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleAction', 'NameURLRedirect', 'NameURLRewrite', 'NameModifyRequestHeader', 'NameModifyResponseHeader', 'NameCacheExpiration', 'NameCacheKeyQueryString' + Name NameBasicDeliveryRuleAction `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) MarshalJSON() ([]byte, error) { + drrha.Name = NameModifyRequestHeader + objectMap := make(map[string]interface{}) + if drrha.Parameters != nil { + objectMap["parameters"] = drrha.Parameters + } + if drrha.Name != "" { + objectMap["name"] = drrha.Name + } + return json.Marshal(objectMap) +} + +// AsURLRedirectAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsURLRedirectAction() (*URLRedirectAction, bool) { + return nil, false +} + +// AsURLRewriteAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsURLRewriteAction() (*URLRewriteAction, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) { + return &drrha, true +} + +// AsDeliveryRuleResponseHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheKeyQueryStringAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) { + return nil, false +} + +// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { + return nil, false +} + +// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleRequestHeaderAction. +func (drrha DeliveryRuleRequestHeaderAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { + return &drrha, true +} + +// DeliveryRuleRequestHeaderCondition defines the RequestHeader condition for the delivery rule. +type DeliveryRuleRequestHeaderCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *RequestHeaderMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) MarshalJSON() ([]byte, error) { + drrhc.Name = NameRequestHeader + objectMap := make(map[string]interface{}) + if drrhc.Parameters != nil { + objectMap["parameters"] = drrhc.Parameters + } + if drrhc.Name != "" { + objectMap["name"] = drrhc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return &drrhc, true +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestHeaderCondition. +func (drrhc DeliveryRuleRequestHeaderCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drrhc, true +} + +// DeliveryRuleRequestMethodCondition defines the RequestMethod condition for the delivery rule. +type DeliveryRuleRequestMethodCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *RequestMethodMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) MarshalJSON() ([]byte, error) { + drrmc.Name = NameRequestMethod + objectMap := make(map[string]interface{}) + if drrmc.Parameters != nil { + objectMap["parameters"] = drrmc.Parameters + } + if drrmc.Name != "" { + objectMap["name"] = drrmc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return &drrmc, true +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestMethodCondition. +func (drrmc DeliveryRuleRequestMethodCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drrmc, true +} + +// DeliveryRuleRequestSchemeCondition defines the RequestScheme condition for the delivery rule. +type DeliveryRuleRequestSchemeCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *RequestSchemeMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) MarshalJSON() ([]byte, error) { + drrsc.Name = NameRequestScheme + objectMap := make(map[string]interface{}) + if drrsc.Parameters != nil { + objectMap["parameters"] = drrsc.Parameters + } + if drrsc.Name != "" { + objectMap["name"] = drrsc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return &drrsc, true +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestSchemeCondition. +func (drrsc DeliveryRuleRequestSchemeCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drrsc, true +} + +// DeliveryRuleRequestURICondition defines the RequestUri condition for the delivery rule. +type DeliveryRuleRequestURICondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *RequestURIMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) MarshalJSON() ([]byte, error) { + drruc.Name = NameRequestURI + objectMap := make(map[string]interface{}) + if drruc.Parameters != nil { + objectMap["parameters"] = drruc.Parameters + } + if drruc.Name != "" { + objectMap["name"] = drruc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return &drruc, true +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleRequestURICondition. +func (drruc DeliveryRuleRequestURICondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drruc, true +} + +// DeliveryRuleResponseHeaderAction defines the response header action for the delivery rule. +type DeliveryRuleResponseHeaderAction struct { + // Parameters - Defines the parameters for the action. + Parameters *HeaderActionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleAction', 'NameURLRedirect', 'NameURLRewrite', 'NameModifyRequestHeader', 'NameModifyResponseHeader', 'NameCacheExpiration', 'NameCacheKeyQueryString' + Name NameBasicDeliveryRuleAction `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) MarshalJSON() ([]byte, error) { + drrha.Name = NameModifyResponseHeader + objectMap := make(map[string]interface{}) + if drrha.Parameters != nil { + objectMap["parameters"] = drrha.Parameters + } + if drrha.Name != "" { + objectMap["name"] = drrha.Name + } + return json.Marshal(objectMap) +} + +// AsURLRedirectAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsURLRedirectAction() (*URLRedirectAction, bool) { + return nil, false +} + +// AsURLRewriteAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsURLRewriteAction() (*URLRewriteAction, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleResponseHeaderAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) { + return &drrha, true +} + +// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheKeyQueryStringAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) { + return nil, false +} + +// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { + return nil, false +} + +// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for DeliveryRuleResponseHeaderAction. +func (drrha DeliveryRuleResponseHeaderAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { + return &drrha, true +} + +// DeliveryRuleURLFileExtensionCondition defines the UrlFileExtension condition for the delivery rule. +type DeliveryRuleURLFileExtensionCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *URLFileExtensionMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) MarshalJSON() ([]byte, error) { + drufec.Name = NameURLFileExtension + objectMap := make(map[string]interface{}) + if drufec.Parameters != nil { + objectMap["parameters"] = drufec.Parameters + } + if drufec.Name != "" { + objectMap["name"] = drufec.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return &drufec, true +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileExtensionCondition. +func (drufec DeliveryRuleURLFileExtensionCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drufec, true +} + +// DeliveryRuleURLFileNameCondition defines the UrlFileName condition for the delivery rule. +type DeliveryRuleURLFileNameCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *URLFileNameMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) MarshalJSON() ([]byte, error) { + drufnc.Name = NameURLFileName + objectMap := make(map[string]interface{}) + if drufnc.Parameters != nil { + objectMap["parameters"] = drufnc.Parameters + } + if drufnc.Name != "" { + objectMap["name"] = drufnc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return &drufnc, true +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLFileNameCondition. +func (drufnc DeliveryRuleURLFileNameCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drufnc, true +} + +// DeliveryRuleURLPathCondition defines the UrlPath condition for the delivery rule. +type DeliveryRuleURLPathCondition struct { + // Parameters - Defines the parameters for the condition. + Parameters *URLPathMatchConditionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleCondition', 'NameRemoteAddress', 'NameRequestMethod', 'NameQueryString', 'NamePostArgs', 'NameRequestURI', 'NameRequestHeader', 'NameRequestBody', 'NameRequestScheme', 'NameURLPath', 'NameURLFileExtension', 'NameURLFileName', 'NameHTTPVersion', 'NameCookies', 'NameIsDevice' + Name Name `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) MarshalJSON() ([]byte, error) { + drupc.Name = NameURLPath + objectMap := make(map[string]interface{}) + if drupc.Parameters != nil { + objectMap["parameters"] = drupc.Parameters + } + if drupc.Name != "" { + objectMap["name"] = drupc.Name + } + return json.Marshal(objectMap) +} + +// AsDeliveryRuleRemoteAddressCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleRemoteAddressCondition() (*DeliveryRuleRemoteAddressCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestMethodCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleRequestMethodCondition() (*DeliveryRuleRequestMethodCondition, bool) { + return nil, false +} + +// AsDeliveryRuleQueryStringCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleQueryStringCondition() (*DeliveryRuleQueryStringCondition, bool) { + return nil, false +} + +// AsDeliveryRulePostArgsCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRulePostArgsCondition() (*DeliveryRulePostArgsCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestURICondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleRequestURICondition() (*DeliveryRuleRequestURICondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleRequestHeaderCondition() (*DeliveryRuleRequestHeaderCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestBodyCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleRequestBodyCondition() (*DeliveryRuleRequestBodyCondition, bool) { + return nil, false +} + +// AsDeliveryRuleRequestSchemeCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleRequestSchemeCondition() (*DeliveryRuleRequestSchemeCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLPathCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleURLPathCondition() (*DeliveryRuleURLPathCondition, bool) { + return &drupc, true +} + +// AsDeliveryRuleURLFileExtensionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleURLFileExtensionCondition() (*DeliveryRuleURLFileExtensionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleURLFileNameCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleURLFileNameCondition() (*DeliveryRuleURLFileNameCondition, bool) { + return nil, false +} + +// AsDeliveryRuleHTTPVersionCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleHTTPVersionCondition() (*DeliveryRuleHTTPVersionCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCookiesCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleCookiesCondition() (*DeliveryRuleCookiesCondition, bool) { + return nil, false +} + +// AsDeliveryRuleIsDeviceCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleIsDeviceCondition() (*DeliveryRuleIsDeviceCondition, bool) { + return nil, false +} + +// AsDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsDeliveryRuleCondition() (*DeliveryRuleCondition, bool) { + return nil, false +} + +// AsBasicDeliveryRuleCondition is the BasicDeliveryRuleCondition implementation for DeliveryRuleURLPathCondition. +func (drupc DeliveryRuleURLPathCondition) AsBasicDeliveryRuleCondition() (BasicDeliveryRuleCondition, bool) { + return &drupc, true +} + +// EdgeNode edgenode is a global Point of Presence (POP) location used to deliver CDN content to end users. +type EdgeNode struct { + *EdgeNodeProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EdgeNode. +func (en EdgeNode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if en.EdgeNodeProperties != nil { + objectMap["properties"] = en.EdgeNodeProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EdgeNode struct. +func (en *EdgeNode) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var edgeNodeProperties EdgeNodeProperties + err = json.Unmarshal(*v, &edgeNodeProperties) + if err != nil { + return err + } + en.EdgeNodeProperties = &edgeNodeProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + en.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + en.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + en.Type = &typeVar + } + } + } + + return nil +} + +// EdgeNodeProperties the JSON object that contains the properties required to create an edgenode. +type EdgeNodeProperties struct { + // IPAddressGroups - List of ip address groups. + IPAddressGroups *[]IPAddressGroup `json:"ipAddressGroups,omitempty"` +} + +// EdgenodeResult result of the request to list CDN edgenodes. It contains a list of ip address group and a +// URL link to get the next set of results. +type EdgenodeResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Edge node of CDN service. + Value *[]EdgeNode `json:"value,omitempty"` + // NextLink - URL to get the next set of edgenode list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// EdgenodeResultIterator provides access to a complete listing of EdgeNode values. +type EdgenodeResultIterator struct { + i int + page EdgenodeResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EdgenodeResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EdgenodeResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EdgenodeResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EdgenodeResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EdgenodeResultIterator) Response() EdgenodeResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EdgenodeResultIterator) Value() EdgeNode { + if !iter.page.NotDone() { + return EdgeNode{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EdgenodeResultIterator type. +func NewEdgenodeResultIterator(page EdgenodeResultPage) EdgenodeResultIterator { + return EdgenodeResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (er EdgenodeResult) IsEmpty() bool { + return er.Value == nil || len(*er.Value) == 0 +} + +// edgenodeResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (er EdgenodeResult) edgenodeResultPreparer(ctx context.Context) (*http.Request, error) { + if er.NextLink == nil || len(to.String(er.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(er.NextLink))) +} + +// EdgenodeResultPage contains a page of EdgeNode values. +type EdgenodeResultPage struct { + fn func(context.Context, EdgenodeResult) (EdgenodeResult, error) + er EdgenodeResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EdgenodeResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EdgenodeResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.er) + if err != nil { + return err + } + page.er = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EdgenodeResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EdgenodeResultPage) NotDone() bool { + return !page.er.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EdgenodeResultPage) Response() EdgenodeResult { + return page.er +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EdgenodeResultPage) Values() []EdgeNode { + if page.er.IsEmpty() { + return nil + } + return *page.er.Value +} + +// Creates a new instance of the EdgenodeResultPage type. +func NewEdgenodeResultPage(getNextPage func(context.Context, EdgenodeResult) (EdgenodeResult, error)) EdgenodeResultPage { + return EdgenodeResultPage{fn: getNextPage} +} + +// Endpoint CDN endpoint is the entity within a CDN profile containing configuration information such as +// origin, protocol, content caching and delivery behavior. The CDN endpoint uses the URL format +// .azureedge.net. +type Endpoint struct { + autorest.Response `json:"-"` + *EndpointProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Endpoint. +func (e Endpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if e.EndpointProperties != nil { + objectMap["properties"] = e.EndpointProperties + } + if e.Location != nil { + objectMap["location"] = e.Location + } + if e.Tags != nil { + objectMap["tags"] = e.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Endpoint struct. +func (e *Endpoint) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var endpointProperties EndpointProperties + err = json.Unmarshal(*v, &endpointProperties) + if err != nil { + return err + } + e.EndpointProperties = &endpointProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + e.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + e.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + e.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + e.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + e.Type = &typeVar + } + } + } + + return nil +} + +// EndpointListResult result of the request to list endpoints. It contains a list of endpoint objects and a +// URL link to get the next set of results. +type EndpointListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of CDN endpoints within a profile + Value *[]Endpoint `json:"value,omitempty"` + // NextLink - URL to get the next set of endpoint objects if there is any. + NextLink *string `json:"nextLink,omitempty"` +} + +// EndpointListResultIterator provides access to a complete listing of Endpoint values. +type EndpointListResultIterator struct { + i int + page EndpointListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EndpointListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EndpointListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EndpointListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EndpointListResultIterator) Response() EndpointListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EndpointListResultIterator) Value() Endpoint { + if !iter.page.NotDone() { + return Endpoint{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EndpointListResultIterator type. +func NewEndpointListResultIterator(page EndpointListResultPage) EndpointListResultIterator { + return EndpointListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (elr EndpointListResult) IsEmpty() bool { + return elr.Value == nil || len(*elr.Value) == 0 +} + +// endpointListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (elr EndpointListResult) endpointListResultPreparer(ctx context.Context) (*http.Request, error) { + if elr.NextLink == nil || len(to.String(elr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(elr.NextLink))) +} + +// EndpointListResultPage contains a page of Endpoint values. +type EndpointListResultPage struct { + fn func(context.Context, EndpointListResult) (EndpointListResult, error) + elr EndpointListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EndpointListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.elr) + if err != nil { + return err + } + page.elr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EndpointListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EndpointListResultPage) NotDone() bool { + return !page.elr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EndpointListResultPage) Response() EndpointListResult { + return page.elr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EndpointListResultPage) Values() []Endpoint { + if page.elr.IsEmpty() { + return nil + } + return *page.elr.Value +} + +// Creates a new instance of the EndpointListResultPage type. +func NewEndpointListResultPage(getNextPage func(context.Context, EndpointListResult) (EndpointListResult, error)) EndpointListResultPage { + return EndpointListResultPage{fn: getNextPage} +} + +// EndpointProperties the JSON object that contains the properties required to create an endpoint. +type EndpointProperties struct { + // HostName - READ-ONLY; The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. contoso.azureedge.net + HostName *string `json:"hostName,omitempty"` + // Origins - The source of the content being delivered via CDN. + Origins *[]DeepCreatedOrigin `json:"origins,omitempty"` + // ResourceState - READ-ONLY; Resource status of the endpoint. Possible values include: 'EndpointResourceStateCreating', 'EndpointResourceStateDeleting', 'EndpointResourceStateRunning', 'EndpointResourceStateStarting', 'EndpointResourceStateStopped', 'EndpointResourceStateStopping' + ResourceState EndpointResourceState `json:"resourceState,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning status of the endpoint. + ProvisioningState *string `json:"provisioningState,omitempty"` + // OriginHostHeader - The host header value sent to the origin with each request. If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default. + OriginHostHeader *string `json:"originHostHeader,omitempty"` + // OriginPath - A directory path on the origin that CDN can use to retrieve content from, e.g. contoso.cloudapp.net/originpath. + OriginPath *string `json:"originPath,omitempty"` + // ContentTypesToCompress - List of content types on which compression applies. The value should be a valid MIME type. + ContentTypesToCompress *[]string `json:"contentTypesToCompress,omitempty"` + // IsCompressionEnabled - Indicates whether content compression is enabled on CDN. Default value is false. If compression is enabled, content will be served as compressed if user requests for a compressed version. Content won't be compressed on CDN when requested content is smaller than 1 byte or larger than 1 MB. + IsCompressionEnabled *bool `json:"isCompressionEnabled,omitempty"` + // IsHTTPAllowed - Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. + IsHTTPAllowed *bool `json:"isHttpAllowed,omitempty"` + // IsHTTPSAllowed - Indicates whether HTTPS traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. + IsHTTPSAllowed *bool `json:"isHttpsAllowed,omitempty"` + // QueryStringCachingBehavior - Defines how CDN caches requests that include query strings. You can ignore any query strings when caching, bypass caching to prevent requests that contain query strings from being cached, or cache every request with a unique URL. Possible values include: 'IgnoreQueryString', 'BypassCaching', 'UseQueryString', 'NotSet' + QueryStringCachingBehavior QueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` + // OptimizationType - Specifies what scenario the customer wants this CDN endpoint to optimize for, e.g. Download, Media services. With this information, CDN can apply scenario driven optimization. Possible values include: 'GeneralWebDelivery', 'GeneralMediaStreaming', 'VideoOnDemandMediaStreaming', 'LargeFileDownload', 'DynamicSiteAcceleration' + OptimizationType OptimizationType `json:"optimizationType,omitempty"` + // ProbePath - Path to a file hosted on the origin which helps accelerate delivery of the dynamic content and calculate the most optimal routes for the CDN. This is relative to the origin path. + ProbePath *string `json:"probePath,omitempty"` + // GeoFilters - List of rules defining the user's geo access within a CDN endpoint. Each geo filter defines an access rule to a specified path or content, e.g. block APAC for path /pictures/ + GeoFilters *[]GeoFilter `json:"geoFilters,omitempty"` + // DeliveryPolicy - A policy that specifies the delivery rules to be used for an endpoint. + DeliveryPolicy *EndpointPropertiesUpdateParametersDeliveryPolicy `json:"deliveryPolicy,omitempty"` +} + +// EndpointPropertiesUpdateParameters the JSON object containing endpoint update parameters. +type EndpointPropertiesUpdateParameters struct { + // OriginHostHeader - The host header value sent to the origin with each request. If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default. + OriginHostHeader *string `json:"originHostHeader,omitempty"` + // OriginPath - A directory path on the origin that CDN can use to retrieve content from, e.g. contoso.cloudapp.net/originpath. + OriginPath *string `json:"originPath,omitempty"` + // ContentTypesToCompress - List of content types on which compression applies. The value should be a valid MIME type. + ContentTypesToCompress *[]string `json:"contentTypesToCompress,omitempty"` + // IsCompressionEnabled - Indicates whether content compression is enabled on CDN. Default value is false. If compression is enabled, content will be served as compressed if user requests for a compressed version. Content won't be compressed on CDN when requested content is smaller than 1 byte or larger than 1 MB. + IsCompressionEnabled *bool `json:"isCompressionEnabled,omitempty"` + // IsHTTPAllowed - Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. + IsHTTPAllowed *bool `json:"isHttpAllowed,omitempty"` + // IsHTTPSAllowed - Indicates whether HTTPS traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed. + IsHTTPSAllowed *bool `json:"isHttpsAllowed,omitempty"` + // QueryStringCachingBehavior - Defines how CDN caches requests that include query strings. You can ignore any query strings when caching, bypass caching to prevent requests that contain query strings from being cached, or cache every request with a unique URL. Possible values include: 'IgnoreQueryString', 'BypassCaching', 'UseQueryString', 'NotSet' + QueryStringCachingBehavior QueryStringCachingBehavior `json:"queryStringCachingBehavior,omitempty"` + // OptimizationType - Specifies what scenario the customer wants this CDN endpoint to optimize for, e.g. Download, Media services. With this information, CDN can apply scenario driven optimization. Possible values include: 'GeneralWebDelivery', 'GeneralMediaStreaming', 'VideoOnDemandMediaStreaming', 'LargeFileDownload', 'DynamicSiteAcceleration' + OptimizationType OptimizationType `json:"optimizationType,omitempty"` + // ProbePath - Path to a file hosted on the origin which helps accelerate delivery of the dynamic content and calculate the most optimal routes for the CDN. This is relative to the origin path. + ProbePath *string `json:"probePath,omitempty"` + // GeoFilters - List of rules defining the user's geo access within a CDN endpoint. Each geo filter defines an access rule to a specified path or content, e.g. block APAC for path /pictures/ + GeoFilters *[]GeoFilter `json:"geoFilters,omitempty"` + // DeliveryPolicy - A policy that specifies the delivery rules to be used for an endpoint. + DeliveryPolicy *EndpointPropertiesUpdateParametersDeliveryPolicy `json:"deliveryPolicy,omitempty"` +} + +// EndpointPropertiesUpdateParametersDeliveryPolicy a policy that specifies the delivery rules to be used +// for an endpoint. +type EndpointPropertiesUpdateParametersDeliveryPolicy struct { + // Description - User-friendly description of the policy. + Description *string `json:"description,omitempty"` + // Rules - A list of the delivery rules. + Rules *[]DeliveryRule `json:"rules,omitempty"` +} + +// EndpointsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EndpointsCreateFuture) Result(client EndpointsClient) (e Endpoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.EndpointsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { + e, err = client.CreateResponder(e.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsCreateFuture", "Result", e.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EndpointsDeleteFuture) Result(client EndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.EndpointsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// EndpointsLoadContentFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointsLoadContentFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EndpointsLoadContentFuture) Result(client EndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsLoadContentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.EndpointsLoadContentFuture") + return + } + ar.Response = future.Response() + return +} + +// EndpointsPurgeContentFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointsPurgeContentFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EndpointsPurgeContentFuture) Result(client EndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsPurgeContentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.EndpointsPurgeContentFuture") + return + } + ar.Response = future.Response() + return +} + +// EndpointsStartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointsStartFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EndpointsStartFuture) Result(client EndpointsClient) (e Endpoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.EndpointsStartFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { + e, err = client.StartResponder(e.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsStartFuture", "Result", e.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointsStopFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointsStopFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EndpointsStopFuture) Result(client EndpointsClient) (e Endpoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsStopFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.EndpointsStopFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { + e, err = client.StopResponder(e.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsStopFuture", "Result", e.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *EndpointsUpdateFuture) Result(client EndpointsClient) (e Endpoint, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.EndpointsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if e.Response.Response, err = future.GetResult(sender); err == nil && e.Response.Response.StatusCode != http.StatusNoContent { + e, err = client.UpdateResponder(e.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.EndpointsUpdateFuture", "Result", e.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointUpdateParameters properties required to create or update an endpoint. +type EndpointUpdateParameters struct { + // Tags - Endpoint tags. + Tags map[string]*string `json:"tags"` + *EndpointPropertiesUpdateParameters `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for EndpointUpdateParameters. +func (eup EndpointUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if eup.Tags != nil { + objectMap["tags"] = eup.Tags + } + if eup.EndpointPropertiesUpdateParameters != nil { + objectMap["properties"] = eup.EndpointPropertiesUpdateParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EndpointUpdateParameters struct. +func (eup *EndpointUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + eup.Tags = tags + } + case "properties": + if v != nil { + var endpointPropertiesUpdateParameters EndpointPropertiesUpdateParameters + err = json.Unmarshal(*v, &endpointPropertiesUpdateParameters) + if err != nil { + return err + } + eup.EndpointPropertiesUpdateParameters = &endpointPropertiesUpdateParameters + } + } + } + + return nil +} + +// ErrorResponse error response indicates CDN service is not able to process the incoming request. The +// reason is provided in the error message. +type ErrorResponse struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// GeoFilter rules defining user's geo access within a CDN endpoint. +type GeoFilter struct { + // RelativePath - Relative path applicable to geo filter. (e.g. '/mypictures', '/mypicture/kitty.jpg', and etc.) + RelativePath *string `json:"relativePath,omitempty"` + // Action - Action of the geo filter, i.e. allow or block access. Possible values include: 'Block', 'Allow' + Action GeoFilterActions `json:"action,omitempty"` + // CountryCodes - Two letter country codes defining user country access in a geo filter, e.g. AU, MX, US. + CountryCodes *[]string `json:"countryCodes,omitempty"` +} + +// HeaderActionParameters defines the parameters for the request header action. +type HeaderActionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // HeaderAction - Action to perform. Possible values include: 'Append', 'Overwrite', 'Delete' + HeaderAction HeaderAction `json:"headerAction,omitempty"` + // HeaderName - Name of the header to modify + HeaderName *string `json:"headerName,omitempty"` + // Value - Value for the specified action + Value *string `json:"value,omitempty"` +} + +// HTTPVersionMatchConditionParameters defines the parameters for HttpVersion match conditions +type HTTPVersionMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched + Operator *string `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` +} + +// IPAddressGroup CDN Ip address group +type IPAddressGroup struct { + // DeliveryRegion - The delivery region of the ip address group + DeliveryRegion *string `json:"deliveryRegion,omitempty"` + // Ipv4Addresses - The list of ip v4 addresses. + Ipv4Addresses *[]CidrIPAddress `json:"ipv4Addresses,omitempty"` + // Ipv6Addresses - The list of ip v6 addresses. + Ipv6Addresses *[]CidrIPAddress `json:"ipv6Addresses,omitempty"` +} + +// IsDeviceMatchConditionParameters defines the parameters for IsDevice match conditions +type IsDeviceMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched + Operator *string `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// KeyVaultCertificateSourceParameters describes the parameters for using a user's KeyVault certificate for +// securing custom domain. +type KeyVaultCertificateSourceParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // SubscriptionID - Subscription Id of the user's Key Vault containing the SSL certificate + SubscriptionID *string `json:"subscriptionId,omitempty"` + // ResourceGroupName - Resource group of the user's Key Vault containing the SSL certificate + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + // VaultName - The name of the user's Key Vault containing the SSL certificate + VaultName *string `json:"vaultName,omitempty"` + // SecretName - The name of Key Vault Secret (representing the full certificate PFX) in Key Vault. + SecretName *string `json:"secretName,omitempty"` + // SecretVersion - The version(GUID) of Key Vault Secret in Key Vault. + SecretVersion *string `json:"secretVersion,omitempty"` + // UpdateRule - Describes the action that shall be taken when the certificate is updated in Key Vault. + UpdateRule *string `json:"updateRule,omitempty"` + // DeleteRule - Describes the action that shall be taken when the certificate is removed from Key Vault. + DeleteRule *string `json:"deleteRule,omitempty"` +} + +// LoadParameters parameters required for content load. +type LoadParameters struct { + // ContentPaths - The path to the content to be loaded. Path should be a relative file URL of the origin. + ContentPaths *[]string `json:"contentPaths,omitempty"` +} + +// ManagedHTTPSParameters defines the certificate source parameters using CDN managed certificate for +// enabling SSL. +type ManagedHTTPSParameters struct { + // CertificateSourceParameters - Defines the certificate source parameters using CDN managed certificate for enabling SSL. + CertificateSourceParameters *CertificateSourceParameters `json:"certificateSourceParameters,omitempty"` + // ProtocolType - Defines the TLS extension protocol that is used for secure delivery. Possible values include: 'ServerNameIndication', 'IPBased' + ProtocolType ProtocolType `json:"protocolType,omitempty"` + // MinimumTLSVersion - TLS protocol version that will be used for Https. Possible values include: 'None', 'TLS10', 'TLS12' + MinimumTLSVersion MinimumTLSVersion `json:"minimumTlsVersion,omitempty"` + // CertificateSource - Possible values include: 'CertificateSourceCustomDomainHTTPSParameters', 'CertificateSourceCdn', 'CertificateSourceAzureKeyVault' + CertificateSource CertificateSource `json:"certificateSource,omitempty"` +} + +// MarshalJSON is the custom marshaler for ManagedHTTPSParameters. +func (mhp ManagedHTTPSParameters) MarshalJSON() ([]byte, error) { + mhp.CertificateSource = CertificateSourceCdn + objectMap := make(map[string]interface{}) + if mhp.CertificateSourceParameters != nil { + objectMap["certificateSourceParameters"] = mhp.CertificateSourceParameters + } + if mhp.ProtocolType != "" { + objectMap["protocolType"] = mhp.ProtocolType + } + if mhp.MinimumTLSVersion != "" { + objectMap["minimumTlsVersion"] = mhp.MinimumTLSVersion + } + if mhp.CertificateSource != "" { + objectMap["certificateSource"] = mhp.CertificateSource + } + return json.Marshal(objectMap) +} + +// AsManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. +func (mhp ManagedHTTPSParameters) AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) { + return &mhp, true +} + +// AsUserManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. +func (mhp ManagedHTTPSParameters) AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) { + return nil, false +} + +// AsCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. +func (mhp ManagedHTTPSParameters) AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) { + return nil, false +} + +// AsBasicCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for ManagedHTTPSParameters. +func (mhp ManagedHTTPSParameters) AsBasicCustomDomainHTTPSParameters() (BasicCustomDomainHTTPSParameters, bool) { + return &mhp, true +} + +// Operation CDN REST API operation +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.Cdn + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed: Profile, endpoint, etc. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationsListResult result of the request to list CDN operations. It contains a list of operations and +// a URL link to get the next set of results. +type OperationsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of CDN operations supported by the CDN resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationsListResultIterator provides access to a complete listing of Operation values. +type OperationsListResultIterator struct { + i int + page OperationsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationsListResultIterator) Response() OperationsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationsListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationsListResultIterator type. +func NewOperationsListResultIterator(page OperationsListResultPage) OperationsListResultIterator { + return OperationsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationsListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationsListResult) operationsListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationsListResultPage contains a page of Operation values. +type OperationsListResultPage struct { + fn func(context.Context, OperationsListResult) (OperationsListResult, error) + olr OperationsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationsListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationsListResultPage) Response() OperationsListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationsListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationsListResultPage type. +func NewOperationsListResultPage(getNextPage func(context.Context, OperationsListResult) (OperationsListResult, error)) OperationsListResultPage { + return OperationsListResultPage{fn: getNextPage} +} + +// Origin CDN origin is the source of the content being delivered via CDN. When the edge nodes represented +// by an endpoint do not have the requested content cached, they attempt to fetch it from one or more of +// the configured origins. +type Origin struct { + autorest.Response `json:"-"` + *OriginProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Origin. +func (o Origin) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.OriginProperties != nil { + objectMap["properties"] = o.OriginProperties + } + if o.Location != nil { + objectMap["location"] = o.Location + } + if o.Tags != nil { + objectMap["tags"] = o.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Origin struct. +func (o *Origin) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var originProperties OriginProperties + err = json.Unmarshal(*v, &originProperties) + if err != nil { + return err + } + o.OriginProperties = &originProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + o.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + o.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + o.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + o.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + o.Type = &typeVar + } + } + } + + return nil +} + +// OriginListResult result of the request to list origins. It contains a list of origin objects and a URL +// link to get the next set of results. +type OriginListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of CDN origins within an endpoint + Value *[]Origin `json:"value,omitempty"` + // NextLink - URL to get the next set of origin objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OriginListResultIterator provides access to a complete listing of Origin values. +type OriginListResultIterator struct { + i int + page OriginListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OriginListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OriginListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OriginListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OriginListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OriginListResultIterator) Response() OriginListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OriginListResultIterator) Value() Origin { + if !iter.page.NotDone() { + return Origin{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OriginListResultIterator type. +func NewOriginListResultIterator(page OriginListResultPage) OriginListResultIterator { + return OriginListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OriginListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// originListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OriginListResult) originListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OriginListResultPage contains a page of Origin values. +type OriginListResultPage struct { + fn func(context.Context, OriginListResult) (OriginListResult, error) + olr OriginListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OriginListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OriginListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OriginListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OriginListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OriginListResultPage) Response() OriginListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OriginListResultPage) Values() []Origin { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OriginListResultPage type. +func NewOriginListResultPage(getNextPage func(context.Context, OriginListResult) (OriginListResult, error)) OriginListResultPage { + return OriginListResultPage{fn: getNextPage} +} + +// OriginProperties the JSON object that contains the properties of the origin. +type OriginProperties struct { + // HostName - The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported. + HostName *string `json:"hostName,omitempty"` + // HTTPPort - The value of the HTTP port. Must be between 1 and 65535. + HTTPPort *int32 `json:"httpPort,omitempty"` + // HTTPSPort - The value of the https port. Must be between 1 and 65535. + HTTPSPort *int32 `json:"httpsPort,omitempty"` + // ResourceState - READ-ONLY; Resource status of the origin. Possible values include: 'OriginResourceStateCreating', 'OriginResourceStateActive', 'OriginResourceStateDeleting' + ResourceState OriginResourceState `json:"resourceState,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning status of the origin. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// OriginPropertiesParameters the JSON object that contains the properties of the origin. +type OriginPropertiesParameters struct { + // HostName - The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported. + HostName *string `json:"hostName,omitempty"` + // HTTPPort - The value of the HTTP port. Must be between 1 and 65535. + HTTPPort *int32 `json:"httpPort,omitempty"` + // HTTPSPort - The value of the HTTPS port. Must be between 1 and 65535. + HTTPSPort *int32 `json:"httpsPort,omitempty"` +} + +// OriginsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OriginsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *OriginsUpdateFuture) Result(client OriginsClient) (o Origin, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.OriginsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.OriginsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if o.Response.Response, err = future.GetResult(sender); err == nil && o.Response.Response.StatusCode != http.StatusNoContent { + o, err = client.UpdateResponder(o.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.OriginsUpdateFuture", "Result", o.Response.Response, "Failure responding to request") + } + } + return +} + +// OriginUpdateParameters origin properties needed for origin creation or update. +type OriginUpdateParameters struct { + *OriginPropertiesParameters `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OriginUpdateParameters. +func (oup OriginUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if oup.OriginPropertiesParameters != nil { + objectMap["properties"] = oup.OriginPropertiesParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OriginUpdateParameters struct. +func (oup *OriginUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var originPropertiesParameters OriginPropertiesParameters + err = json.Unmarshal(*v, &originPropertiesParameters) + if err != nil { + return err + } + oup.OriginPropertiesParameters = &originPropertiesParameters + } + } + } + + return nil +} + +// PostArgsMatchConditionParameters defines the parameters for PostArgs match conditions +type PostArgsMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Selector - Name of PostArg to be matched + Selector *string `json:"selector,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'PostArgsOperatorAny', 'PostArgsOperatorEqual', 'PostArgsOperatorContains', 'PostArgsOperatorBeginsWith', 'PostArgsOperatorEndsWith', 'PostArgsOperatorLessThan', 'PostArgsOperatorLessThanOrEqual', 'PostArgsOperatorGreaterThan', 'PostArgsOperatorGreaterThanOrEqual' + Operator PostArgsOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// Profile CDN profile is a logical grouping of endpoints that share the same settings, such as CDN +// provider and pricing tier. +type Profile struct { + autorest.Response `json:"-"` + // Sku - The pricing tier (defines a CDN provider, feature list and rate) of the CDN profile. + Sku *Sku `json:"sku,omitempty"` + *ProfileProperties `json:"properties,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Profile. +func (p Profile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.Sku != nil { + objectMap["sku"] = p.Sku + } + if p.ProfileProperties != nil { + objectMap["properties"] = p.ProfileProperties + } + if p.Location != nil { + objectMap["location"] = p.Location + } + if p.Tags != nil { + objectMap["tags"] = p.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Profile struct. +func (p *Profile) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + p.Sku = &sku + } + case "properties": + if v != nil { + var profileProperties ProfileProperties + err = json.Unmarshal(*v, &profileProperties) + if err != nil { + return err + } + p.ProfileProperties = &profileProperties + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + p.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + p.Tags = tags + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// ProfileListResult result of the request to list profiles. It contains a list of profile objects and a +// URL link to get the next set of results. +type ProfileListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of CDN profiles within a resource group. + Value *[]Profile `json:"value,omitempty"` + // NextLink - URL to get the next set of profile objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProfileListResultIterator provides access to a complete listing of Profile values. +type ProfileListResultIterator struct { + i int + page ProfileListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ProfileListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ProfileListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProfileListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ProfileListResultIterator) Response() ProfileListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ProfileListResultIterator) Value() Profile { + if !iter.page.NotDone() { + return Profile{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProfileListResultIterator type. +func NewProfileListResultIterator(page ProfileListResultPage) ProfileListResultIterator { + return ProfileListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plr ProfileListResult) IsEmpty() bool { + return plr.Value == nil || len(*plr.Value) == 0 +} + +// profileListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plr ProfileListResult) profileListResultPreparer(ctx context.Context) (*http.Request, error) { + if plr.NextLink == nil || len(to.String(plr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plr.NextLink))) +} + +// ProfileListResultPage contains a page of Profile values. +type ProfileListResultPage struct { + fn func(context.Context, ProfileListResult) (ProfileListResult, error) + plr ProfileListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ProfileListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.plr) + if err != nil { + return err + } + page.plr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProfileListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProfileListResultPage) NotDone() bool { + return !page.plr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProfileListResultPage) Response() ProfileListResult { + return page.plr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProfileListResultPage) Values() []Profile { + if page.plr.IsEmpty() { + return nil + } + return *page.plr.Value +} + +// Creates a new instance of the ProfileListResultPage type. +func NewProfileListResultPage(getNextPage func(context.Context, ProfileListResult) (ProfileListResult, error)) ProfileListResultPage { + return ProfileListResultPage{fn: getNextPage} +} + +// ProfileProperties the JSON object that contains the properties required to create a profile. +type ProfileProperties struct { + // ResourceState - READ-ONLY; Resource status of the profile. Possible values include: 'ProfileResourceStateCreating', 'ProfileResourceStateActive', 'ProfileResourceStateDeleting', 'ProfileResourceStateDisabled' + ResourceState ProfileResourceState `json:"resourceState,omitempty"` + // ProvisioningState - READ-ONLY; Provisioning status of the profile. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// ProfilesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ProfilesCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ProfilesCreateFuture) Result(client ProfilesClient) (p Profile, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.ProfilesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if p.Response.Response, err = future.GetResult(sender); err == nil && p.Response.Response.StatusCode != http.StatusNoContent { + p, err = client.CreateResponder(p.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesCreateFuture", "Result", p.Response.Response, "Failure responding to request") + } + } + return +} + +// ProfilesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ProfilesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ProfilesDeleteFuture) Result(client ProfilesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.ProfilesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ProfilesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ProfilesUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ProfilesUpdateFuture) Result(client ProfilesClient) (p Profile, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("cdn.ProfilesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if p.Response.Response, err = future.GetResult(sender); err == nil && p.Response.Response.StatusCode != http.StatusNoContent { + p, err = client.UpdateResponder(p.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "cdn.ProfilesUpdateFuture", "Result", p.Response.Response, "Failure responding to request") + } + } + return +} + +// ProfileUpdateParameters properties required to update a profile. +type ProfileUpdateParameters struct { + // Tags - Profile tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ProfileUpdateParameters. +func (pup ProfileUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pup.Tags != nil { + objectMap["tags"] = pup.Tags + } + return json.Marshal(objectMap) +} + +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// PurgeParameters parameters required for content purge. +type PurgeParameters struct { + // ContentPaths - The path to the content to be purged. Can describe a file path or a wild card directory. + ContentPaths *[]string `json:"contentPaths,omitempty"` +} + +// QueryStringMatchConditionParameters defines the parameters for QueryString match conditions +type QueryStringMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'QueryStringOperatorAny', 'QueryStringOperatorEqual', 'QueryStringOperatorContains', 'QueryStringOperatorBeginsWith', 'QueryStringOperatorEndsWith', 'QueryStringOperatorLessThan', 'QueryStringOperatorLessThanOrEqual', 'QueryStringOperatorGreaterThan', 'QueryStringOperatorGreaterThanOrEqual' + Operator QueryStringOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// RemoteAddressMatchConditionParameters defines the parameters for RemoteAddress match conditions +type RemoteAddressMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'RemoteAddressOperatorAny', 'RemoteAddressOperatorIPMatch', 'RemoteAddressOperatorGeoMatch' + Operator RemoteAddressOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - Match values to match against. The operator will apply to each value in here with OR semantics. If any of them match the variable with the given operator this match condition is considered a match. + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// RequestBodyMatchConditionParameters defines the parameters for RequestBody match conditions +type RequestBodyMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'RequestBodyOperatorAny', 'RequestBodyOperatorEqual', 'RequestBodyOperatorContains', 'RequestBodyOperatorBeginsWith', 'RequestBodyOperatorEndsWith', 'RequestBodyOperatorLessThan', 'RequestBodyOperatorLessThanOrEqual', 'RequestBodyOperatorGreaterThan', 'RequestBodyOperatorGreaterThanOrEqual' + Operator RequestBodyOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// RequestHeaderMatchConditionParameters defines the parameters for RequestHeader match conditions +type RequestHeaderMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Selector - Name of Header to be matched + Selector *string `json:"selector,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'RequestHeaderOperatorAny', 'RequestHeaderOperatorEqual', 'RequestHeaderOperatorContains', 'RequestHeaderOperatorBeginsWith', 'RequestHeaderOperatorEndsWith', 'RequestHeaderOperatorLessThan', 'RequestHeaderOperatorLessThanOrEqual', 'RequestHeaderOperatorGreaterThan', 'RequestHeaderOperatorGreaterThanOrEqual' + Operator RequestHeaderOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// RequestMethodMatchConditionParameters defines the parameters for RequestMethod match conditions +type RequestMethodMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched + Operator *string `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` +} + +// RequestSchemeMatchConditionParameters defines the parameters for RequestScheme match conditions +type RequestSchemeMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched + Operator *string `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` +} + +// RequestURIMatchConditionParameters defines the parameters for RequestUri match conditions +type RequestURIMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'RequestURIOperatorAny', 'RequestURIOperatorEqual', 'RequestURIOperatorContains', 'RequestURIOperatorBeginsWith', 'RequestURIOperatorEndsWith', 'RequestURIOperatorLessThan', 'RequestURIOperatorLessThanOrEqual', 'RequestURIOperatorGreaterThan', 'RequestURIOperatorGreaterThanOrEqual' + Operator RequestURIOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// Resource the core properties of ARM resources +type Resource struct { + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// ResourceUsage output of check resource usage API. +type ResourceUsage struct { + // ResourceType - READ-ONLY; Resource type for which the usage is provided. + ResourceType *string `json:"resourceType,omitempty"` + // Unit - READ-ONLY; Unit of the usage. e.g. Count. + Unit *string `json:"unit,omitempty"` + // CurrentValue - READ-ONLY; Actual value of usage on the specified resource type. + CurrentValue *int32 `json:"currentValue,omitempty"` + // Limit - READ-ONLY; Quota of the specified resource type. + Limit *int32 `json:"limit,omitempty"` +} + +// ResourceUsageListResult output of check resource usage API. +type ResourceUsageListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of resource usages. + Value *[]ResourceUsage `json:"value,omitempty"` + // NextLink - URL to get the next set of custom domain objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// ResourceUsageListResultIterator provides access to a complete listing of ResourceUsage values. +type ResourceUsageListResultIterator struct { + i int + page ResourceUsageListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ResourceUsageListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceUsageListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ResourceUsageListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ResourceUsageListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ResourceUsageListResultIterator) Response() ResourceUsageListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ResourceUsageListResultIterator) Value() ResourceUsage { + if !iter.page.NotDone() { + return ResourceUsage{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ResourceUsageListResultIterator type. +func NewResourceUsageListResultIterator(page ResourceUsageListResultPage) ResourceUsageListResultIterator { + return ResourceUsageListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rulr ResourceUsageListResult) IsEmpty() bool { + return rulr.Value == nil || len(*rulr.Value) == 0 +} + +// resourceUsageListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rulr ResourceUsageListResult) resourceUsageListResultPreparer(ctx context.Context) (*http.Request, error) { + if rulr.NextLink == nil || len(to.String(rulr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rulr.NextLink))) +} + +// ResourceUsageListResultPage contains a page of ResourceUsage values. +type ResourceUsageListResultPage struct { + fn func(context.Context, ResourceUsageListResult) (ResourceUsageListResult, error) + rulr ResourceUsageListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ResourceUsageListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ResourceUsageListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rulr) + if err != nil { + return err + } + page.rulr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ResourceUsageListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ResourceUsageListResultPage) NotDone() bool { + return !page.rulr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ResourceUsageListResultPage) Response() ResourceUsageListResult { + return page.rulr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ResourceUsageListResultPage) Values() []ResourceUsage { + if page.rulr.IsEmpty() { + return nil + } + return *page.rulr.Value +} + +// Creates a new instance of the ResourceUsageListResultPage type. +func NewResourceUsageListResultPage(getNextPage func(context.Context, ResourceUsageListResult) (ResourceUsageListResult, error)) ResourceUsageListResultPage { + return ResourceUsageListResultPage{fn: getNextPage} +} + +// Sku the pricing tier (defines a CDN provider, feature list and rate) of the CDN profile. +type Sku struct { + // Name - Name of the pricing tier. Possible values include: 'StandardVerizon', 'PremiumVerizon', 'CustomVerizon', 'StandardAkamai', 'StandardChinaCdn', 'StandardMicrosoft', 'PremiumChinaCdn' + Name SkuName `json:"name,omitempty"` +} + +// SsoURI the URI required to login to the supplemental portal from the Azure portal. +type SsoURI struct { + autorest.Response `json:"-"` + // SsoURIValue - READ-ONLY; The URI used to login to the supplemental portal. + SsoURIValue *string `json:"ssoUriValue,omitempty"` +} + +// SupportedOptimizationTypesListResult the result of the GetSupportedOptimizationTypes API +type SupportedOptimizationTypesListResult struct { + autorest.Response `json:"-"` + // SupportedOptimizationTypes - READ-ONLY; Supported optimization types for a profile. + SupportedOptimizationTypes *[]OptimizationType `json:"supportedOptimizationTypes,omitempty"` +} + +// TrackedResource the resource model definition for a ARM tracked top level resource. +type TrackedResource struct { + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ID - READ-ONLY; Resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Location != nil { + objectMap["location"] = tr.Location + } + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// URLFileExtensionMatchConditionParameters defines the parameters for UrlFileExtension match conditions +type URLFileExtensionMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'URLFileExtensionOperatorAny', 'URLFileExtensionOperatorEqual', 'URLFileExtensionOperatorContains', 'URLFileExtensionOperatorBeginsWith', 'URLFileExtensionOperatorEndsWith', 'URLFileExtensionOperatorLessThan', 'URLFileExtensionOperatorLessThanOrEqual', 'URLFileExtensionOperatorGreaterThan', 'URLFileExtensionOperatorGreaterThanOrEqual' + Operator URLFileExtensionOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// URLFileNameMatchConditionParameters defines the parameters for UrlFilename match conditions +type URLFileNameMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'URLFileNameOperatorAny', 'URLFileNameOperatorEqual', 'URLFileNameOperatorContains', 'URLFileNameOperatorBeginsWith', 'URLFileNameOperatorEndsWith', 'URLFileNameOperatorLessThan', 'URLFileNameOperatorLessThanOrEqual', 'URLFileNameOperatorGreaterThan', 'URLFileNameOperatorGreaterThanOrEqual' + Operator URLFileNameOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// URLPathMatchConditionParameters defines the parameters for UrlPath match conditions +type URLPathMatchConditionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'URLPathOperatorAny', 'URLPathOperatorEqual', 'URLPathOperatorContains', 'URLPathOperatorBeginsWith', 'URLPathOperatorEndsWith', 'URLPathOperatorLessThan', 'URLPathOperatorLessThanOrEqual', 'URLPathOperatorGreaterThan', 'URLPathOperatorGreaterThanOrEqual', 'URLPathOperatorWildcard' + Operator URLPathOperator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValues - The match value for the condition of the delivery rule + MatchValues *[]string `json:"matchValues,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// URLRedirectAction defines the url redirect action for the delivery rule. +type URLRedirectAction struct { + // Parameters - Defines the parameters for the action. + Parameters *URLRedirectActionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleAction', 'NameURLRedirect', 'NameURLRewrite', 'NameModifyRequestHeader', 'NameModifyResponseHeader', 'NameCacheExpiration', 'NameCacheKeyQueryString' + Name NameBasicDeliveryRuleAction `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for URLRedirectAction. +func (ura URLRedirectAction) MarshalJSON() ([]byte, error) { + ura.Name = NameURLRedirect + objectMap := make(map[string]interface{}) + if ura.Parameters != nil { + objectMap["parameters"] = ura.Parameters + } + if ura.Name != "" { + objectMap["name"] = ura.Name + } + return json.Marshal(objectMap) +} + +// AsURLRedirectAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsURLRedirectAction() (*URLRedirectAction, bool) { + return &ura, true +} + +// AsURLRewriteAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsURLRewriteAction() (*URLRewriteAction, bool) { + return nil, false +} + +// AsDeliveryRuleRequestHeaderAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleResponseHeaderAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheKeyQueryStringAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) { + return nil, false +} + +// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { + return nil, false +} + +// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for URLRedirectAction. +func (ura URLRedirectAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { + return &ura, true +} + +// URLRedirectActionParameters defines the parameters for the url redirect action. +type URLRedirectActionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // RedirectType - The redirect type the rule will use when redirecting traffic. Possible values include: 'Moved', 'Found', 'TemporaryRedirect', 'PermanentRedirect' + RedirectType RedirectType `json:"redirectType,omitempty"` + // DestinationProtocol - Protocol to use for the redirect. The default value is MatchRequest. Possible values include: 'MatchRequest', 'HTTP', 'HTTPS' + DestinationProtocol DestinationProtocol `json:"destinationProtocol,omitempty"` + // CustomPath - The full path to redirect. Path cannot be empty and must start with /. Leave empty to use the incoming path as destination path. + CustomPath *string `json:"customPath,omitempty"` + // CustomHostname - Host to redirect. Leave empty to use the incoming host as the destination host. + CustomHostname *string `json:"customHostname,omitempty"` + // CustomQueryString - The set of query strings to be placed in the redirect URL. Setting this value would replace any existing query string; leave empty to preserve the incoming query string. Query string must be in = format. ? and & will be added automatically so do not include them. + CustomQueryString *string `json:"customQueryString,omitempty"` + // CustomFragment - Fragment to add to the redirect URL. Fragment is the part of the URL that comes after #. Do not include the #. + CustomFragment *string `json:"customFragment,omitempty"` +} + +// URLRewriteAction defines the url rewrite action for the delivery rule. +type URLRewriteAction struct { + // Parameters - Defines the parameters for the action. + Parameters *URLRewriteActionParameters `json:"parameters,omitempty"` + // Name - Possible values include: 'NameDeliveryRuleAction', 'NameURLRedirect', 'NameURLRewrite', 'NameModifyRequestHeader', 'NameModifyResponseHeader', 'NameCacheExpiration', 'NameCacheKeyQueryString' + Name NameBasicDeliveryRuleAction `json:"name,omitempty"` +} + +// MarshalJSON is the custom marshaler for URLRewriteAction. +func (ura URLRewriteAction) MarshalJSON() ([]byte, error) { + ura.Name = NameURLRewrite + objectMap := make(map[string]interface{}) + if ura.Parameters != nil { + objectMap["parameters"] = ura.Parameters + } + if ura.Name != "" { + objectMap["name"] = ura.Name + } + return json.Marshal(objectMap) +} + +// AsURLRedirectAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsURLRedirectAction() (*URLRedirectAction, bool) { + return nil, false +} + +// AsURLRewriteAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsURLRewriteAction() (*URLRewriteAction, bool) { + return &ura, true +} + +// AsDeliveryRuleRequestHeaderAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsDeliveryRuleRequestHeaderAction() (*DeliveryRuleRequestHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleResponseHeaderAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsDeliveryRuleResponseHeaderAction() (*DeliveryRuleResponseHeaderAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheExpirationAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsDeliveryRuleCacheExpirationAction() (*DeliveryRuleCacheExpirationAction, bool) { + return nil, false +} + +// AsDeliveryRuleCacheKeyQueryStringAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsDeliveryRuleCacheKeyQueryStringAction() (*DeliveryRuleCacheKeyQueryStringAction, bool) { + return nil, false +} + +// AsDeliveryRuleAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsDeliveryRuleAction() (*DeliveryRuleAction, bool) { + return nil, false +} + +// AsBasicDeliveryRuleAction is the BasicDeliveryRuleAction implementation for URLRewriteAction. +func (ura URLRewriteAction) AsBasicDeliveryRuleAction() (BasicDeliveryRuleAction, bool) { + return &ura, true +} + +// URLRewriteActionParameters defines the parameters for the url rewrite action. +type URLRewriteActionParameters struct { + OdataType *string `json:"@odata.type,omitempty"` + // SourcePattern - define a request URI pattern that identifies the type of requests that may be rewritten. Currently, source pattern uses a prefix-based match. To match all URL paths, use "/" as the source pattern value. To match only the root directory and re-write this path, use the origin path field + SourcePattern *string `json:"sourcePattern,omitempty"` + // Destination - Define the destination path for be used in the rewrite. This will overwrite the source pattern + Destination *string `json:"destination,omitempty"` + // PreserveUnmatchedPath - If True, the remaining path after the source pattern will be appended to the new destination path. + PreserveUnmatchedPath *bool `json:"preserveUnmatchedPath,omitempty"` +} + +// UserManagedHTTPSParameters defines the certificate source parameters using user's keyvault certificate +// for enabling SSL. +type UserManagedHTTPSParameters struct { + // CertificateSourceParameters - Defines the certificate source parameters using user's keyvault certificate for enabling SSL. + CertificateSourceParameters *KeyVaultCertificateSourceParameters `json:"certificateSourceParameters,omitempty"` + // ProtocolType - Defines the TLS extension protocol that is used for secure delivery. Possible values include: 'ServerNameIndication', 'IPBased' + ProtocolType ProtocolType `json:"protocolType,omitempty"` + // MinimumTLSVersion - TLS protocol version that will be used for Https. Possible values include: 'None', 'TLS10', 'TLS12' + MinimumTLSVersion MinimumTLSVersion `json:"minimumTlsVersion,omitempty"` + // CertificateSource - Possible values include: 'CertificateSourceCustomDomainHTTPSParameters', 'CertificateSourceCdn', 'CertificateSourceAzureKeyVault' + CertificateSource CertificateSource `json:"certificateSource,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserManagedHTTPSParameters. +func (umhp UserManagedHTTPSParameters) MarshalJSON() ([]byte, error) { + umhp.CertificateSource = CertificateSourceAzureKeyVault + objectMap := make(map[string]interface{}) + if umhp.CertificateSourceParameters != nil { + objectMap["certificateSourceParameters"] = umhp.CertificateSourceParameters + } + if umhp.ProtocolType != "" { + objectMap["protocolType"] = umhp.ProtocolType + } + if umhp.MinimumTLSVersion != "" { + objectMap["minimumTlsVersion"] = umhp.MinimumTLSVersion + } + if umhp.CertificateSource != "" { + objectMap["certificateSource"] = umhp.CertificateSource + } + return json.Marshal(objectMap) +} + +// AsManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. +func (umhp UserManagedHTTPSParameters) AsManagedHTTPSParameters() (*ManagedHTTPSParameters, bool) { + return nil, false +} + +// AsUserManagedHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. +func (umhp UserManagedHTTPSParameters) AsUserManagedHTTPSParameters() (*UserManagedHTTPSParameters, bool) { + return &umhp, true +} + +// AsCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. +func (umhp UserManagedHTTPSParameters) AsCustomDomainHTTPSParameters() (*CustomDomainHTTPSParameters, bool) { + return nil, false +} + +// AsBasicCustomDomainHTTPSParameters is the BasicCustomDomainHTTPSParameters implementation for UserManagedHTTPSParameters. +func (umhp UserManagedHTTPSParameters) AsBasicCustomDomainHTTPSParameters() (BasicCustomDomainHTTPSParameters, bool) { + return &umhp, true +} + +// ValidateCustomDomainInput input of the custom domain to be validated for DNS mapping. +type ValidateCustomDomainInput struct { + // HostName - The host name of the custom domain. Must be a domain name. + HostName *string `json:"hostName,omitempty"` +} + +// ValidateCustomDomainOutput output of custom domain validation. +type ValidateCustomDomainOutput struct { + autorest.Response `json:"-"` + // CustomDomainValidated - READ-ONLY; Indicates whether the custom domain is valid or not. + CustomDomainValidated *bool `json:"customDomainValidated,omitempty"` + // Reason - READ-ONLY; The reason why the custom domain is not valid. + Reason *string `json:"reason,omitempty"` + // Message - READ-ONLY; Error message describing why the custom domain is not valid. + Message *string `json:"message,omitempty"` +} + +// ValidateProbeInput input of the validate probe API. +type ValidateProbeInput struct { + // ProbeURL - The probe URL to validate. + ProbeURL *string `json:"probeURL,omitempty"` +} + +// ValidateProbeOutput output of the validate probe API. +type ValidateProbeOutput struct { + autorest.Response `json:"-"` + // IsValid - READ-ONLY; Indicates whether the probe URL is accepted or not. + IsValid *bool `json:"isValid,omitempty"` + // ErrorCode - READ-ONLY; Specifies the error code when the probe url is not accepted. + ErrorCode *string `json:"errorCode,omitempty"` + // Message - READ-ONLY; The detailed error message describing why the probe URL is not accepted. + Message *string `json:"message,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/operations.go index d52e1b598621..78308a3d372c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/operations.go @@ -77,7 +77,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationsListR // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/origins.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/origins.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/origins.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/origins.go index 05c6870b8776..7207fae1c8df 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/origins.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/origins.go @@ -98,7 +98,7 @@ func (client OriginsClient) GetPreparer(ctx context.Context, resourceGroupName s "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -185,7 +185,7 @@ func (client OriginsClient) ListByEndpointPreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -305,7 +305,7 @@ func (client OriginsClient) UpdatePreparer(ctx context.Context, resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/profiles.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/profiles.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/profiles.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/profiles.go index 12e0133d785a..305462fecb33 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/profiles.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/profiles.go @@ -91,7 +91,7 @@ func (client ProfilesClient) CreatePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -178,7 +178,7 @@ func (client ProfilesClient) DeletePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -270,7 +270,7 @@ func (client ProfilesClient) GenerateSsoURIPreparer(ctx context.Context, resourc "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -354,7 +354,7 @@ func (client ProfilesClient) GetPreparer(ctx context.Context, resourceGroupName "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -426,7 +426,7 @@ func (client ProfilesClient) ListPreparer(ctx context.Context) (*http.Request, e "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -546,7 +546,7 @@ func (client ProfilesClient) ListByResourceGroupPreparer(ctx context.Context, re "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -668,7 +668,7 @@ func (client ProfilesClient) ListResourceUsagePreparer(ctx context.Context, reso "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -790,7 +790,7 @@ func (client ProfilesClient) ListSupportedOptimizationTypesPreparer(ctx context. "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -870,7 +870,7 @@ func (client ProfilesClient) UpdatePreparer(ctx context.Context, resourceGroupNa "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/resourceusage.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/resourceusage.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/resourceusage.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/resourceusage.go index 71ae8646fd8f..6ea31f5dbd4b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/resourceusage.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/resourceusage.go @@ -81,7 +81,7 @@ func (client ResourceUsageClient) ListPreparer(ctx context.Context) (*http.Reque "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2017-10-12" + const APIVersion = "2019-04-15" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/version.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/version.go index f6472564e13c..8b4578a79683 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " cdn/2017-10-12" + return "Azure-SDK-For-Go/" + version.Number + " cdn/2019-04-15" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/modules.txt b/vendor/modules.txt index b9459dfa5ce1..6e166d69bb0d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -14,7 +14,7 @@ github.com/Azure/azure-sdk-for-go/services/appconfiguration/mgmt/2019-10-01/appc github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights github.com/Azure/azure-sdk-for-go/services/automation/mgmt/2015-10-31/automation github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2019-08-01/batch -github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn +github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn github.com/Azure/azure-sdk-for-go/services/cognitiveservices/mgmt/2017-04-18/cognitiveservices github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance diff --git a/website/docs/r/cdn_endpoint.html.markdown b/website/docs/r/cdn_endpoint.html.markdown index 6a1d159a0a54..e75d1d2b295b 100644 --- a/website/docs/r/cdn_endpoint.html.markdown +++ b/website/docs/r/cdn_endpoint.html.markdown @@ -4,7 +4,6 @@ layout: "azurerm" page_title: "Azure Resource Manager: azurerm_cdn_endpoint" description: |- Manages a CDN Endpoint. - --- # azurerm_cdn_endpoint @@ -14,40 +13,32 @@ A CDN Endpoint is the entity within a CDN Profile containing configuration infor ## Example Usage ```hcl -resource "random_id" "server" { - keepers = { - azi_id = 1 - } - - byte_length = 8 -} - resource "azurerm_resource_group" "example" { - name = "acceptanceTestResourceGroup1" - location = "West US" + name = "example-resources" + location = "West Europe" } resource "azurerm_cdn_profile" "example" { - name = "exampleCdnProfile" + name = "example-cdn" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name sku = "Standard_Verizon" } resource "azurerm_cdn_endpoint" "example" { - name = random_id.server.hex + name = "example" profile_name = azurerm_cdn_profile.example.name location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name origin { - name = "exampleCdnOrigin" + name = "example" host_name = "www.example.com" } } ``` -## Argument Reference +## Arguments Reference The following arguments are supported: @@ -101,6 +92,304 @@ The `geo_filter` block supports: * `country_codes` - (Required) A List of two letter country codes (e.g. `US`, `GB`) to be associated with this Geo Filter. +-> **NOTE:** `global_delivery_rule` and `delivery_rule` are currently only available for `Microsoft_Standard` CDN profiles. + +* `global_delivery_rule` - (Optional) Actions that are valid for all resources regardless of any conditions. A `global_delivery_rule` block as defined below. + +* `delivery_rule` - (Optional) Rules for the rules engine. An endpoint can contain up until 4 of those rules that consist of conditions and actions. A `delivery_rule` blocks as defined below. + +--- + +A `global_delivery_rule` block supports the following: + +* `cache_expiration_action` - (Optional) A `cache_expiration_action` block as defined above. + +* `cache_key_query_string_action` - (Optional) A `cache_key_query_string_action` block as defined above. + +* `modify_request_header_action` - (Optional) A `modify_request_header_action` block as defined below. + +* `modify_response_header_action` - (Optional) A `modify_response_header_action` block as defined below. + +* `url_redirect_action` - (Optional) A `url_redirect_action` block as defined below. + +* `url_rewrite_action` - (Optional) A `url_rewrite_action` block as defined below. + +--- + +A `delivery_rule` block supports the following: + +* `name` - (Required) The Name which should be used for this Delivery Rule. + +* `order` - (Required) The order used for this rule, which must be larger than 1. + +* `cache_expiration_action` - (Optional) A `cache_expiration_action` block as defined above. + +* `cache_key_query_string_action` - (Optional) A `cache_key_query_string_action` block as defined above. + +* `cookies_condition` - (Optional) A `cookies_condition` block as defined above. + +* `device_condition` - (Optional) A `device_condition` block as defined below. + +* `http_version_condition` - (Optional) A `http_version_condition` block as defined below. + +* `modify_request_header_action` - (Optional) A `modify_request_header_action` block as defined below. + +* `modify_response_header_action` - (Optional) A `modify_response_header_action` block as defined below. + +* `post_arg_condition` - (Optional) A `post_arg_condition` block as defined below. + +* `query_string_condition` - (Optional) A `query_string_condition` block as defined below. + +* `remote_address_condition` - (Optional) A `remote_address_condition` block as defined below. + +* `request_body_condition` - (Optional) A `request_body_condition` block as defined below. + +* `request_header_condition` - (Optional) A `request_header_condition` block as defined below. + +* `request_method_condition` - (Optional) A `request_method_condition` block as defined below. + +* `request_scheme_condition` - (Optional) A `request_scheme_condition` block as defined below. + +* `request_uri_condition` - (Optional) A `request_uri_condition` block as defined below. + +* `url_file_extension_condition` - (Optional) A `url_file_extension_condition` block as defined below. + +* `url_file_name_condition` - (Optional) A `url_file_name_condition` block as defined below. + +* `url_path_condition` - (Optional) A `url_path_condition` block as defined below. + +* `url_redirect_action` - (Optional) A `url_redirect_action` block as defined below. + +* `url_rewrite_action` - (Optional) A `url_rewrite_action` block as defined below. + +--- + +A `cache_expiration_action` block supports the following: + +* `behavior` - (Required) The behavior of the cache. Valid values are `BypassCache`, `Override` and `SetIfMissing`. + +* `duration` - (Optional) Duration of the cache. Only allowed when `behavior` is set to `Override` or `SetIfMissing`. Format: `[d.]hh:mm:ss` + +--- + +A `cache_key_query_string_action` block supports the following: + +* `behavior` - (Required) The behavior of the cache key for query strings. Valid values are `Exclude`, `ExcludeAll`, `Include` and `IncludeAll`. + +* `parameters` - (Optional) Comma separated list of parameter values. + +--- + +A `modify_request_header_action` block supports the following: + +* `action` - (Required) Action to be executed on a header value. Valid values are `Append`, `Delete` and `Overwrite`. + +* `name` - (Required) The header name. + +* `value` - (Optional) The value of the header. Only needed when `action` is set to `Append` or `overwrite`. + +--- + +A `modify_response_header_action` block supports the following: + +* `action` - (Required) Action to be executed on a header value. Valid values are `Append`, `Delete` and `Overwrite`. + +* `name` - (Required) The header name. + +* `value` - (Optional) The value of the header. Only needed when `action` is set to `Append` or `overwrite`. + +--- + +A `url_redirect_action` block supports the following: + +* `redirect_type` - (Required) Type of the redirect. Valid values are `Found`, `Moved`, `PermanentRedirect` and `TemporaryRedirect`. + +* `protocol` - (Optional) Specifies the protocol part of the URL. Valid values are `Http` and `Https`. + +* `hostname` - (Optional) Specifies the hostname part of the URL. + +* `path` - (Optional) Specifies the path part of the URL. This value must begin with a `/`. + +* `fragment` - (Optional) Specifies the fragment part of the URL. This value must not start with a `#`. + +* `query_string` - (Optional) Specifies the query string part of the URL. This value must not start with a `?` or `&` and must be in `=` format separated by `&`. + +--- + +A `url_rewrite_action` block supports the following: + +* `source_pattern` - (Required) This value must start with a `/` and can't be longer than 260 characters. + +* `destination` - (Required) This value must start with a `/` and can't be longer than 260 characters. + +* `preserve_unmatched_path` - (Optional) Defaults to `true`. + +--- + +A `cookies_condition` block supports the following: + +* `selector` - (Required) Name of the cookie. + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of values for the cookie. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `device_condition` block supports the following: + +* `operator` - (Optional) Valid values are `Equal`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) Valid values are `Desktop` and `Mobile`. + +--- + +A `http_version_condition` block supports the following: + +* `operator` - (Optional) Valid values are `Equal`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) Valid values are `0.9`, `1.0`, `1.1` and `2.0`. + +--- + +A `post_arg_condition` block supports the following: + +* `selector` - (Required) Name of the post arg. + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `query_string_condition` block supports the following: + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `remote_address_condition` block supports the following: + +* `operator` - (Required) Valid values are `Any`, `GeoMatch` and `IPMatch`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. For `GeoMatch` `operator` this should be a list of country codes (e.g. `US` or `DE`). List of IP address if `operator` equals to `IPMatch`. + +--- + +A `request_body_condition` block supports the following: + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `request_header_condition` block supports the following: + +* `selector` - (Required) Header name. + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of header values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `request_method_condition` block supports the following: + +* `operator` - (Optional) Valid values are `Equal`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) Valid values are `DELETE`, `GET`, `HEAD`, `OPTIONS`, `POST` and `PUT`. + +--- + +A `request_scheme_condition` block supports the following: + +* `operator` - (Optional) Valid values are `Equal`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) Valid values are `HTTP` and `HTTPS`. + +--- + +A `request_uri_condition` block supports the following: + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `url_file_extension_condition` block supports the following: + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `url_file_name_condition` block supports the following: + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + +A `url_path_condition` block supports the following: + +* `operator` - (Required) Valid values are `Any`, `BeginsWith`, `Contains`, `EndsWith`, `Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan` and `LessThanOrEqual`. + +* `negate_condition` - (Optional) Defaults to `false`. + +* `match_values` - (Required) List of string values. + +* `transforms` - (Optional) Valid values are `Lowercase` and `Uppercase`. + +--- + ## Attributes Reference The following attributes are exported: