From 421746592cc68b190582698d6d3f1883c63e36c1 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 16:07:35 +0100 Subject: [PATCH 01/92] bump CDN api version --- .../internal/services/cdn/client/client.go | 2 +- .../services/cdn/resource_arm_cdn_endpoint.go | 4 +- .../services/cdn/resource_arm_cdn_profile.go | 2 +- .../cdn/mgmt/2017-10-12/cdn/models.go | 3305 ---------- .../{2017-10-12 => 2019-04-15}/cdn/client.go | 8 +- .../cdn/customdomains.go | 12 +- .../cdn/edgenodes.go | 2 +- .../cdn/endpoints.go | 22 +- .../cdn/mgmt/2019-04-15/cdn/models.go | 5859 +++++++++++++++++ .../cdn/operations.go | 2 +- .../{2017-10-12 => 2019-04-15}/cdn/origins.go | 6 +- .../cdn/profiles.go | 18 +- .../cdn/resourceusage.go | 2 +- .../{2017-10-12 => 2019-04-15}/cdn/version.go | 2 +- vendor/modules.txt | 2 +- 15 files changed, 5902 insertions(+), 3346 deletions(-) delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/models.go rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/client.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/customdomains.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/edgenodes.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/endpoints.go (99%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/models.go rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/operations.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/origins.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/profiles.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/resourceusage.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/version.go (94%) 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/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index cf4b9cb39983..ccad38c087c2 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" @@ -197,6 +197,8 @@ func resourceArmCdnEndpoint() *schema.Resource { Computed: true, }, + "delivery_policy": EndpointDeliveryPolicy(), + "tags": tags.Schema(), }, } 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/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 df3714c94d58..423a5b0f186b 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 @@ -100,7 +100,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, } @@ -268,7 +268,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 7fe0bdd42003..98a215398ac0 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 @@ -95,7 +95,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, } @@ -281,7 +281,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, } @@ -373,7 +373,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, } @@ -467,7 +467,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, } @@ -555,7 +555,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 11f184afda4e..4301bf55001d 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 @@ -76,7 +76,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 1b780ee65646..9d7e2925cfb1 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 @@ -94,7 +94,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, } @@ -277,7 +277,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, } @@ -363,7 +363,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, } @@ -488,7 +488,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, } @@ -610,7 +610,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, } @@ -703,7 +703,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, } @@ -791,7 +791,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, } @@ -878,7 +878,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, } @@ -968,7 +968,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, } @@ -1066,7 +1066,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 c6c4ee5e5446..07e8d0c31a6d 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 @@ -76,7 +76,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 0fe220e021e2..a3982f327053 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 @@ -97,7 +97,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, } @@ -306,7 +306,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 77b127b13d3b..cf3de82123e5 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 @@ -90,7 +90,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, } @@ -271,7 +271,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, } @@ -356,7 +356,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, } @@ -429,7 +429,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, } @@ -550,7 +550,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, } @@ -673,7 +673,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, } @@ -796,7 +796,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, } @@ -877,7 +877,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 42995a73dbd0..ada2d799c88f 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 @@ -80,7 +80,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 ef8827c62e16..fc52258048e6 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/2018-12-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 From 50f3a5dbe4b7456456edfe02dd8b0a11123eac7c Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 16:15:49 +0100 Subject: [PATCH 02/92] add delivery policy rule name validation function --- azurerm/helpers/validate/cdn.go | 14 +++++++ azurerm/helpers/validate/cdn_test.go | 60 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 azurerm/helpers/validate/cdn.go create mode 100644 azurerm/helpers/validate/cdn_test.go diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go new file mode 100644 index 000000000000..9988317d34a6 --- /dev/null +++ b/azurerm/helpers/validate/cdn.go @@ -0,0 +1,14 @@ +package validate + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "regexp" +) + +func CdnEndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$"), + "The Delivery Policy Rule Name must start with a letter any may only contain letters and numbers.", + ) +} diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go new file mode 100644 index 000000000000..d3b7807e0b6a --- /dev/null +++ b/azurerm/helpers/validate/cdn_test.go @@ -0,0 +1,60 @@ +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 := CdnEndpointDeliveryPolicyRuleName()(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)) + } + }) + } +} From f6ad207a6d6d3a2bf54eb0fae01879bd9c9819cf Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 20:34:09 +0100 Subject: [PATCH 03/92] add endpoint delivery policy, rule, request schema condition and url redirect action --- azurerm/helpers/validate/cdn.go | 44 +++++- azurerm/helpers/validate/cdn_test.go | 133 ++++++++++++++++++ .../cdn/endpoint_delivery_policy_rule.go | 39 +++++ .../services/cdn/endpont_delivery_policy.go | 28 ++++ .../services/cdn/rule_action_url_redirect.go | 58 ++++++++ .../cdn/rule_condition_request_scheme.go | 38 +++++ 6 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go create mode 100644 azurerm/internal/services/cdn/endpont_delivery_policy.go create mode 100644 azurerm/internal/services/cdn/rule_action_url_redirect.go create mode 100644 azurerm/internal/services/cdn/rule_condition_request_scheme.go diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index 9988317d34a6..9c733d807a47 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -1,9 +1,12 @@ package validate import ( + "fmt" + "regexp" + "strings" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "regexp" ) func CdnEndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { @@ -12,3 +15,42 @@ func CdnEndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { "The Delivery Policy Rule Name must start with a letter any may only contain letters and numbers.", ) } + +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.Compile("^[?&]") + if re.MatchString(querystring) { + return nil, []error{fmt.Errorf("The Url Query String must not start with a question mark or ampersand.")} + } + + kvre, _ := regexp.Compile("^[^?&]+=[^?&]+$") + 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 Redirect Path must start with a slash.", + ) +} diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go index d3b7807e0b6a..aded6923d74f 100644 --- a/azurerm/helpers/validate/cdn_test.go +++ b/azurerm/helpers/validate/cdn_test.go @@ -58,3 +58,136 @@ func TestCdnEndpointDeliveryPolicyRuleName(t *testing.T) { }) } } + +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, "name") + + 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, "name") + + 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, "name") + + 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)) + } + }) + } +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go new file mode 100644 index 000000000000..78bf84b6e186 --- /dev/null +++ b/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go @@ -0,0 +1,39 @@ +package cdn + +import ( + "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" +) + +func EndpointDeliveryRule() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), + }, + + "order": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "request_scheme_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: RuleConditionRequestScheme(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: RuleActionUrlRedirect(), + }, + }, + } +} diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go new file mode 100644 index 000000000000..d38a97de6402 --- /dev/null +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -0,0 +1,28 @@ +package cdn + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +func EndpointDeliveryPolicy() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Required: false, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Required: false, + }, + + "delivery_rule": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: EndpointDeliveryRule(), + }, + }, + }, + } +} diff --git a/azurerm/internal/services/cdn/rule_action_url_redirect.go b/azurerm/internal/services/cdn/rule_action_url_redirect.go new file mode 100644 index 000000000000..38b2f163426d --- /dev/null +++ b/azurerm/internal/services/cdn/rule_action_url_redirect.go @@ -0,0 +1,58 @@ +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" +) + +func RuleActionUrlRedirect() *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), + }, + + "destination_protocol": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.MatchRequest), + string(cdn.HTTP), + string(cdn.HTTPS), + }, false), + }, + + "hostname": { + Type: schema.TypeString, + Required: false, + }, + + "path": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "query_string": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "fragment": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectFragment(), + }, + }, + } +} diff --git a/azurerm/internal/services/cdn/rule_condition_request_scheme.go b/azurerm/internal/services/cdn/rule_condition_request_scheme.go new file mode 100644 index 000000000000..e6db5bea7a3c --- /dev/null +++ b/azurerm/internal/services/cdn/rule_condition_request_scheme.go @@ -0,0 +1,38 @@ +package cdn + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" +) + +func RuleConditionRequestScheme() *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.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + ValidateFunc: validation.StringInSlice([]string{ + "HTTP", + "HTTPS", + }, false), + }, + }, + } +} From 90f2f4ef6dc919dc85e14a5f1e1e2d8aae08176d Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 20:48:18 +0100 Subject: [PATCH 04/92] allow max 5 rules per delivery policy --- azurerm/internal/services/cdn/endpont_delivery_policy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index d38a97de6402..b9fa81c4a26f 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -20,6 +20,7 @@ func EndpointDeliveryPolicy() *schema.Schema { Type: schema.TypeList, Required: true, MinItems: 1, + MaxItems: 5, Elem: EndpointDeliveryRule(), }, }, From ca528faf5eec9c8735ae2f1004615a18ccf408de Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 22:03:38 +0100 Subject: [PATCH 05/92] rename delivery_rule to rule; allow max 4 rules (leave one spot for global rule) --- azurerm/internal/services/cdn/endpont_delivery_policy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index b9fa81c4a26f..598533e4f0c0 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -16,11 +16,11 @@ func EndpointDeliveryPolicy() *schema.Schema { Required: false, }, - "delivery_rule": { + "rule": { Type: schema.TypeList, Required: true, MinItems: 1, - MaxItems: 5, + MaxItems: 4, Elem: EndpointDeliveryRule(), }, }, From 2806d1e0c3f41d755d99f12edf7b1b5e8f616476 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 22:38:04 +0100 Subject: [PATCH 06/92] implement rad & update for delivery_policy --- .../services/cdn/resource_arm_cdn_endpoint.go | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index ccad38c087c2..cd9bd96078ce 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -238,6 +238,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) + deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -255,6 +256,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro IsCompressionEnabled: &compressionEnabled, QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), OriginHostHeader: utils.String(originHostHeader), + DeliveryPolicy: deliveryPolicy, }, Tags: tags.Expand(t), } @@ -315,6 +317,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) + deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -331,6 +334,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro IsCompressionEnabled: utils.Bool(compressionEnabled), QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), OriginHostHeader: utils.String(hostHeader), + DeliveryPolicy: deliveryPolicy, }, Tags: tags.Expand(t), } @@ -586,3 +590,108 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface return results } + +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { + policies := d.Get("delivery_policy").([]interface{}) + if len(policies) == 0 { + return nil + } + + deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} + + policy := policies[0].(map[string]interface{}) + if descr, ok := policy["description"]; ok { + deliveryPolicy.Description = utils.String(descr.(string)) + } + + rules := policy["rule"].([]interface{}) + deliveryRules := make([]cdn.DeliveryRule, len(rules)) + for i, rule := range rules { + deliveryRules[i] = expandArmCdnEndpointDeliveryPolicyRule(rule.(map[string]interface{})) + } + deliveryPolicy.Rules = &deliveryRules + + return &deliveryPolicy +} + +func expandArmCdnEndpointDeliveryPolicyRule(rule map[string]interface{}) cdn.DeliveryRule { + deliveryRule := cdn.DeliveryRule{ + Name: utils.String(rule["name"].(string)), + Order: utils.Int32(rule["order"].(int32)), + } + + conditions := make([]cdn.BasicDeliveryRuleCondition, 0) + + if rsc, ok := rule["request_scheme_condition"]; ok { + conditions = append(conditions, *expandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Conditions = &conditions + + actions := make([]cdn.BasicDeliveryRuleAction, 0) + + if ura, ok := rule["url_redirect_action"]; ok { + actions = append(actions, *expandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Actions = &actions + + return deliveryRule +} + +func expandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { + requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ + Name: cdn.NameRequestScheme, + } + + matchValues := rsc["match_values"].([]string) + params := cdn.RequestSchemeMatchConditionParameters{ + MatchValues: &matchValues, + } + + if operator, ok := rsc["operator"]; ok { + params.Operator = utils.String(operator.(string)) + } + + if negate, ok := rsc["negate_condition"]; ok { + params.NegateCondition = utils.Bool(negate.(bool)) + } + + requestSchemeCondition.Parameters = ¶ms + + return &requestSchemeCondition +} + +func expandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { + urlRedirectAction := cdn.URLRedirectAction{ + Name: cdn.NameURLRedirect, + } + + params := cdn.URLRedirectActionParameters{ + RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), + } + + if destProt, ok := ura["destination_protocol"]; ok { + params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) + } + + if hostname, ok := ura["hostname"]; ok { + params.CustomHostname = utils.String(hostname.(string)) + } + + if path, ok := ura["path"]; ok { + params.CustomPath = utils.String(path.(string)) + } + + if queryString, ok := ura["query_string"]; ok { + params.CustomQueryString = utils.String(queryString.(string)) + } + + if fragment, ok := ura["fragment"]; ok { + params.CustomFragment = utils.String(fragment.(string)) + } + + urlRedirectAction.Parameters = ¶ms + + return &urlRedirectAction +} From e26f0397b49345492a890961d168126389679ea1 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 14:12:42 +0100 Subject: [PATCH 07/92] move actions and condition into own dir; add flatten functions for url redirect action and request scheme condition --- .../cdn/delivery_rule_actions/url_redirect.go | 122 ++++++++++++++++++ .../request_scheme.go | 83 ++++++++++++ .../cdn/endpoint_delivery_policy_rule.go | 39 ------ .../services/cdn/endpoint_delivery_rule.go | 103 +++++++++++++++ .../services/cdn/endpont_delivery_policy.go | 47 +++++++ .../services/cdn/resource_arm_cdn_endpoint.go | 110 +--------------- .../services/cdn/rule_action_url_redirect.go | 58 --------- .../cdn/rule_condition_request_scheme.go | 38 ------ 8 files changed, 360 insertions(+), 240 deletions(-) create mode 100644 azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go create mode 100644 azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go delete mode 100644 azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go create mode 100644 azurerm/internal/services/cdn/endpoint_delivery_rule.go delete mode 100644 azurerm/internal/services/cdn/rule_action_url_redirect.go delete mode 100644 azurerm/internal/services/cdn/rule_condition_request_scheme.go diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go new file mode 100644 index 000000000000..e88b6e538c68 --- /dev/null +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -0,0 +1,122 @@ +package delivery_rule_actions + +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/utils" +) + +func RuleActionUrlRedirect() *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, + Required: false, + Default: string(cdn.MatchRequest), + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.MatchRequest), + string(cdn.HTTP), + string(cdn.HTTPS), + }, false), + }, + + "hostname": { + Type: schema.TypeString, + Required: false, + }, + + "path": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "query_string": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "fragment": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectFragment(), + }, + }, + } +} + +func ExpandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { + urlRedirectAction := cdn.URLRedirectAction{ + Name: cdn.NameURLRedirect, + } + + params := cdn.URLRedirectActionParameters{ + RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), + } + + if destProt, ok := ura["protocol"]; ok { + params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) + } + + if hostname, ok := ura["hostname"]; ok { + params.CustomHostname = utils.String(hostname.(string)) + } + + if path, ok := ura["path"]; ok { + params.CustomPath = utils.String(path.(string)) + } + + if queryString, ok := ura["query_string"]; ok { + params.CustomQueryString = utils.String(queryString.(string)) + } + + if fragment, ok := ura["fragment"]; ok { + params.CustomFragment = utils.String(fragment.(string)) + } + + urlRedirectAction.Parameters = ¶ms + + return &urlRedirectAction +} + +func FlattenArmCdnEndpointActionUrlRedirect(ura *cdn.URLRedirectAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := ura.Parameters; params != nil { + res["redirect_type"] = string(params.RedirectType) + + res["protocol"] = string(params.DestinationProtocol) + + if params.CustomHostname != nil { + res["hostname"] = *params.CustomHostname + } + + if params.CustomPath != nil { + res["path"] = *params.CustomPath + } + + if params.CustomQueryString != nil { + res["query_string"] = *params.CustomQueryString + } + + if params.CustomFragment != nil { + res["fragment"] = *params.CustomFragment + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go new file mode 100644 index 000000000000..bc9863110510 --- /dev/null +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -0,0 +1,83 @@ +package delivery_rule_conditions + +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 RuleConditionRequestScheme() *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.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + ValidateFunc: validation.StringInSlice([]string{ + "HTTP", + "HTTPS", + }, false), + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { + requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ + Name: cdn.NameRequestScheme, + } + + matchValues := rsc["match_values"].([]string) + params := cdn.RequestSchemeMatchConditionParameters{ + MatchValues: &matchValues, + } + + if operator, ok := rsc["operator"]; ok { + params.Operator = utils.String(operator.(string)) + } + + if negate, ok := rsc["negate_condition"]; ok { + params.NegateCondition = utils.Bool(negate.(bool)) + } + + requestSchemeCondition.Parameters = ¶ms + + return &requestSchemeCondition +} + +func FlattenArmCdnEndpointConditionRequestScheme(condition *cdn.DeliveryRuleRequestSchemeCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := condition.Parameters; params != nil { + if params.Operator != nil { + res["operator"] = *params.Operator + } + + if params.NegateCondition != nil { + res["negate_condition"] = *params.NegateCondition + } + + if params.MatchValues != nil { + res["match_values"] = *params.MatchValues + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go deleted file mode 100644 index 78bf84b6e186..000000000000 --- a/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go +++ /dev/null @@ -1,39 +0,0 @@ -package cdn - -import ( - "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" -) - -func EndpointDeliveryRule() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), - }, - - "order": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, - - "request_scheme_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: RuleConditionRequestScheme(), - }, - - "url_redirect_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: RuleActionUrlRedirect(), - }, - }, - } -} 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..89f861dec5bb --- /dev/null +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -0,0 +1,103 @@ +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/delivery_rule_actions" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/delivery_rule_conditions" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func EndpointDeliveryRule() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), + }, + + "order": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "request_scheme_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_conditions.RuleConditionRequestScheme(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.RuleActionUrlRedirect(), + }, + }, + } +} + +func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryRule { + deliveryRule := cdn.DeliveryRule{ + Name: utils.String(rule["name"].(string)), + Order: utils.Int32(rule["order"].(int32)), + } + + conditions := make([]cdn.BasicDeliveryRuleCondition, 0) + + if rsc, ok := rule["request_scheme_condition"]; ok { + conditions = append(conditions, *delivery_rule_conditions.ExpandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Conditions = &conditions + + actions := make([]cdn.BasicDeliveryRuleAction, 0) + + if ura, ok := rule["url_redirect_action"]; ok { + actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Actions = &actions + + return deliveryRule +} + +func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { + res := make(map[string]interface{}, 0) + + if deliveryRule == nil { + return res + } + + if deliveryRule.Name != nil { + res["name"] = *deliveryRule.Name + } + + if deliveryRule.Order != nil { + res["order"] = *deliveryRule.Order + } + + if deliveryRule.Conditions != nil { + for _, basicDeliveryRuleCondition := range *deliveryRule.Conditions { + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { + res["request_scheme_condition"] = delivery_rule_conditions.FlattenArmCdnEndpointConditionRequestScheme(condition) + continue + } + } + } + + if deliveryRule.Actions != nil { + for _, basicDeliveryRuleAction := range *deliveryRule.Actions { + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { + res["url_redirect_action"] = delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action) + } + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index 598533e4f0c0..333b7c96883e 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -1,7 +1,9 @@ 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/utils" ) func EndpointDeliveryPolicy() *schema.Schema { @@ -27,3 +29,48 @@ func EndpointDeliveryPolicy() *schema.Schema { }, } } + +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { + policies := d.Get("delivery_policy").([]interface{}) + if len(policies) == 0 { + return nil + } + + deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} + + policy := policies[0].(map[string]interface{}) + if descr, ok := policy["description"]; ok { + deliveryPolicy.Description = utils.String(descr.(string)) + } + + rules := policy["rule"].([]interface{}) + deliveryRules := make([]cdn.DeliveryRule, len(rules)) + for i, rule := range rules { + deliveryRules[i] = expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + } + deliveryPolicy.Rules = &deliveryRules + + return &deliveryPolicy +} + +func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { + deliveryPolicies := make([]interface{}, 0) + + if deliveryPolicy == nil { + return deliveryPolicies + } + + dp := make(map[string]interface{}) + if deliveryPolicy.Description != nil { + dp["description"] = *deliveryPolicy.Description + } + + if deliveryPolicy.Rules != nil && len(*deliveryPolicy.Rules) > 0 { + rules := make([]map[string]interface{}, len(*deliveryPolicy.Rules)) + for i, rule := range *deliveryPolicy.Rules { + rules[i] = flattenArmCdnEndpointDeliveryRule(&rule) + } + } + + return deliveryPolicies +} diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index cd9bd96078ce..1ad6ad768024 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -416,6 +416,11 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("origin", origins); err != nil { return fmt.Errorf("Error setting `origin`: %+v", err) } + + deliveryPolicy := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) + if err := d.Set("delivery_policy", deliveryPolicy); err != nil { + return fmt.Errorf("Error setting `delivery_policy`: %+v", err) + } } return tags.FlattenAndSet(d, resp.Tags) @@ -590,108 +595,3 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface return results } - -func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { - policies := d.Get("delivery_policy").([]interface{}) - if len(policies) == 0 { - return nil - } - - deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} - - policy := policies[0].(map[string]interface{}) - if descr, ok := policy["description"]; ok { - deliveryPolicy.Description = utils.String(descr.(string)) - } - - rules := policy["rule"].([]interface{}) - deliveryRules := make([]cdn.DeliveryRule, len(rules)) - for i, rule := range rules { - deliveryRules[i] = expandArmCdnEndpointDeliveryPolicyRule(rule.(map[string]interface{})) - } - deliveryPolicy.Rules = &deliveryRules - - return &deliveryPolicy -} - -func expandArmCdnEndpointDeliveryPolicyRule(rule map[string]interface{}) cdn.DeliveryRule { - deliveryRule := cdn.DeliveryRule{ - Name: utils.String(rule["name"].(string)), - Order: utils.Int32(rule["order"].(int32)), - } - - conditions := make([]cdn.BasicDeliveryRuleCondition, 0) - - if rsc, ok := rule["request_scheme_condition"]; ok { - conditions = append(conditions, *expandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) - } - - deliveryRule.Conditions = &conditions - - actions := make([]cdn.BasicDeliveryRuleAction, 0) - - if ura, ok := rule["url_redirect_action"]; ok { - actions = append(actions, *expandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) - } - - deliveryRule.Actions = &actions - - return deliveryRule -} - -func expandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { - requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ - Name: cdn.NameRequestScheme, - } - - matchValues := rsc["match_values"].([]string) - params := cdn.RequestSchemeMatchConditionParameters{ - MatchValues: &matchValues, - } - - if operator, ok := rsc["operator"]; ok { - params.Operator = utils.String(operator.(string)) - } - - if negate, ok := rsc["negate_condition"]; ok { - params.NegateCondition = utils.Bool(negate.(bool)) - } - - requestSchemeCondition.Parameters = ¶ms - - return &requestSchemeCondition -} - -func expandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { - urlRedirectAction := cdn.URLRedirectAction{ - Name: cdn.NameURLRedirect, - } - - params := cdn.URLRedirectActionParameters{ - RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), - } - - if destProt, ok := ura["destination_protocol"]; ok { - params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) - } - - if hostname, ok := ura["hostname"]; ok { - params.CustomHostname = utils.String(hostname.(string)) - } - - if path, ok := ura["path"]; ok { - params.CustomPath = utils.String(path.(string)) - } - - if queryString, ok := ura["query_string"]; ok { - params.CustomQueryString = utils.String(queryString.(string)) - } - - if fragment, ok := ura["fragment"]; ok { - params.CustomFragment = utils.String(fragment.(string)) - } - - urlRedirectAction.Parameters = ¶ms - - return &urlRedirectAction -} diff --git a/azurerm/internal/services/cdn/rule_action_url_redirect.go b/azurerm/internal/services/cdn/rule_action_url_redirect.go deleted file mode 100644 index 38b2f163426d..000000000000 --- a/azurerm/internal/services/cdn/rule_action_url_redirect.go +++ /dev/null @@ -1,58 +0,0 @@ -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" -) - -func RuleActionUrlRedirect() *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), - }, - - "destination_protocol": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validation.StringInSlice([]string{ - string(cdn.MatchRequest), - string(cdn.HTTP), - string(cdn.HTTPS), - }, false), - }, - - "hostname": { - Type: schema.TypeString, - Required: false, - }, - - "path": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validate.RuleActionUrlRedirectPath(), - }, - - "query_string": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validate.RuleActionUrlRedirectPath(), - }, - - "fragment": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validate.RuleActionUrlRedirectFragment(), - }, - }, - } -} diff --git a/azurerm/internal/services/cdn/rule_condition_request_scheme.go b/azurerm/internal/services/cdn/rule_condition_request_scheme.go deleted file mode 100644 index e6db5bea7a3c..000000000000 --- a/azurerm/internal/services/cdn/rule_condition_request_scheme.go +++ /dev/null @@ -1,38 +0,0 @@ -package cdn - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" -) - -func RuleConditionRequestScheme() *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.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - ValidateFunc: validation.StringInSlice([]string{ - "HTTP", - "HTTPS", - }, false), - }, - }, - } -} From 81ae83b0563bbd6c3e10e49b3edb72cf75813f43 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 15:09:53 +0100 Subject: [PATCH 08/92] fix basic issues in order to run `terraform plan` --- .../services/cdn/delivery_rule_actions/url_redirect.go | 10 +++++----- .../cdn/delivery_rule_conditions/request_scheme.go | 8 +++----- .../internal/services/cdn/endpont_delivery_policy.go | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go index e88b6e538c68..4572d3d053f2 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -24,7 +24,7 @@ func RuleActionUrlRedirect() *schema.Resource { "protocol": { Type: schema.TypeString, - Required: false, + Optional: true, Default: string(cdn.MatchRequest), ValidateFunc: validation.StringInSlice([]string{ string(cdn.MatchRequest), @@ -35,24 +35,24 @@ func RuleActionUrlRedirect() *schema.Resource { "hostname": { Type: schema.TypeString, - Required: false, + Optional: true, }, "path": { Type: schema.TypeString, - Required: false, + Optional: true, ValidateFunc: validate.RuleActionUrlRedirectPath(), }, "query_string": { Type: schema.TypeString, - Required: false, + Optional: true, ValidateFunc: validate.RuleActionUrlRedirectPath(), }, "fragment": { Type: schema.TypeString, - Required: false, + Optional: true, ValidateFunc: validate.RuleActionUrlRedirectFragment(), }, }, diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index bc9863110510..8ebb7ebbf9a5 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -25,11 +25,9 @@ func RuleConditionRequestScheme() *schema.Resource { Default: false, }, - "match_values": { - Type: schema.TypeList, + "match_value": { + Type: schema.TypeString, Required: true, - MinItems: 1, - MaxItems: 1, ValidateFunc: validation.StringInSlice([]string{ "HTTP", "HTTPS", @@ -44,7 +42,7 @@ func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn Name: cdn.NameRequestScheme, } - matchValues := rsc["match_values"].([]string) + matchValues := []string{rsc["match_value"].(string)} params := cdn.RequestSchemeMatchConditionParameters{ MatchValues: &matchValues, } diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index 333b7c96883e..5e34bbefb666 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -9,13 +9,13 @@ import ( func EndpointDeliveryPolicy() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, - Required: false, + Optional: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "description": { Type: schema.TypeString, - Required: false, + Optional: true, }, "rule": { From 97e22675e3b07b32a0cc3e368fc72dfd3d9dc83e Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 17:04:20 +0100 Subject: [PATCH 09/92] fix problems in order to apply correctly --- .../cdn/delivery_rule_actions/url_redirect.go | 11 ++++++----- .../cdn/delivery_rule_conditions/request_scheme.go | 10 +++++----- .../internal/services/cdn/endpoint_delivery_rule.go | 7 ++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go index 4572d3d053f2..c2ac0f7fe338 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -65,26 +65,27 @@ func ExpandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLR } params := cdn.URLRedirectActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRedirectActionParameters"), RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), } - if destProt, ok := ura["protocol"]; ok { + if destProt := ura["protocol"]; destProt.(string) != "" { params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) } - if hostname, ok := ura["hostname"]; ok { + if hostname := ura["hostname"]; hostname.(string) != "" { params.CustomHostname = utils.String(hostname.(string)) } - if path, ok := ura["path"]; ok { + if path := ura["path"]; path.(string) != "" { params.CustomPath = utils.String(path.(string)) } - if queryString, ok := ura["query_string"]; ok { + if queryString := ura["query_string"]; queryString.(string) != "" { params.CustomQueryString = utils.String(queryString.(string)) } - if fragment, ok := ura["fragment"]; ok { + if fragment := ura["fragment"]; fragment.(string) != "" { params.CustomFragment = utils.String(fragment.(string)) } diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index 8ebb7ebbf9a5..5573ff485f00 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -44,16 +44,16 @@ func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn matchValues := []string{rsc["match_value"].(string)} params := cdn.RequestSchemeMatchConditionParameters{ - MatchValues: &matchValues, + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), + MatchValues: &matchValues, + NegateCondition: utils.Bool(rsc["negate_condition"].(bool)), } - if operator, ok := rsc["operator"]; ok { + if operator := rsc["operator"]; operator.(string) != "" { params.Operator = utils.String(operator.(string)) } - if negate, ok := rsc["negate_condition"]; ok { - params.NegateCondition = utils.Bool(negate.(bool)) - } + params.NegateCondition = utils.Bool(rsc["negate_condition"].(bool)) requestSchemeCondition.Parameters = ¶ms diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 89f861dec5bb..fdf4dc24d33f 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -45,12 +45,12 @@ func EndpointDeliveryRule() *schema.Resource { func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryRule { deliveryRule := cdn.DeliveryRule{ Name: utils.String(rule["name"].(string)), - Order: utils.Int32(rule["order"].(int32)), + Order: utils.Int32(int32(rule["order"].(int))), } conditions := make([]cdn.BasicDeliveryRuleCondition, 0) - if rsc, ok := rule["request_scheme_condition"]; ok { + if rsc := rule["request_scheme_condition"]; len(rsc.([]interface{})) > 0 { conditions = append(conditions, *delivery_rule_conditions.ExpandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) } @@ -58,7 +58,7 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryR actions := make([]cdn.BasicDeliveryRuleAction, 0) - if ura, ok := rule["url_redirect_action"]; ok { + if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) } @@ -95,6 +95,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin for _, basicDeliveryRuleAction := range *deliveryRule.Actions { if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { res["url_redirect_action"] = delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action) + continue } } } From bff24d2767464257e6b5ab57e22c0c8c4f29361f Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 17:47:59 +0100 Subject: [PATCH 10/92] fix rename of match_values to match_value; rename endpoint_delivery_policy.go --- .../services/cdn/delivery_rule_conditions/request_scheme.go | 4 ++-- ...endpont_delivery_policy.go => endpoint_delivery_policy.go} | 3 +++ azurerm/internal/services/cdn/endpoint_delivery_rule.go | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) rename azurerm/internal/services/cdn/{endpont_delivery_policy.go => endpoint_delivery_policy.go} (96%) diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index 5573ff485f00..f51bafaafbc2 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -72,8 +72,8 @@ func FlattenArmCdnEndpointConditionRequestScheme(condition *cdn.DeliveryRuleRequ res["negate_condition"] = *params.NegateCondition } - if params.MatchValues != nil { - res["match_values"] = *params.MatchValues + if params.MatchValues != nil && len(*params.MatchValues) > 0 { + res["match_value"] = (*params.MatchValues)[0] } } diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpoint_delivery_policy.go similarity index 96% rename from azurerm/internal/services/cdn/endpont_delivery_policy.go rename to azurerm/internal/services/cdn/endpoint_delivery_policy.go index 5e34bbefb666..2163ce66b9e9 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_policy.go @@ -70,7 +70,10 @@ func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesU for i, rule := range *deliveryPolicy.Rules { rules[i] = flattenArmCdnEndpointDeliveryRule(&rule) } + dp["rule"] = rules } + deliveryPolicies = append(deliveryPolicies, dp) + return deliveryPolicies } diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index fdf4dc24d33f..5982807f6946 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -85,7 +85,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Conditions != nil { for _, basicDeliveryRuleCondition := range *deliveryRule.Conditions { if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { - res["request_scheme_condition"] = delivery_rule_conditions.FlattenArmCdnEndpointConditionRequestScheme(condition) + res["request_scheme_condition"] = []interface{}{delivery_rule_conditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue } } @@ -94,7 +94,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Actions != nil { for _, basicDeliveryRuleAction := range *deliveryRule.Actions { if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { - res["url_redirect_action"] = delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action) + res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } } From a87c141b456bac15c7f5f142fc419caf50df7b58 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:10:25 +0100 Subject: [PATCH 11/92] add method to test cache expiration duration --- azurerm/helpers/validate/cdn.go | 7 ++++ azurerm/helpers/validate/cdn_test.go | 57 ++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index 9c733d807a47..015199845596 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -54,3 +54,10 @@ func RuleActionUrlRedirectFragment() schema.SchemaValidateFunc { "The Url Redirect Path must start with a slash.", ) } + +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.", + ) +} diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go index aded6923d74f..b98b64ab37e6 100644 --- a/azurerm/helpers/validate/cdn_test.go +++ b/azurerm/helpers/validate/cdn_test.go @@ -84,7 +84,7 @@ func TestRuleActionUrlRedirectPath(t *testing.T) { for _, tc := range cases { t.Run(tc.Path, func(t *testing.T) { - _, errors := RuleActionUrlRedirectPath()(tc.Path, "name") + _, errors := RuleActionUrlRedirectPath()(tc.Path, "path") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { @@ -135,7 +135,7 @@ func TestRuleActionUrlRedirectQueryString(t *testing.T) { for _, tc := range cases { t.Run(tc.QueryString, func(t *testing.T) { - _, errors := RuleActionUrlRedirectQueryString()(tc.QueryString, "name") + _, errors := RuleActionUrlRedirectQueryString()(tc.QueryString, "query_string") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { @@ -178,7 +178,7 @@ func TestRuleActionUrlRedirectFragment(t *testing.T) { for _, tc := range cases { t.Run(tc.Fragment, func(t *testing.T) { - _, errors := RuleActionUrlRedirectFragment()(tc.Fragment, "name") + _, errors := RuleActionUrlRedirectFragment()(tc.Fragment, "fragment") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { @@ -191,3 +191,54 @@ func TestRuleActionUrlRedirectFragment(t *testing.T) { }) } } + +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)) + } + }) + } +} From f4aab9773a0962104fe59679ceece43c43a94f06 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:11:17 +0100 Subject: [PATCH 12/92] shorten names of conditions and actions --- .../services/cdn/delivery_rule_actions/url_redirect.go | 2 +- .../services/cdn/delivery_rule_conditions/request_scheme.go | 2 +- azurerm/internal/services/cdn/endpoint_delivery_rule.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go index c2ac0f7fe338..9a8551ec8d3b 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -8,7 +8,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func RuleActionUrlRedirect() *schema.Resource { +func URLRedirect() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "redirect_type": { diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index f51bafaafbc2..920175fa2fe5 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -7,7 +7,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func RuleConditionRequestScheme() *schema.Resource { +func RequestScheme() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "operator": { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 5982807f6946..43bc4da95c36 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -29,14 +29,14 @@ func EndpointDeliveryRule() *schema.Resource { Type: schema.TypeList, Optional: true, MaxItems: 1, - Elem: delivery_rule_conditions.RuleConditionRequestScheme(), + Elem: delivery_rule_conditions.RequestScheme(), }, "url_redirect_action": { Type: schema.TypeList, Optional: true, MaxItems: 1, - Elem: delivery_rule_actions.RuleActionUrlRedirect(), + Elem: delivery_rule_actions.URLRedirect(), }, }, } From 9fe50e741cf715459f40c5fb41c9440ee0e36451 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:21:29 +0100 Subject: [PATCH 13/92] add cache expiration action --- .../delivery_rule_actions/cache_expiration.go | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go new file mode 100644 index 000000000000..c9b8f1ba08cc --- /dev/null +++ b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go @@ -0,0 +1,62 @@ +package delivery_rule_actions + +import ( + "github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/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(cea map[string]interface{}) *cdn.DeliveryRuleCacheExpirationAction { + cacheExpirationAction := cdn.DeliveryRuleCacheExpirationAction{ + Name: cdn.NameCacheExpiration, + Parameters: &cdn.CacheExpirationActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters"), + CacheBehavior: cdn.CacheBehavior(cea["behavior"].(string)), + CacheType: utils.String("All"), + }, + } + + if duration := cea["duration"].(string); duration != "" { + cacheExpirationAction.Parameters.CacheDuration = utils.String(duration) + } + + return &cacheExpirationAction +} + +func FlattenArmCdnEndpointActionCacheExpiry(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := cea.Parameters; params != nil { + res["behavior"] = string(params.CacheBehavior) + + if params.CacheDuration != nil { + res["duration"] = *params.CacheDuration + } + } + + return res +} From 1082b3cb4d5ad5d397283169e8ed33407e2fe23f Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:24:34 +0100 Subject: [PATCH 14/92] add cache expiration action to delivery_rule --- .../delivery_rule_actions/cache_expiration.go | 2 +- .../services/cdn/endpoint_delivery_rule.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go index c9b8f1ba08cc..1fccf6a58826 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go @@ -47,7 +47,7 @@ func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) *cdn. return &cacheExpirationAction } -func FlattenArmCdnEndpointActionCacheExpiry(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { +func FlattenArmCdnEndpointActionCacheExpiration(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { res := make(map[string]interface{}, 1) if params := cea.Parameters; params != nil { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 43bc4da95c36..a74503832493 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -38,6 +38,13 @@ func EndpointDeliveryRule() *schema.Resource { MaxItems: 1, Elem: delivery_rule_actions.URLRedirect(), }, + + "cache_expiration_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.CacheExpiration(), + }, }, } } @@ -62,6 +69,10 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryR actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) } + if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { + actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{}))) + } + deliveryRule.Actions = &actions return deliveryRule @@ -97,6 +108,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } + + if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { + res["cache_expiration_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionCacheExpiration(action)} + continue + } } } From dd4b132e5863796da0d221184cefb1df54ed543b Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:43:17 +0100 Subject: [PATCH 15/92] fix not working build --- .../services/cdn/endpoint_delivery_rule.go | 8 +- .../profiles/latest/cdn/mgmt/cdn/models.go | 711 ++++++++++++++++++ vendor/modules.txt | 1 + 3 files changed, 716 insertions(+), 4 deletions(-) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index a74503832493..971d798618bc 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -104,13 +104,13 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Actions != nil { for _, basicDeliveryRuleAction := range *deliveryRule.Actions { - if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { - res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} + if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { + res["cache_expiration_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionCacheExpiration(action)} continue } - if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { - res["cache_expiration_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionCacheExpiration(action)} + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { + res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go b/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go new file mode 100644 index 000000000000..efa977211a2a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go @@ -0,0 +1,711 @@ +// +build go1.9 + +// Copyright 2020 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package cdn + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type CacheBehavior = original.CacheBehavior + +const ( + BypassCache CacheBehavior = original.BypassCache + Override CacheBehavior = original.Override + SetIfMissing CacheBehavior = original.SetIfMissing +) + +type CertificateSource = original.CertificateSource + +const ( + CertificateSourceAzureKeyVault CertificateSource = original.CertificateSourceAzureKeyVault + CertificateSourceCdn CertificateSource = original.CertificateSourceCdn + CertificateSourceCustomDomainHTTPSParameters CertificateSource = original.CertificateSourceCustomDomainHTTPSParameters +) + +type CertificateType = original.CertificateType + +const ( + Dedicated CertificateType = original.Dedicated + Shared CertificateType = original.Shared +) + +type CookiesOperator = original.CookiesOperator + +const ( + Any CookiesOperator = original.Any + BeginsWith CookiesOperator = original.BeginsWith + Contains CookiesOperator = original.Contains + EndsWith CookiesOperator = original.EndsWith + Equal CookiesOperator = original.Equal + GreaterThan CookiesOperator = original.GreaterThan + GreaterThanOrEqual CookiesOperator = original.GreaterThanOrEqual + LessThan CookiesOperator = original.LessThan + LessThanOrEqual CookiesOperator = original.LessThanOrEqual +) + +type CustomDomainResourceState = original.CustomDomainResourceState + +const ( + Active CustomDomainResourceState = original.Active + Creating CustomDomainResourceState = original.Creating + Deleting CustomDomainResourceState = original.Deleting +) + +type CustomHTTPSProvisioningState = original.CustomHTTPSProvisioningState + +const ( + Disabled CustomHTTPSProvisioningState = original.Disabled + Disabling CustomHTTPSProvisioningState = original.Disabling + Enabled CustomHTTPSProvisioningState = original.Enabled + Enabling CustomHTTPSProvisioningState = original.Enabling + Failed CustomHTTPSProvisioningState = original.Failed +) + +type CustomHTTPSProvisioningSubstate = original.CustomHTTPSProvisioningSubstate + +const ( + CertificateDeleted CustomHTTPSProvisioningSubstate = original.CertificateDeleted + CertificateDeployed CustomHTTPSProvisioningSubstate = original.CertificateDeployed + DeletingCertificate CustomHTTPSProvisioningSubstate = original.DeletingCertificate + DeployingCertificate CustomHTTPSProvisioningSubstate = original.DeployingCertificate + DomainControlValidationRequestApproved CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestApproved + DomainControlValidationRequestRejected CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestRejected + DomainControlValidationRequestTimedOut CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestTimedOut + IssuingCertificate CustomHTTPSProvisioningSubstate = original.IssuingCertificate + PendingDomainControlValidationREquestApproval CustomHTTPSProvisioningSubstate = original.PendingDomainControlValidationREquestApproval + SubmittingDomainControlValidationRequest CustomHTTPSProvisioningSubstate = original.SubmittingDomainControlValidationRequest +) + +type DestinationProtocol = original.DestinationProtocol + +const ( + HTTP DestinationProtocol = original.HTTP + HTTPS DestinationProtocol = original.HTTPS + MatchRequest DestinationProtocol = original.MatchRequest +) + +type EndpointResourceState = original.EndpointResourceState + +const ( + EndpointResourceStateCreating EndpointResourceState = original.EndpointResourceStateCreating + EndpointResourceStateDeleting EndpointResourceState = original.EndpointResourceStateDeleting + EndpointResourceStateRunning EndpointResourceState = original.EndpointResourceStateRunning + EndpointResourceStateStarting EndpointResourceState = original.EndpointResourceStateStarting + EndpointResourceStateStopped EndpointResourceState = original.EndpointResourceStateStopped + EndpointResourceStateStopping EndpointResourceState = original.EndpointResourceStateStopping +) + +type GeoFilterActions = original.GeoFilterActions + +const ( + Allow GeoFilterActions = original.Allow + Block GeoFilterActions = original.Block +) + +type HeaderAction = original.HeaderAction + +const ( + Append HeaderAction = original.Append + Delete HeaderAction = original.Delete + Overwrite HeaderAction = original.Overwrite +) + +type MinimumTLSVersion = original.MinimumTLSVersion + +const ( + None MinimumTLSVersion = original.None + TLS10 MinimumTLSVersion = original.TLS10 + TLS12 MinimumTLSVersion = original.TLS12 +) + +type Name = original.Name + +const ( + NameCookies Name = original.NameCookies + NameDeliveryRuleCondition Name = original.NameDeliveryRuleCondition + NameHTTPVersion Name = original.NameHTTPVersion + NameIsDevice Name = original.NameIsDevice + NamePostArgs Name = original.NamePostArgs + NameQueryString Name = original.NameQueryString + NameRemoteAddress Name = original.NameRemoteAddress + NameRequestBody Name = original.NameRequestBody + NameRequestHeader Name = original.NameRequestHeader + NameRequestMethod Name = original.NameRequestMethod + NameRequestScheme Name = original.NameRequestScheme + NameRequestURI Name = original.NameRequestURI + NameURLFileExtension Name = original.NameURLFileExtension + NameURLFileName Name = original.NameURLFileName + NameURLPath Name = original.NameURLPath +) + +type NameBasicDeliveryRuleAction = original.NameBasicDeliveryRuleAction + +const ( + NameCacheExpiration NameBasicDeliveryRuleAction = original.NameCacheExpiration + NameCacheKeyQueryString NameBasicDeliveryRuleAction = original.NameCacheKeyQueryString + NameDeliveryRuleAction NameBasicDeliveryRuleAction = original.NameDeliveryRuleAction + NameModifyRequestHeader NameBasicDeliveryRuleAction = original.NameModifyRequestHeader + NameModifyResponseHeader NameBasicDeliveryRuleAction = original.NameModifyResponseHeader + NameURLRedirect NameBasicDeliveryRuleAction = original.NameURLRedirect + NameURLRewrite NameBasicDeliveryRuleAction = original.NameURLRewrite +) + +type OptimizationType = original.OptimizationType + +const ( + DynamicSiteAcceleration OptimizationType = original.DynamicSiteAcceleration + GeneralMediaStreaming OptimizationType = original.GeneralMediaStreaming + GeneralWebDelivery OptimizationType = original.GeneralWebDelivery + LargeFileDownload OptimizationType = original.LargeFileDownload + VideoOnDemandMediaStreaming OptimizationType = original.VideoOnDemandMediaStreaming +) + +type OriginResourceState = original.OriginResourceState + +const ( + OriginResourceStateActive OriginResourceState = original.OriginResourceStateActive + OriginResourceStateCreating OriginResourceState = original.OriginResourceStateCreating + OriginResourceStateDeleting OriginResourceState = original.OriginResourceStateDeleting +) + +type PostArgsOperator = original.PostArgsOperator + +const ( + PostArgsOperatorAny PostArgsOperator = original.PostArgsOperatorAny + PostArgsOperatorBeginsWith PostArgsOperator = original.PostArgsOperatorBeginsWith + PostArgsOperatorContains PostArgsOperator = original.PostArgsOperatorContains + PostArgsOperatorEndsWith PostArgsOperator = original.PostArgsOperatorEndsWith + PostArgsOperatorEqual PostArgsOperator = original.PostArgsOperatorEqual + PostArgsOperatorGreaterThan PostArgsOperator = original.PostArgsOperatorGreaterThan + PostArgsOperatorGreaterThanOrEqual PostArgsOperator = original.PostArgsOperatorGreaterThanOrEqual + PostArgsOperatorLessThan PostArgsOperator = original.PostArgsOperatorLessThan + PostArgsOperatorLessThanOrEqual PostArgsOperator = original.PostArgsOperatorLessThanOrEqual +) + +type ProfileResourceState = original.ProfileResourceState + +const ( + ProfileResourceStateActive ProfileResourceState = original.ProfileResourceStateActive + ProfileResourceStateCreating ProfileResourceState = original.ProfileResourceStateCreating + ProfileResourceStateDeleting ProfileResourceState = original.ProfileResourceStateDeleting + ProfileResourceStateDisabled ProfileResourceState = original.ProfileResourceStateDisabled +) + +type ProtocolType = original.ProtocolType + +const ( + IPBased ProtocolType = original.IPBased + ServerNameIndication ProtocolType = original.ServerNameIndication +) + +type QueryStringBehavior = original.QueryStringBehavior + +const ( + Exclude QueryStringBehavior = original.Exclude + ExcludeAll QueryStringBehavior = original.ExcludeAll + Include QueryStringBehavior = original.Include + IncludeAll QueryStringBehavior = original.IncludeAll +) + +type QueryStringCachingBehavior = original.QueryStringCachingBehavior + +const ( + BypassCaching QueryStringCachingBehavior = original.BypassCaching + IgnoreQueryString QueryStringCachingBehavior = original.IgnoreQueryString + NotSet QueryStringCachingBehavior = original.NotSet + UseQueryString QueryStringCachingBehavior = original.UseQueryString +) + +type QueryStringOperator = original.QueryStringOperator + +const ( + QueryStringOperatorAny QueryStringOperator = original.QueryStringOperatorAny + QueryStringOperatorBeginsWith QueryStringOperator = original.QueryStringOperatorBeginsWith + QueryStringOperatorContains QueryStringOperator = original.QueryStringOperatorContains + QueryStringOperatorEndsWith QueryStringOperator = original.QueryStringOperatorEndsWith + QueryStringOperatorEqual QueryStringOperator = original.QueryStringOperatorEqual + QueryStringOperatorGreaterThan QueryStringOperator = original.QueryStringOperatorGreaterThan + QueryStringOperatorGreaterThanOrEqual QueryStringOperator = original.QueryStringOperatorGreaterThanOrEqual + QueryStringOperatorLessThan QueryStringOperator = original.QueryStringOperatorLessThan + QueryStringOperatorLessThanOrEqual QueryStringOperator = original.QueryStringOperatorLessThanOrEqual +) + +type RedirectType = original.RedirectType + +const ( + Found RedirectType = original.Found + Moved RedirectType = original.Moved + PermanentRedirect RedirectType = original.PermanentRedirect + TemporaryRedirect RedirectType = original.TemporaryRedirect +) + +type RemoteAddressOperator = original.RemoteAddressOperator + +const ( + RemoteAddressOperatorAny RemoteAddressOperator = original.RemoteAddressOperatorAny + RemoteAddressOperatorGeoMatch RemoteAddressOperator = original.RemoteAddressOperatorGeoMatch + RemoteAddressOperatorIPMatch RemoteAddressOperator = original.RemoteAddressOperatorIPMatch +) + +type RequestBodyOperator = original.RequestBodyOperator + +const ( + RequestBodyOperatorAny RequestBodyOperator = original.RequestBodyOperatorAny + RequestBodyOperatorBeginsWith RequestBodyOperator = original.RequestBodyOperatorBeginsWith + RequestBodyOperatorContains RequestBodyOperator = original.RequestBodyOperatorContains + RequestBodyOperatorEndsWith RequestBodyOperator = original.RequestBodyOperatorEndsWith + RequestBodyOperatorEqual RequestBodyOperator = original.RequestBodyOperatorEqual + RequestBodyOperatorGreaterThan RequestBodyOperator = original.RequestBodyOperatorGreaterThan + RequestBodyOperatorGreaterThanOrEqual RequestBodyOperator = original.RequestBodyOperatorGreaterThanOrEqual + RequestBodyOperatorLessThan RequestBodyOperator = original.RequestBodyOperatorLessThan + RequestBodyOperatorLessThanOrEqual RequestBodyOperator = original.RequestBodyOperatorLessThanOrEqual +) + +type RequestHeaderOperator = original.RequestHeaderOperator + +const ( + RequestHeaderOperatorAny RequestHeaderOperator = original.RequestHeaderOperatorAny + RequestHeaderOperatorBeginsWith RequestHeaderOperator = original.RequestHeaderOperatorBeginsWith + RequestHeaderOperatorContains RequestHeaderOperator = original.RequestHeaderOperatorContains + RequestHeaderOperatorEndsWith RequestHeaderOperator = original.RequestHeaderOperatorEndsWith + RequestHeaderOperatorEqual RequestHeaderOperator = original.RequestHeaderOperatorEqual + RequestHeaderOperatorGreaterThan RequestHeaderOperator = original.RequestHeaderOperatorGreaterThan + RequestHeaderOperatorGreaterThanOrEqual RequestHeaderOperator = original.RequestHeaderOperatorGreaterThanOrEqual + RequestHeaderOperatorLessThan RequestHeaderOperator = original.RequestHeaderOperatorLessThan + RequestHeaderOperatorLessThanOrEqual RequestHeaderOperator = original.RequestHeaderOperatorLessThanOrEqual +) + +type RequestURIOperator = original.RequestURIOperator + +const ( + RequestURIOperatorAny RequestURIOperator = original.RequestURIOperatorAny + RequestURIOperatorBeginsWith RequestURIOperator = original.RequestURIOperatorBeginsWith + RequestURIOperatorContains RequestURIOperator = original.RequestURIOperatorContains + RequestURIOperatorEndsWith RequestURIOperator = original.RequestURIOperatorEndsWith + RequestURIOperatorEqual RequestURIOperator = original.RequestURIOperatorEqual + RequestURIOperatorGreaterThan RequestURIOperator = original.RequestURIOperatorGreaterThan + RequestURIOperatorGreaterThanOrEqual RequestURIOperator = original.RequestURIOperatorGreaterThanOrEqual + RequestURIOperatorLessThan RequestURIOperator = original.RequestURIOperatorLessThan + RequestURIOperatorLessThanOrEqual RequestURIOperator = original.RequestURIOperatorLessThanOrEqual +) + +type ResourceType = original.ResourceType + +const ( + MicrosoftCdnProfilesEndpoints ResourceType = original.MicrosoftCdnProfilesEndpoints +) + +type SkuName = original.SkuName + +const ( + CustomVerizon SkuName = original.CustomVerizon + PremiumChinaCdn SkuName = original.PremiumChinaCdn + PremiumVerizon SkuName = original.PremiumVerizon + StandardAkamai SkuName = original.StandardAkamai + StandardChinaCdn SkuName = original.StandardChinaCdn + StandardMicrosoft SkuName = original.StandardMicrosoft + StandardVerizon SkuName = original.StandardVerizon +) + +type Transform = original.Transform + +const ( + Lowercase Transform = original.Lowercase + Uppercase Transform = original.Uppercase +) + +type URLFileExtensionOperator = original.URLFileExtensionOperator + +const ( + URLFileExtensionOperatorAny URLFileExtensionOperator = original.URLFileExtensionOperatorAny + URLFileExtensionOperatorBeginsWith URLFileExtensionOperator = original.URLFileExtensionOperatorBeginsWith + URLFileExtensionOperatorContains URLFileExtensionOperator = original.URLFileExtensionOperatorContains + URLFileExtensionOperatorEndsWith URLFileExtensionOperator = original.URLFileExtensionOperatorEndsWith + URLFileExtensionOperatorEqual URLFileExtensionOperator = original.URLFileExtensionOperatorEqual + URLFileExtensionOperatorGreaterThan URLFileExtensionOperator = original.URLFileExtensionOperatorGreaterThan + URLFileExtensionOperatorGreaterThanOrEqual URLFileExtensionOperator = original.URLFileExtensionOperatorGreaterThanOrEqual + URLFileExtensionOperatorLessThan URLFileExtensionOperator = original.URLFileExtensionOperatorLessThan + URLFileExtensionOperatorLessThanOrEqual URLFileExtensionOperator = original.URLFileExtensionOperatorLessThanOrEqual +) + +type URLFileNameOperator = original.URLFileNameOperator + +const ( + URLFileNameOperatorAny URLFileNameOperator = original.URLFileNameOperatorAny + URLFileNameOperatorBeginsWith URLFileNameOperator = original.URLFileNameOperatorBeginsWith + URLFileNameOperatorContains URLFileNameOperator = original.URLFileNameOperatorContains + URLFileNameOperatorEndsWith URLFileNameOperator = original.URLFileNameOperatorEndsWith + URLFileNameOperatorEqual URLFileNameOperator = original.URLFileNameOperatorEqual + URLFileNameOperatorGreaterThan URLFileNameOperator = original.URLFileNameOperatorGreaterThan + URLFileNameOperatorGreaterThanOrEqual URLFileNameOperator = original.URLFileNameOperatorGreaterThanOrEqual + URLFileNameOperatorLessThan URLFileNameOperator = original.URLFileNameOperatorLessThan + URLFileNameOperatorLessThanOrEqual URLFileNameOperator = original.URLFileNameOperatorLessThanOrEqual +) + +type URLPathOperator = original.URLPathOperator + +const ( + URLPathOperatorAny URLPathOperator = original.URLPathOperatorAny + URLPathOperatorBeginsWith URLPathOperator = original.URLPathOperatorBeginsWith + URLPathOperatorContains URLPathOperator = original.URLPathOperatorContains + URLPathOperatorEndsWith URLPathOperator = original.URLPathOperatorEndsWith + URLPathOperatorEqual URLPathOperator = original.URLPathOperatorEqual + URLPathOperatorGreaterThan URLPathOperator = original.URLPathOperatorGreaterThan + URLPathOperatorGreaterThanOrEqual URLPathOperator = original.URLPathOperatorGreaterThanOrEqual + URLPathOperatorLessThan URLPathOperator = original.URLPathOperatorLessThan + URLPathOperatorLessThanOrEqual URLPathOperator = original.URLPathOperatorLessThanOrEqual + URLPathOperatorWildcard URLPathOperator = original.URLPathOperatorWildcard +) + +type BaseClient = original.BaseClient +type BasicCustomDomainHTTPSParameters = original.BasicCustomDomainHTTPSParameters +type BasicDeliveryRuleAction = original.BasicDeliveryRuleAction +type BasicDeliveryRuleCondition = original.BasicDeliveryRuleCondition +type CacheExpirationActionParameters = original.CacheExpirationActionParameters +type CacheKeyQueryStringActionParameters = original.CacheKeyQueryStringActionParameters +type CertificateSourceParameters = original.CertificateSourceParameters +type CheckNameAvailabilityInput = original.CheckNameAvailabilityInput +type CheckNameAvailabilityOutput = original.CheckNameAvailabilityOutput +type CidrIPAddress = original.CidrIPAddress +type CookiesMatchConditionParameters = original.CookiesMatchConditionParameters +type CustomDomain = original.CustomDomain +type CustomDomainHTTPSParameters = original.CustomDomainHTTPSParameters +type CustomDomainListResult = original.CustomDomainListResult +type CustomDomainListResultIterator = original.CustomDomainListResultIterator +type CustomDomainListResultPage = original.CustomDomainListResultPage +type CustomDomainParameters = original.CustomDomainParameters +type CustomDomainProperties = original.CustomDomainProperties +type CustomDomainPropertiesParameters = original.CustomDomainPropertiesParameters +type CustomDomainsClient = original.CustomDomainsClient +type CustomDomainsCreateFuture = original.CustomDomainsCreateFuture +type CustomDomainsDeleteFuture = original.CustomDomainsDeleteFuture +type DeepCreatedOrigin = original.DeepCreatedOrigin +type DeepCreatedOriginProperties = original.DeepCreatedOriginProperties +type DeliveryRule = original.DeliveryRule +type DeliveryRuleAction = original.DeliveryRuleAction +type DeliveryRuleCacheExpirationAction = original.DeliveryRuleCacheExpirationAction +type DeliveryRuleCacheKeyQueryStringAction = original.DeliveryRuleCacheKeyQueryStringAction +type DeliveryRuleCondition = original.DeliveryRuleCondition +type DeliveryRuleCookiesCondition = original.DeliveryRuleCookiesCondition +type DeliveryRuleHTTPVersionCondition = original.DeliveryRuleHTTPVersionCondition +type DeliveryRuleIsDeviceCondition = original.DeliveryRuleIsDeviceCondition +type DeliveryRulePostArgsCondition = original.DeliveryRulePostArgsCondition +type DeliveryRuleQueryStringCondition = original.DeliveryRuleQueryStringCondition +type DeliveryRuleRemoteAddressCondition = original.DeliveryRuleRemoteAddressCondition +type DeliveryRuleRequestBodyCondition = original.DeliveryRuleRequestBodyCondition +type DeliveryRuleRequestHeaderAction = original.DeliveryRuleRequestHeaderAction +type DeliveryRuleRequestHeaderCondition = original.DeliveryRuleRequestHeaderCondition +type DeliveryRuleRequestMethodCondition = original.DeliveryRuleRequestMethodCondition +type DeliveryRuleRequestSchemeCondition = original.DeliveryRuleRequestSchemeCondition +type DeliveryRuleRequestURICondition = original.DeliveryRuleRequestURICondition +type DeliveryRuleResponseHeaderAction = original.DeliveryRuleResponseHeaderAction +type DeliveryRuleURLFileExtensionCondition = original.DeliveryRuleURLFileExtensionCondition +type DeliveryRuleURLFileNameCondition = original.DeliveryRuleURLFileNameCondition +type DeliveryRuleURLPathCondition = original.DeliveryRuleURLPathCondition +type EdgeNode = original.EdgeNode +type EdgeNodeProperties = original.EdgeNodeProperties +type EdgeNodesClient = original.EdgeNodesClient +type EdgenodeResult = original.EdgenodeResult +type EdgenodeResultIterator = original.EdgenodeResultIterator +type EdgenodeResultPage = original.EdgenodeResultPage +type Endpoint = original.Endpoint +type EndpointListResult = original.EndpointListResult +type EndpointListResultIterator = original.EndpointListResultIterator +type EndpointListResultPage = original.EndpointListResultPage +type EndpointProperties = original.EndpointProperties +type EndpointPropertiesUpdateParameters = original.EndpointPropertiesUpdateParameters +type EndpointPropertiesUpdateParametersDeliveryPolicy = original.EndpointPropertiesUpdateParametersDeliveryPolicy +type EndpointUpdateParameters = original.EndpointUpdateParameters +type EndpointsClient = original.EndpointsClient +type EndpointsCreateFuture = original.EndpointsCreateFuture +type EndpointsDeleteFuture = original.EndpointsDeleteFuture +type EndpointsLoadContentFuture = original.EndpointsLoadContentFuture +type EndpointsPurgeContentFuture = original.EndpointsPurgeContentFuture +type EndpointsStartFuture = original.EndpointsStartFuture +type EndpointsStopFuture = original.EndpointsStopFuture +type EndpointsUpdateFuture = original.EndpointsUpdateFuture +type ErrorResponse = original.ErrorResponse +type GeoFilter = original.GeoFilter +type HTTPVersionMatchConditionParameters = original.HTTPVersionMatchConditionParameters +type HeaderActionParameters = original.HeaderActionParameters +type IPAddressGroup = original.IPAddressGroup +type IsDeviceMatchConditionParameters = original.IsDeviceMatchConditionParameters +type KeyVaultCertificateSourceParameters = original.KeyVaultCertificateSourceParameters +type LoadParameters = original.LoadParameters +type ManagedHTTPSParameters = original.ManagedHTTPSParameters +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationsClient = original.OperationsClient +type OperationsListResult = original.OperationsListResult +type OperationsListResultIterator = original.OperationsListResultIterator +type OperationsListResultPage = original.OperationsListResultPage +type Origin = original.Origin +type OriginListResult = original.OriginListResult +type OriginListResultIterator = original.OriginListResultIterator +type OriginListResultPage = original.OriginListResultPage +type OriginProperties = original.OriginProperties +type OriginPropertiesParameters = original.OriginPropertiesParameters +type OriginUpdateParameters = original.OriginUpdateParameters +type OriginsClient = original.OriginsClient +type OriginsUpdateFuture = original.OriginsUpdateFuture +type PostArgsMatchConditionParameters = original.PostArgsMatchConditionParameters +type Profile = original.Profile +type ProfileListResult = original.ProfileListResult +type ProfileListResultIterator = original.ProfileListResultIterator +type ProfileListResultPage = original.ProfileListResultPage +type ProfileProperties = original.ProfileProperties +type ProfileUpdateParameters = original.ProfileUpdateParameters +type ProfilesClient = original.ProfilesClient +type ProfilesCreateFuture = original.ProfilesCreateFuture +type ProfilesDeleteFuture = original.ProfilesDeleteFuture +type ProfilesUpdateFuture = original.ProfilesUpdateFuture +type ProxyResource = original.ProxyResource +type PurgeParameters = original.PurgeParameters +type QueryStringMatchConditionParameters = original.QueryStringMatchConditionParameters +type RemoteAddressMatchConditionParameters = original.RemoteAddressMatchConditionParameters +type RequestBodyMatchConditionParameters = original.RequestBodyMatchConditionParameters +type RequestHeaderMatchConditionParameters = original.RequestHeaderMatchConditionParameters +type RequestMethodMatchConditionParameters = original.RequestMethodMatchConditionParameters +type RequestSchemeMatchConditionParameters = original.RequestSchemeMatchConditionParameters +type RequestURIMatchConditionParameters = original.RequestURIMatchConditionParameters +type Resource = original.Resource +type ResourceUsage = original.ResourceUsage +type ResourceUsageClient = original.ResourceUsageClient +type ResourceUsageListResult = original.ResourceUsageListResult +type ResourceUsageListResultIterator = original.ResourceUsageListResultIterator +type ResourceUsageListResultPage = original.ResourceUsageListResultPage +type Sku = original.Sku +type SsoURI = original.SsoURI +type SupportedOptimizationTypesListResult = original.SupportedOptimizationTypesListResult +type TrackedResource = original.TrackedResource +type URLFileExtensionMatchConditionParameters = original.URLFileExtensionMatchConditionParameters +type URLFileNameMatchConditionParameters = original.URLFileNameMatchConditionParameters +type URLPathMatchConditionParameters = original.URLPathMatchConditionParameters +type URLRedirectAction = original.URLRedirectAction +type URLRedirectActionParameters = original.URLRedirectActionParameters +type URLRewriteAction = original.URLRewriteAction +type URLRewriteActionParameters = original.URLRewriteActionParameters +type UserManagedHTTPSParameters = original.UserManagedHTTPSParameters +type ValidateCustomDomainInput = original.ValidateCustomDomainInput +type ValidateCustomDomainOutput = original.ValidateCustomDomainOutput +type ValidateProbeInput = original.ValidateProbeInput +type ValidateProbeOutput = original.ValidateProbeOutput + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewCustomDomainListResultIterator(page CustomDomainListResultPage) CustomDomainListResultIterator { + return original.NewCustomDomainListResultIterator(page) +} +func NewCustomDomainListResultPage(getNextPage func(context.Context, CustomDomainListResult) (CustomDomainListResult, error)) CustomDomainListResultPage { + return original.NewCustomDomainListResultPage(getNextPage) +} +func NewCustomDomainsClient(subscriptionID string) CustomDomainsClient { + return original.NewCustomDomainsClient(subscriptionID) +} +func NewCustomDomainsClientWithBaseURI(baseURI string, subscriptionID string) CustomDomainsClient { + return original.NewCustomDomainsClientWithBaseURI(baseURI, subscriptionID) +} +func NewEdgeNodesClient(subscriptionID string) EdgeNodesClient { + return original.NewEdgeNodesClient(subscriptionID) +} +func NewEdgeNodesClientWithBaseURI(baseURI string, subscriptionID string) EdgeNodesClient { + return original.NewEdgeNodesClientWithBaseURI(baseURI, subscriptionID) +} +func NewEdgenodeResultIterator(page EdgenodeResultPage) EdgenodeResultIterator { + return original.NewEdgenodeResultIterator(page) +} +func NewEdgenodeResultPage(getNextPage func(context.Context, EdgenodeResult) (EdgenodeResult, error)) EdgenodeResultPage { + return original.NewEdgenodeResultPage(getNextPage) +} +func NewEndpointListResultIterator(page EndpointListResultPage) EndpointListResultIterator { + return original.NewEndpointListResultIterator(page) +} +func NewEndpointListResultPage(getNextPage func(context.Context, EndpointListResult) (EndpointListResult, error)) EndpointListResultPage { + return original.NewEndpointListResultPage(getNextPage) +} +func NewEndpointsClient(subscriptionID string) EndpointsClient { + return original.NewEndpointsClient(subscriptionID) +} +func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient { + return original.NewEndpointsClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationsListResultIterator(page OperationsListResultPage) OperationsListResultIterator { + return original.NewOperationsListResultIterator(page) +} +func NewOperationsListResultPage(getNextPage func(context.Context, OperationsListResult) (OperationsListResult, error)) OperationsListResultPage { + return original.NewOperationsListResultPage(getNextPage) +} +func NewOriginListResultIterator(page OriginListResultPage) OriginListResultIterator { + return original.NewOriginListResultIterator(page) +} +func NewOriginListResultPage(getNextPage func(context.Context, OriginListResult) (OriginListResult, error)) OriginListResultPage { + return original.NewOriginListResultPage(getNextPage) +} +func NewOriginsClient(subscriptionID string) OriginsClient { + return original.NewOriginsClient(subscriptionID) +} +func NewOriginsClientWithBaseURI(baseURI string, subscriptionID string) OriginsClient { + return original.NewOriginsClientWithBaseURI(baseURI, subscriptionID) +} +func NewProfileListResultIterator(page ProfileListResultPage) ProfileListResultIterator { + return original.NewProfileListResultIterator(page) +} +func NewProfileListResultPage(getNextPage func(context.Context, ProfileListResult) (ProfileListResult, error)) ProfileListResultPage { + return original.NewProfileListResultPage(getNextPage) +} +func NewProfilesClient(subscriptionID string) ProfilesClient { + return original.NewProfilesClient(subscriptionID) +} +func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) ProfilesClient { + return original.NewProfilesClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceUsageClient(subscriptionID string) ResourceUsageClient { + return original.NewResourceUsageClient(subscriptionID) +} +func NewResourceUsageClientWithBaseURI(baseURI string, subscriptionID string) ResourceUsageClient { + return original.NewResourceUsageClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceUsageListResultIterator(page ResourceUsageListResultPage) ResourceUsageListResultIterator { + return original.NewResourceUsageListResultIterator(page) +} +func NewResourceUsageListResultPage(getNextPage func(context.Context, ResourceUsageListResult) (ResourceUsageListResult, error)) ResourceUsageListResultPage { + return original.NewResourceUsageListResultPage(getNextPage) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleCacheBehaviorValues() []CacheBehavior { + return original.PossibleCacheBehaviorValues() +} +func PossibleCertificateSourceValues() []CertificateSource { + return original.PossibleCertificateSourceValues() +} +func PossibleCertificateTypeValues() []CertificateType { + return original.PossibleCertificateTypeValues() +} +func PossibleCookiesOperatorValues() []CookiesOperator { + return original.PossibleCookiesOperatorValues() +} +func PossibleCustomDomainResourceStateValues() []CustomDomainResourceState { + return original.PossibleCustomDomainResourceStateValues() +} +func PossibleCustomHTTPSProvisioningStateValues() []CustomHTTPSProvisioningState { + return original.PossibleCustomHTTPSProvisioningStateValues() +} +func PossibleCustomHTTPSProvisioningSubstateValues() []CustomHTTPSProvisioningSubstate { + return original.PossibleCustomHTTPSProvisioningSubstateValues() +} +func PossibleDestinationProtocolValues() []DestinationProtocol { + return original.PossibleDestinationProtocolValues() +} +func PossibleEndpointResourceStateValues() []EndpointResourceState { + return original.PossibleEndpointResourceStateValues() +} +func PossibleGeoFilterActionsValues() []GeoFilterActions { + return original.PossibleGeoFilterActionsValues() +} +func PossibleHeaderActionValues() []HeaderAction { + return original.PossibleHeaderActionValues() +} +func PossibleMinimumTLSVersionValues() []MinimumTLSVersion { + return original.PossibleMinimumTLSVersionValues() +} +func PossibleNameBasicDeliveryRuleActionValues() []NameBasicDeliveryRuleAction { + return original.PossibleNameBasicDeliveryRuleActionValues() +} +func PossibleNameValues() []Name { + return original.PossibleNameValues() +} +func PossibleOptimizationTypeValues() []OptimizationType { + return original.PossibleOptimizationTypeValues() +} +func PossibleOriginResourceStateValues() []OriginResourceState { + return original.PossibleOriginResourceStateValues() +} +func PossiblePostArgsOperatorValues() []PostArgsOperator { + return original.PossiblePostArgsOperatorValues() +} +func PossibleProfileResourceStateValues() []ProfileResourceState { + return original.PossibleProfileResourceStateValues() +} +func PossibleProtocolTypeValues() []ProtocolType { + return original.PossibleProtocolTypeValues() +} +func PossibleQueryStringBehaviorValues() []QueryStringBehavior { + return original.PossibleQueryStringBehaviorValues() +} +func PossibleQueryStringCachingBehaviorValues() []QueryStringCachingBehavior { + return original.PossibleQueryStringCachingBehaviorValues() +} +func PossibleQueryStringOperatorValues() []QueryStringOperator { + return original.PossibleQueryStringOperatorValues() +} +func PossibleRedirectTypeValues() []RedirectType { + return original.PossibleRedirectTypeValues() +} +func PossibleRemoteAddressOperatorValues() []RemoteAddressOperator { + return original.PossibleRemoteAddressOperatorValues() +} +func PossibleRequestBodyOperatorValues() []RequestBodyOperator { + return original.PossibleRequestBodyOperatorValues() +} +func PossibleRequestHeaderOperatorValues() []RequestHeaderOperator { + return original.PossibleRequestHeaderOperatorValues() +} +func PossibleRequestURIOperatorValues() []RequestURIOperator { + return original.PossibleRequestURIOperatorValues() +} +func PossibleResourceTypeValues() []ResourceType { + return original.PossibleResourceTypeValues() +} +func PossibleSkuNameValues() []SkuName { + return original.PossibleSkuNameValues() +} +func PossibleTransformValues() []Transform { + return original.PossibleTransformValues() +} +func PossibleURLFileExtensionOperatorValues() []URLFileExtensionOperator { + return original.PossibleURLFileExtensionOperatorValues() +} +func PossibleURLFileNameOperatorValues() []URLFileNameOperator { + return original.PossibleURLFileNameOperatorValues() +} +func PossibleURLPathOperatorValues() []URLPathOperator { + return original.PossibleURLPathOperatorValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/latest" +} +func Version() string { + return original.Version() +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6d5e095abeb9..f516d18c50f4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -8,6 +8,7 @@ cloud.google.com/go/internal/version cloud.google.com/go/storage # github.com/Azure/azure-sdk-for-go v38.1.0+incompatible github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources +github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn github.com/Azure/azure-sdk-for-go/services/analysisservices/mgmt/2017-08-01/analysisservices github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2018-01-01/apimanagement github.com/Azure/azure-sdk-for-go/services/appconfiguration/mgmt/2019-10-01/appconfiguration From da8e280b27bb9b2362edd2125fc62c86db295f3a Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 22:00:32 +0100 Subject: [PATCH 16/92] disable adding of duration when using BypassCache behavior --- .../cdn/delivery_rule_actions/cache_expiration.go | 10 ++++++++-- .../services/cdn/endpoint_delivery_policy.go | 12 ++++++++---- .../internal/services/cdn/endpoint_delivery_rule.go | 10 +++++++--- .../services/cdn/resource_arm_cdn_endpoint.go | 12 ++++++++++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go index 1fccf6a58826..8db750c39160 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go @@ -1,6 +1,8 @@ package delivery_rule_actions import ( + "fmt" + "github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -30,7 +32,7 @@ func CacheExpiration() *schema.Resource { } } -func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) *cdn.DeliveryRuleCacheExpirationAction { +func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) (*cdn.DeliveryRuleCacheExpirationAction, error) { cacheExpirationAction := cdn.DeliveryRuleCacheExpirationAction{ Name: cdn.NameCacheExpiration, Parameters: &cdn.CacheExpirationActionParameters{ @@ -41,10 +43,14 @@ func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) *cdn. } if duration := cea["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) } - return &cacheExpirationAction + return &cacheExpirationAction, nil } func FlattenArmCdnEndpointActionCacheExpiration(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy.go b/azurerm/internal/services/cdn/endpoint_delivery_policy.go index 2163ce66b9e9..387b3aa25875 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_policy.go @@ -30,10 +30,10 @@ func EndpointDeliveryPolicy() *schema.Schema { } } -func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { policies := d.Get("delivery_policy").([]interface{}) if len(policies) == 0 { - return nil + return nil, nil } deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} @@ -46,11 +46,15 @@ func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPro rules := policy["rule"].([]interface{}) deliveryRules := make([]cdn.DeliveryRule, len(rules)) for i, rule := range rules { - deliveryRules[i] = expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + delRule, err := expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + if err != nil { + return nil, err + } + deliveryRules[i] = *delRule } deliveryPolicy.Rules = &deliveryRules - return &deliveryPolicy + return &deliveryPolicy, nil } func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 971d798618bc..3e292bf54c2c 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -49,7 +49,7 @@ func EndpointDeliveryRule() *schema.Resource { } } -func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryRule { +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))), @@ -70,12 +70,16 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryR } if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { - actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{}))) + action, err := delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{})) + if err != nil { + return nil, err + } + actions = append(actions, *action) } deliveryRule.Actions = &actions - return deliveryRule + return &deliveryRule, nil } func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index 1ad6ad768024..e725509732c7 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -238,7 +238,6 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) - deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -246,6 +245,11 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error expanding `geo_filter`: %s", err) } + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + if err != nil { + return fmt.Errorf("Error expanding `delivery_policy`: %s", err) + } + endpoint := cdn.Endpoint{ Location: &location, EndpointProperties: &cdn.EndpointProperties{ @@ -317,7 +321,6 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) - deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -325,6 +328,11 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error expanding `geo_filter`: %s", err) } + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + if err != nil { + return fmt.Errorf("Error expanding `delivery_policy`: %s", err) + } + endpoint := cdn.EndpointUpdateParameters{ EndpointPropertiesUpdateParameters: &cdn.EndpointPropertiesUpdateParameters{ ContentTypesToCompress: &contentTypes, From c2349ed676d158fd508d5407cf1a46b7e97a68de Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 9 Mar 2020 21:32:13 +0100 Subject: [PATCH 17/92] remove obsolete policy layer; make removing of rules working as well --- .../services/cdn/endpoint_delivery_policy.go | 83 ------------------- .../services/cdn/endpoint_delivery_rule.go | 80 +++++++++--------- .../services/cdn/resource_arm_cdn_endpoint.go | 46 ++++++++-- 3 files changed, 83 insertions(+), 126 deletions(-) delete mode 100644 azurerm/internal/services/cdn/endpoint_delivery_policy.go diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy.go b/azurerm/internal/services/cdn/endpoint_delivery_policy.go deleted file mode 100644 index 387b3aa25875..000000000000 --- a/azurerm/internal/services/cdn/endpoint_delivery_policy.go +++ /dev/null @@ -1,83 +0,0 @@ -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/utils" -) - -func EndpointDeliveryPolicy() *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Optional: true, - }, - - "rule": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 4, - Elem: EndpointDeliveryRule(), - }, - }, - }, - } -} - -func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { - policies := d.Get("delivery_policy").([]interface{}) - if len(policies) == 0 { - return nil, nil - } - - deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} - - policy := policies[0].(map[string]interface{}) - if descr, ok := policy["description"]; ok { - deliveryPolicy.Description = utils.String(descr.(string)) - } - - rules := policy["rule"].([]interface{}) - deliveryRules := make([]cdn.DeliveryRule, len(rules)) - for i, rule := range rules { - delRule, err := expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) - if err != nil { - return nil, err - } - deliveryRules[i] = *delRule - } - deliveryPolicy.Rules = &deliveryRules - - return &deliveryPolicy, nil -} - -func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { - deliveryPolicies := make([]interface{}, 0) - - if deliveryPolicy == nil { - return deliveryPolicies - } - - dp := make(map[string]interface{}) - if deliveryPolicy.Description != nil { - dp["description"] = *deliveryPolicy.Description - } - - if deliveryPolicy.Rules != nil && len(*deliveryPolicy.Rules) > 0 { - rules := make([]map[string]interface{}, len(*deliveryPolicy.Rules)) - for i, rule := range *deliveryPolicy.Rules { - rules[i] = flattenArmCdnEndpointDeliveryRule(&rule) - } - dp["rule"] = rules - } - - deliveryPolicies = append(deliveryPolicies, dp) - - return deliveryPolicies -} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 3e292bf54c2c..fcf494884618 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -10,40 +10,44 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func EndpointDeliveryRule() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), - }, - - "order": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, - - "request_scheme_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: delivery_rule_conditions.RequestScheme(), - }, - - "url_redirect_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: delivery_rule_actions.URLRedirect(), - }, - - "cache_expiration_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: delivery_rule_actions.CacheExpiration(), +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.CdnEndpointDeliveryPolicyRuleName(), + }, + + "order": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "request_scheme_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_conditions.RequestScheme(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.URLRedirect(), + }, + + "cache_expiration_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.CacheExpiration(), + }, }, }, } @@ -65,10 +69,6 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver actions := make([]cdn.BasicDeliveryRuleAction, 0) - if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { - actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) - } - if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { action, err := delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{})) if err != nil { @@ -77,6 +77,10 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver actions = append(actions, *action) } + if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { + actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + } + deliveryRule.Actions = &actions return &deliveryRule, nil diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index e725509732c7..db44894802cb 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -197,7 +197,7 @@ func resourceArmCdnEndpoint() *schema.Resource { Computed: true, }, - "delivery_policy": EndpointDeliveryPolicy(), + "delivery_rule": EndpointDeliveryRule(), "tags": tags.Schema(), }, @@ -330,7 +330,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) if err != nil { - return fmt.Errorf("Error expanding `delivery_policy`: %s", err) + return fmt.Errorf("Error expanding `delivery_rule`: %s", err) } endpoint := cdn.EndpointUpdateParameters{ @@ -425,9 +425,9 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting `origin`: %+v", err) } - deliveryPolicy := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) - if err := d.Set("delivery_policy", deliveryPolicy); err != nil { - return fmt.Errorf("Error setting `delivery_policy`: %+v", err) + deliveryRules := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) + if err := d.Set("delivery_rule", deliveryRules); err != nil { + return fmt.Errorf("Error setting `delivery_rule`: %+v", err) } } @@ -603,3 +603,39 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface return results } + +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { + deliveryRules := make([]cdn.DeliveryRule, 0) + deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{ + Description: utils.String(""), + Rules: &deliveryRules, + } + + rules := d.Get("delivery_rule").([]interface{}) + if len(rules) == 0 { + return &deliveryPolicy, nil + } + + for _, rule := range rules { + delRule, err := expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + if err != nil { + return nil, err + } + deliveryRules = append(deliveryRules, *delRule) + } + + return &deliveryPolicy, nil +} + +func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { + if deliveryPolicy == nil { + return nil + } + + deliveryRules := make([]interface{}, len(*deliveryPolicy.Rules)) + for i, rule := range *deliveryPolicy.Rules { + deliveryRules[i] = flattenArmCdnEndpointDeliveryRule(&rule) + } + + return deliveryRules +} From bb9580c947d16a34524321f98aa22b3d85da41ee Mon Sep 17 00:00:00 2001 From: Marceline Abadeer Date: Sun, 8 Mar 2020 21:41:35 -0600 Subject: [PATCH 18/92] Updated virtual_hub.html.markdown (#6033) Fixed Usage definition: resource_group >> resource_group_name --- website/docs/d/virtual_hub.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/d/virtual_hub.html.markdown b/website/docs/d/virtual_hub.html.markdown index d4ed43d726d8..d0d73787ffb0 100644 --- a/website/docs/d/virtual_hub.html.markdown +++ b/website/docs/d/virtual_hub.html.markdown @@ -14,8 +14,8 @@ Uses this data source to access information about an existing Virtual Hub. ```hcl data "azurerm_virtual_hub" "example" { - name = "example-hub" - resource_group = "example-resources" + name = "example-hub" + resource_group_name = "example-resources" } output "virtual_hub_id" { From dd60c152c36c778b848716e0f753d03ddf3d32e1 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 20 Feb 2020 07:46:51 +0100 Subject: [PATCH 19/92] wip: adding a scaffolder for resources/data sources --- .../internal/tools/website-scaffold/main.go | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 azurerm/internal/tools/website-scaffold/main.go diff --git a/azurerm/internal/tools/website-scaffold/main.go b/azurerm/internal/tools/website-scaffold/main.go new file mode 100644 index 000000000000..b1b943bea8d9 --- /dev/null +++ b/azurerm/internal/tools/website-scaffold/main.go @@ -0,0 +1,73 @@ +package main + +import ( + "flag" + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/provider" +) + +func main() { + isResource := flag.Bool("resource", true, "True if this is a Resource, False if this is a Data Source") + resourceName := flag.String("name", "", "The name of the Data Source/Resource which should be generated") + flag.Parse() + + if err := run(*isResource, *resourceName); err != nil { + panic(err) + } +} + +func run(isResource bool, resourceName string) error { + if isResource { + return runForResource(resourceName) + } + + return runForDataSource(resourceName) +} + +func runForDataSource(resourceName string) error { + var dataSource *schema.Resource + + for _, service := range provider.SupportedServices() { + for key, ds := range service.SupportedDataSources() { + if key == resourceName { + dataSource = ds + break + } + } + } + + if dataSource == nil { + return fmt.Errorf("Data Source %q was not registered!", resourceName) + } + + return buildDocumentationForDataSource(resourceName, dataSource) +} + +func runForResource(resourceName string) error { + var resource *schema.Resource + + for _, service := range provider.SupportedServices() { + for key, rs := range service.SupportedResources() { + if key == resourceName { + resource = rs + break + } + } + } + + if resource == nil { + return fmt.Errorf("Resource %q was not registered!", resourceName) + } + + return buildDocumentationForResource(resourceName, resource) +} + +func buildDocumentationForDataSource(resourceName string, resource *schema.Resource) error { + return nil +} + +func buildDocumentationForResource(resourceName string, resource *schema.Resource) error { + return nil +} From 04768068129db18db8e882e274e2b44a16f0fa36 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 24 Feb 2020 19:17:55 +0100 Subject: [PATCH 20/92] New Tool: website-scaffolder This tools intended to aid with building new resources, in particular by scaffolding the documentation from the resource definition. Note: this is intentionally scaffolding - not full codegen - since documentation should always require human review for clarity / grammar. --- .../internal/tools/website-scaffold/README.md | 23 + .../internal/tools/website-scaffold/main.go | 882 +++++++++++++++++- 2 files changed, 873 insertions(+), 32 deletions(-) create mode 100644 azurerm/internal/tools/website-scaffold/README.md diff --git a/azurerm/internal/tools/website-scaffold/README.md b/azurerm/internal/tools/website-scaffold/README.md new file mode 100644 index 000000000000..285b4da72cc0 --- /dev/null +++ b/azurerm/internal/tools/website-scaffold/README.md @@ -0,0 +1,23 @@ +## Website Scaffolder + +This application scaffolds the documentation for a Data Source/Resource. + +**Note:** the documentation generated from this application is intended to be a starting point, which when finished requires human review - rather than generating a finished product. + +## Example Usage + +``` +$ go run main.go -name azurerm_resource_group -brand-name "Resource Group" -type "resource" -resource-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1" -website-path ../../../../website/ +``` + +## Arguments + +* `-name` - (Required) The Name used for the Resource in Terraform e.g. `azurerm_resource_group` + +* `-brand-name` - (Required) The Brand Name used for this Resource in Azure e.g. `Resource Group` or `App Service (Web Apps)` + +* `-type` - (Required) The Type of Documentation to generate. Possible values are `data` (for a Data Source) or `resource` (for a Resource). + +* `-resource-id` - (Required when scaffolding a Resource) An Azure Resource ID which can be used as a placeholder in the import documentation. + +* `-website-path` - (Required) The path to the `./website` directory in the root of this repository. diff --git a/azurerm/internal/tools/website-scaffold/main.go b/azurerm/internal/tools/website-scaffold/main.go index b1b943bea8d9..cde618488384 100644 --- a/azurerm/internal/tools/website-scaffold/main.go +++ b/azurerm/internal/tools/website-scaffold/main.go @@ -3,71 +3,889 @@ package main import ( "flag" "fmt" + "log" + "math" + "os" + "path/filepath" + "sort" + "strconv" + "strings" + "time" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/provider" ) +// NOTE: since we're using `go run` for these tools all of the code needs to live within the main.go + func main() { - isResource := flag.Bool("resource", true, "True if this is a Resource, False if this is a Data Source") - resourceName := flag.String("name", "", "The name of the Data Source/Resource which should be generated") - flag.Parse() + f := flag.NewFlagSet("example", flag.ExitOnError) + + resourceName := f.String("name", "", "The name of the Data Source/Resource which should be generated") + brandName := f.String("brand-name", "", "The friendly/brand name of this Data Source/Resource (e.g. Resource Group)") + resourceId := f.String("resource-id", "", "An Azure Resource ID showing an example of how to Import this Resource") + resourceType := f.String("type", "", "Whether this is a Data Source (data) or a Resource (resource)") + websitePath := f.String("website-path", "", "The relative path to the website folder") + + f.Parse(os.Args[1:]) + + var quitWithError = func(message string) { + log.Printf(message) + os.Exit(1) + } - if err := run(*isResource, *resourceName); err != nil { + if resourceName == nil || *resourceName == "" { + quitWithError("The name of the Data Source/Resource must be specified via `-name`") + return + } + + if brandName == nil || *brandName == "" { + quitWithError("The friendly/brannd name of the Data Source/Resource must be specified via `-brand`") + return + } + + if resourceType == nil || *resourceType == "" { + quitWithError("The type of the Data Source/Resource must be specified via `-type`") + return + } + + if *resourceType != "data" && *resourceType != "resource" { + quitWithError("The type of the Data Source/Resource specified via `-type` must be either `data` or `resource`") + return + } + + if websitePath == nil || *websitePath == "" { + quitWithError("The Relative Website Path must be specified via `-website-path`") + return + } + + isResource := *resourceType == "resource" + if isResource && (resourceId == nil || *resourceId == "") { + quitWithError("An example of an Azure Resource ID must be specified via `-resource-id` when scaffolding for a Resource") + return + } + + if err := run(*resourceName, *brandName, resourceId, isResource, *websitePath); err != nil { panic(err) } } -func run(isResource bool, resourceName string) error { - if isResource { - return runForResource(resourceName) +func run(resourceName, brandName string, resourceId *string, isResource bool, websitePath string) error { + + content, err := getContent(resourceName, brandName, resourceId, isResource) + if err != nil { + return fmt.Errorf("Error building content: %s", err) + } + + return saveContent(resourceName, websitePath, *content, isResource) +} + +func getContent(resourceName, brandName string, resourceId *string, isResource bool) (*string, error) { + generator := documentationGenerator{ + resourceName: resourceName, + brandName: brandName, + resourceId: resourceId, + isDataSource: !isResource, + } + + if !isResource { + for _, service := range provider.SupportedServices() { + for key, ds := range service.SupportedDataSources() { + if key == resourceName { + generator.resource = ds + generator.websiteCategories = service.WebsiteCategories() + break + } + } + } + + if generator.resource == nil { + return nil, fmt.Errorf("Data Source %q was not registered!", resourceName) + } + } else { + for _, service := range provider.SupportedServices() { + for key, rs := range service.SupportedResources() { + if key == resourceName { + generator.resource = rs + generator.websiteCategories = service.WebsiteCategories() + break + } + } + } + + if generator.resource == nil { + return nil, fmt.Errorf("Resource %q was not registered!", resourceName) + } + } + + docs := generator.generate() + return &docs, nil +} + +func saveContent(resourceName string, websitePath string, content string, isResource bool) error { + resourceKind := "r" + if !isResource { + resourceKind = "d" + } + + fileName := strings.TrimPrefix(resourceName, "azurerm_") + outputFileName := fmt.Sprintf("%s/docs/%s/%s.html.markdown", websitePath, resourceKind, fileName) + outputPath, err := filepath.Abs(outputFileName) + if err != nil { + return err + } + + file, err := os.Create(outputPath) + if err != nil { + return err + } + if os.IsExist(err) { + os.Remove(outputPath) + file, err = os.Create(outputPath) + if err != nil { + return err + } + } + defer file.Close() + + content = strings.TrimSpace(content) + _, _ = file.WriteString(content) + return file.Sync() +} + +type documentationGenerator struct { + resource *schema.Resource + + // brandName is the marketing brand name used for this resource (e.g. Resource Group / App Service / Web Apps) + brandName string + + // resourceName is the name of the resource e.g. `azurerm_resource_group` + resourceName string + + // isDataSource defines if this is a Data Source (if not it's a Resource) + isDataSource bool + + // resourceId is an example of the ID used by this Resource + resourceId *string + + // websiteCategories is the list of categories available by this service definition + websiteCategories []string +} + +func (gen documentationGenerator) generate() string { + title := gen.title() + argumentsBlock := gen.argumentsBlock() + attributesBlock := gen.attributesBlock() + description := gen.description() + exampleUsageBlock := gen.exampleUsageBlock() + frontMatterBlock := gen.frontMatterBlock() + importBlock := gen.importBlock() + timeoutsBlock := gen.timeoutsBlock() + + template := fmt.Sprintf(`%s +# %s + +%s. + +## Example Usage + +[][][]hcl +%s +[][][] + +%s + +%s + +%s + +%s`, frontMatterBlock, title, description, exampleUsageBlock, argumentsBlock, attributesBlock, timeoutsBlock, importBlock) + return strings.ReplaceAll(template, "[][][]", "```") +} + +// blocks +func (gen documentationGenerator) argumentsBlock() string { + var documentationForArguments = func(input map[string]*schema.Schema, onlyRequired, onlyOptional bool, blockName string) string { + fields := "" + + for _, fieldName := range gen.sortFields(input) { + field := input[fieldName] + + // nothing to see here, move along + if !field.Optional && !field.Required { + continue + } + + if onlyRequired && !field.Required { + continue + } + + if onlyOptional && !field.Optional { + continue + } + + status := "Optional" + if field.Required { + status = "Required" + } + + value := gen.buildDescriptionForArgument(fieldName, field, blockName) + if len(field.ConflictsWith) > 0 { + conflictingValues := make([]string, 0) + for _, v := range field.ConflictsWith { + conflictingValues = append(conflictingValues, fmt.Sprintf("`%s`", v)) + } + + value += fmt.Sprintf("Conflicts with %s", strings.Join(conflictingValues, ",")) + } + if field.ForceNew { + value += fmt.Sprintf(" Changing this forces a new %s to be created.", gen.brandName) + } + fields += fmt.Sprintf("* `%s` - (%s) %s\n\n", fieldName, status, value) + } + + return fields + } + + // first output the Required fields + fields := documentationForArguments(gen.resource.Schema, true, false, "") + // then prepare the Optional fields + optionalFields := documentationForArguments(gen.resource.Schema, false, true, "") + + // assuming we have both optional & required fields - let's add a separarer + if len(fields) > 0 && len(optionalFields) > 0 { + fields += "---\n\n" + } + fields += optionalFields + + // first list all of the top-level fields / blocks alphabetically + + // then we need to collect a list of all block names, everywhere + blockNames, blocks := gen.uniqueBlockNamesForArgument(gen.resource.Schema) + + for _, blockName := range blockNames { + block := blocks[blockName] + + fields += "---\n\n" + fields += fmt.Sprintf("A `%s` block supports the following:\n\n", blockName) + // required + fields += documentationForArguments(block, true, false, blockName) + // optional + fields += documentationForArguments(block, false, true, blockName) + } + + fields = strings.TrimSuffix(fields, "\n\n") + + return fmt.Sprintf(`## Arguments Reference + +The following arguments are supported: + +%s`, fields) +} + +func (gen documentationGenerator) attributesBlock() string { + var documentationForAttributes = func(input map[string]*schema.Schema, onlyComputed bool, blockName string) string { + fields := "" + + // now list all of the top-level fields / blocks alphabetically + for _, fieldName := range gen.sortFields(input) { + field := input[fieldName] + // when we're in a nested block there's no need to duplicate the fields + if onlyComputed && !field.Computed { + continue + } + if onlyComputed && (field.Optional || field.Required) { + continue + } + + value := gen.buildDescriptionForAttribute(fieldName, field, blockName) + fields += fmt.Sprintf("* `%s` - %s\n\n", fieldName, value) + } + + return fields + } + + // present in everything + fields := fmt.Sprintf("* `id` - The ID of the %s.\n\n", gen.brandName) + + // now list all of the top-level fields / blocks alphabetically + fields += documentationForAttributes(gen.resource.Schema, true, "") + + // then we need to collect a list of all block names, everywhere + blockNames, blocks := gen.uniqueBlockNamesForAttribute(gen.resource.Schema) + + for _, blockName := range blockNames { + block := blocks[blockName] + + fields += "---\n\n" + fields += fmt.Sprintf("A `%s` block exports the following:\n\n", blockName) + fields += documentationForAttributes(block, false, blockName) + } + + fields = strings.TrimSuffix(fields, "\n\n") + + return fmt.Sprintf(`## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +%s`, fields) +} + +func (gen documentationGenerator) description() string { + if gen.isDataSource { + return fmt.Sprintf("Use this data source to access information about an existing %s", gen.brandName) + } + + return fmt.Sprintf("Manages a %s", gen.brandName) +} + +func (gen documentationGenerator) exampleUsageBlock() string { + requiredFields := gen.requiredFieldsForExampleBlock(gen.resource.Schema, 1) + + if gen.isDataSource { + return fmt.Sprintf(`data "%s" "example" { +%s +} + +output "id" { + value = data.%s.example.id" +}`, gen.resourceName, requiredFields, gen.resourceName) + } + + return fmt.Sprintf(`resource "%s" "example" { +%s +}`, gen.resourceName, requiredFields) +} + +func (gen documentationGenerator) frontMatterBlock() string { + category := "TODO" + if len(gen.websiteCategories) > 0 { + if len(gen.websiteCategories) == 1 { + category = gen.websiteCategories[0] + } else { + category = fmt.Sprintf("TODO - pick from: %s", strings.Join(gen.websiteCategories, "|")) + } + } + + title := gen.title() + var description string + if gen.isDataSource { + description = fmt.Sprintf("Gets information about an existing %s", gen.brandName) + } else { + description = fmt.Sprintf("Manages a %s", gen.brandName) + } + + return fmt.Sprintf(` +--- +subcategory: "%s" +layout: "azurerm" +page_title: "Azure Resource Manager: %s" +description: |- + %s. +--- +`, category, title, description) +} + +func (gen documentationGenerator) importBlock() string { + // data source don't support import + if gen.isDataSource { + return "" + } + + template := fmt.Sprintf(`## Import + +%ss can be imported using the []resource id[], e.g. + +[][][]shell +terraform import %s.example %s +[][][]`, gen.brandName, gen.resourceName, *gen.resourceId) + return strings.ReplaceAll(template, "[]", "`") +} + +func (gen documentationGenerator) timeoutsBlock() string { + if gen.resource.Timeouts == nil { + return "" + } + timeouts := *gen.resource.Timeouts + + timeoutsBlurb := "The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:" + + var timeoutToFriendlyText = func(duration time.Duration) string { + hours := int(math.Floor(duration.Hours())) + if hours > 0 { + var hoursText string + if hours > 1 { + hoursText = fmt.Sprintf("%d hours", hours) + } else { + hoursText = "1 hour" + } + + minutesRemaining := int(math.Floor(duration.Minutes())) % 60.0 + if minutesRemaining == 0 { + return hoursText + } + + var minutesText string + if minutesRemaining > 1 { + minutesText = fmt.Sprintf("%d minutes", minutesRemaining) + } else { + minutesText = "1 minute" + } + + return fmt.Sprintf("%s and %s", hoursText, minutesText) + } + + minutes := int(duration.Minutes()) + if minutes > 1 { + return fmt.Sprintf("%d minutes", minutes) + } + + return "1 minute" + } + + timeoutsText := "" + if timeouts.Create != nil { + friendlyText := timeoutToFriendlyText(*timeouts.Create) + timeoutsText += fmt.Sprintf("* `create` - (Defaults to %s) Used when creating the %s.\n", friendlyText, gen.brandName) + } + + if timeouts.Read != nil { + friendlyText := timeoutToFriendlyText(*timeouts.Read) + timeoutsText += fmt.Sprintf("* `read` - (Defaults to %s) Used when retrieving the %s.\n", friendlyText, gen.brandName) + } + + if timeouts.Update != nil { + friendlyText := timeoutToFriendlyText(*timeouts.Update) + timeoutsText += fmt.Sprintf("* `update` - (Defaults to %s) Used when updating the %s.\n", friendlyText, gen.brandName) + } + + if timeouts.Create != nil { + friendlyText := timeoutToFriendlyText(*timeouts.Create) + timeoutsText += fmt.Sprintf("* `delete` - (Defaults to %s) Used when deleting the %s.\n", friendlyText, gen.brandName) + } + + timeoutsText = strings.TrimSuffix(timeoutsText, "\n") + return fmt.Sprintf(`## Timeouts + +%s + +%s`, timeoutsBlurb, timeoutsText) +} + +func (gen documentationGenerator) title() string { + if gen.isDataSource { + return fmt.Sprintf("Data Source: %s", gen.resourceName) } - return runForDataSource(resourceName) + return gen.resourceName } -func runForDataSource(resourceName string) error { - var dataSource *schema.Resource +// helpers +func (gen documentationGenerator) blockIsBefore(name string, blockName string) bool { + if blockName == "" { + return false + } - for _, service := range provider.SupportedServices() { - for key, ds := range service.SupportedDataSources() { - if key == resourceName { - dataSource = ds - break + items := []string{name, blockName} + sort.Strings(items) + return items[0] == name +} + +func (gen documentationGenerator) buildIndentForExample(level int) string { + out := "" + for i := 0; i < level; i++ { + out += " " + } + return out +} + +func (gen documentationGenerator) buildDescriptionForArgument(name string, field *schema.Schema, blockName string) string { + if name == "name" { + if blockName == "" { + if gen.isDataSource { + return fmt.Sprintf("The Name of this %s.", gen.brandName) } + + return fmt.Sprintf("The Name which should be used for this %s.", gen.brandName) + } else { + return "The Name which should be used for this TODO." + } + } + if name == "location" { + if gen.isDataSource { + return fmt.Sprintf("The Azure Region where the %s exists.", gen.brandName) } + + return fmt.Sprintf("The Azure Region where the %s should exist.", gen.brandName) + } + if name == "resource_group_name" { + if gen.isDataSource { + return fmt.Sprintf("The name of the Resource Group where the %s exists.", gen.brandName) + } + + return fmt.Sprintf("The name of the Resource Group where the %s should exist.", gen.brandName) + } + if name == "tags" { + return fmt.Sprintf("A mapping of tags which should be assigned to the %s.", gen.brandName) + } + + if name == "enabled" || strings.HasSuffix(name, "_enabled") { + return fmt.Sprintf("Should the TODO be enabled?") } - if dataSource == nil { - return fmt.Errorf("Data Source %q was not registered!", resourceName) + if strings.HasSuffix(name, "_id") { + return fmt.Sprintf("The ID of the TODO.") } - return buildDocumentationForDataSource(resourceName, dataSource) + if field.Elem != nil { + if _, ok := field.Elem.(*schema.Schema); ok { + if gen.blockIsBefore(name, blockName) { + return fmt.Sprintf("A `%s` block as defined above.", name) + } else { + return fmt.Sprintf("A `%s` block as defined below.", name) + } + } + + if _, ok := field.Elem.(*schema.Resource); ok { + if gen.blockIsBefore(name, blockName) { + return fmt.Sprintf("A `%s` block as defined above.", name) + } else { + return fmt.Sprintf("A `%s` block as defined below.", name) + } + } + } + if field.Type == schema.TypeList { + if gen.blockIsBefore(name, blockName) { + return fmt.Sprintf("A `%s` block as defined above.", name) + } else { + return fmt.Sprintf("A `%s` block as defined below.", name) + } + } + + return "TODO." } -func runForResource(resourceName string) error { - var resource *schema.Resource +func (gen documentationGenerator) buildDescriptionForAttribute(name string, field *schema.Schema, blockName string) string { + if name == "name" { + if blockName == "" { + return fmt.Sprintf("The Name of this %s.", gen.brandName) + } else { + return "The Name of this TODO." + } + } + if name == "location" { + return fmt.Sprintf("The Azure Region where the %s exists.", gen.brandName) + } + if name == "resource_group_name" { + return fmt.Sprintf("The name of the Resource Group where the %s is located.", gen.brandName) + } + if name == "tags" { + return fmt.Sprintf("A mapping of tags assigned to the %s.", gen.brandName) + } + + if name == "enabled" || strings.HasSuffix(name, "_enabled") { + return fmt.Sprintf("Is the TODO enabled?") + } + + if strings.HasSuffix(name, "_id") { + return fmt.Sprintf("The ID of the TODO.") + } + + if field.Elem != nil { + if _, ok := field.Elem.(*schema.Schema); ok { + if gen.blockIsBefore(name, blockName) { + return fmt.Sprintf("A `%s` block as defined above.", name) + } else { + return fmt.Sprintf("A `%s` block as defined below.", name) + } + } - for _, service := range provider.SupportedServices() { - for key, rs := range service.SupportedResources() { - if key == resourceName { - resource = rs - break + if _, ok := field.Elem.(*schema.Resource); ok { + if gen.blockIsBefore(name, blockName) { + return fmt.Sprintf("A `%s` block as defined above.", name) + } else { + return fmt.Sprintf("A `%s` block as defined below.", name) } } } + if field.Type == schema.TypeList { + if gen.blockIsBefore(name, blockName) { + return fmt.Sprintf("A `%s` block as defined above.", name) + } else { + return fmt.Sprintf("A `%s` block as defined below.", name) + } + } + + return "TODO." +} + +func (gen documentationGenerator) determineDefaultValueForExample(name string, field *schema.Schema) string { + if field.Default != nil { + if v, ok := field.Default.(bool); ok { + return strconv.FormatBool(v) + } + + if v, ok := field.Default.(int); ok { + return fmt.Sprintf("%d", v) + } + + if v, ok := field.Default.(string); ok { + return v + } + } + + if field.Type == schema.TypeBool { + return "false" + } + + if field.Type == schema.TypeInt { + return "42" + } + + if field.Type == schema.TypeFloat { + return "1.23456" + } + + if name == "name" || strings.HasSuffix(name, "_name") { + if gen.isDataSource { + return "\"existing\"" + } + + return "\"example\"" + } + if name == "location" { + return "\"West Europe\"" + } + if name == "resource_group_name" { + return "\"example-resources\"" + } + + return "\"TODO\"" +} + +func (gen documentationGenerator) distinctBlockNames(input []string) []string { + // this is a delightful hack to work around multiple blocks being a thing + temp := make(map[string]struct{}, 0) + for _, v := range input { + temp[v] = struct{}{} + } + + output := make([]string, 0) + for k := range temp { + output = append(output, k) + } + + return output +} + +func (gen documentationGenerator) processElementForExample(field string, indentLevel int, elem interface{}, isAttribute bool) string { + indent := gen.buildIndentForExample(indentLevel) + + // it's an array of something, work out what + if array, ok := elem.(*schema.Schema); ok { + switch array.Type { + case schema.TypeString: + return fmt.Sprintf("%s%s = [ \"example\" ]\n", indent, field) + + case schema.TypeInt: + return fmt.Sprintf("%s%s = [ 1 ]\n", indent, field) + + default: + return "TODO" + } + } + + // otherwise it's a list so we're gonna have to go around + if list, ok := elem.(*schema.Resource); ok && len(list.Schema) > 0 { + innerFields := gen.requiredFieldsForExampleBlock(list.Schema, indentLevel+1) + attributeSyntax := "" + if isAttribute { + attributeSyntax = " =" + } + return fmt.Sprintf("\n%s%s%s {\n%s %s\n%s}\n", indent, field, attributeSyntax, innerFields, indent, indent) + } + + // unless something's broken, since this is likely during provider dev it's likely things could be missing + panic("Field %q has an Element but isn't a Set or List - double-check the schema") +} + +func (gen documentationGenerator) requiredFieldsForExampleBlock(fields map[string]*schema.Schema, indentLevel int) string { + indent := gen.buildIndentForExample(indentLevel) + output := "" + + var processField = func(name string, field *schema.Schema) string { + value := gen.determineDefaultValueForExample(name, field) + return fmt.Sprintf("%s%s = %s\n", indent, name, value) + } + + // if we have a "name", "location" "resource_group_name" field output those first as per convention + if v, ok := fields["name"]; ok && v.Required { + output += processField("name", v) + } + if v, ok := fields["resource_group_name"]; ok && v.Required { + output += processField("resource_group_name", v) + } + if v, ok := fields["location"]; ok && v.Required { + output += processField("location", v) + } + + for field, v := range fields { + if !v.Required { + continue + } + if field == "location" || field == "name" || field == "resource_group_name" { + continue + } - if resource == nil { - return fmt.Errorf("Resource %q was not registered!", resourceName) + if v.Elem != nil { + isAttribute := v.ConfigMode == schema.SchemaConfigModeAttr + output += gen.processElementForExample(field, indentLevel, v.Elem, isAttribute) + continue + } + + output += processField(field, v) } + return strings.TrimSuffix(output, "\n") +} - return buildDocumentationForResource(resourceName, resource) +func (gen documentationGenerator) sortFields(input map[string]*schema.Schema) []string { + fieldNames := make([]string, 0) + for field := range input { + fieldNames = append(fieldNames, field) + } + sort.Strings(fieldNames) + return fieldNames } -func buildDocumentationForDataSource(resourceName string, resource *schema.Resource) error { - return nil +func (gen documentationGenerator) uniqueBlockNamesForArgument(fields map[string]*schema.Schema) ([]string, map[string]map[string]*schema.Schema) { + blockNames := make([]string, 0) + blocks := make(map[string]map[string]*schema.Schema, 0) + + for _, fieldName := range gen.sortFields(fields) { + field := fields[fieldName] + + // compute-only fields can be omited + if field.Computed && !(field.Optional || field.Required) { + continue + } + + if field.Type != schema.TypeList && field.Type != schema.TypeSet { + continue + } + + if field.Elem == nil { + continue + } + v, ok := field.Elem.(*schema.Resource) + if !ok { + continue + } + if v == nil { + continue + } + + // add this block + blockNames = append(blockNames, fieldName) + blocks[fieldName] = v.Schema + + // at this point we want to iterate over all the fields to determine which ones are nested blocks, then iterate over/aggregate those + for _, innerElem := range v.Schema { + if innerElem.Type != schema.TypeList && innerElem.Type != schema.TypeSet { + continue + } + if field.Elem == nil { + continue + } + + innerV, ok := field.Elem.(*schema.Resource) + if !ok { + continue + } + if innerV == nil { + continue + } + + innerBlockNames, innerBlocks := gen.uniqueBlockNamesForArgument(innerV.Schema) + for _, innerBlockName := range innerBlockNames { + innerBlock := innerBlocks[innerBlockName] + + blockNames = append(blockNames, innerBlockName) + blocks[innerBlockName] = innerBlock + } + } + } + + blockNames = gen.distinctBlockNames(blockNames) + sort.Strings(blockNames) + + return blockNames, blocks } -func buildDocumentationForResource(resourceName string, resource *schema.Resource) error { - return nil +func (gen documentationGenerator) uniqueBlockNamesForAttribute(fields map[string]*schema.Schema) ([]string, map[string]map[string]*schema.Schema) { + blockNames := make([]string, 0) + blocks := make(map[string]map[string]*schema.Schema, 0) + + for _, fieldName := range gen.sortFields(fields) { + field := fields[fieldName] + + // fields which are setable but aren't computed-only can be skipped + if (field.Optional || field.Required) && !field.Computed { + continue + } + + // optional+computed blocks with fields which aren't computed shouldn't be documented for attributes + if field.Optional && field.Computed { + continue + } + + if field.Type != schema.TypeList && field.Type != schema.TypeSet { + continue + } + + if field.Elem == nil { + continue + } + v, ok := field.Elem.(*schema.Resource) + if !ok { + continue + } + if v == nil { + continue + } + + // add this block + blockNames = append(blockNames, fieldName) + blocks[fieldName] = v.Schema + + // at this point we want to iterate over all the fields to determine which ones are nested blocks, then iterate over/aggregate those + for _, innerElem := range v.Schema { + if innerElem.Type != schema.TypeList && innerElem.Type != schema.TypeSet { + continue + } + if field.Elem == nil { + continue + } + + innerV, ok := field.Elem.(*schema.Resource) + if !ok { + continue + } + if innerV == nil { + continue + } + + innerBlockNames, innerBlocks := gen.uniqueBlockNamesForAttribute(innerV.Schema) + for _, innerBlockName := range innerBlockNames { + innerBlock := innerBlocks[innerBlockName] + + blockNames = append(blockNames, innerBlockName) + blocks[innerBlockName] = innerBlock + } + } + } + + blockNames = gen.distinctBlockNames(blockNames) + sort.Strings(blockNames) + + return blockNames, blocks } From 9a7b5194773110895dc4218c6df99abf35533cae Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 24 Feb 2020 19:31:36 +0100 Subject: [PATCH 21/92] d|r/resource_group: generating updated documentation --- website/docs/d/resource_group.html.markdown | 27 ++++++++-------- website/docs/r/resource_group.html.markdown | 35 +++++++++------------ 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/website/docs/d/resource_group.html.markdown b/website/docs/d/resource_group.html.markdown index 74d587e70aa4..9e4ec5220dfa 100644 --- a/website/docs/d/resource_group.html.markdown +++ b/website/docs/d/resource_group.html.markdown @@ -1,7 +1,7 @@ --- subcategory: "Base" layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_resource_group" +page_title: "Azure Resource Manager: Data Source: azurerm_resource_group" description: |- Gets information about an existing Resource Group. --- @@ -14,30 +14,29 @@ Use this data source to access information about an existing Resource Group. ```hcl data "azurerm_resource_group" "example" { - name = "dsrg_test" + name = "existing" } -resource "azurerm_managed_disk" "example" { - name = "managed_disk_name" - location = data.azurerm_resource_group.example.location - resource_group_name = data.azurerm_resource_group.example.name - storage_account_type = "Standard_LRS" - create_option = "Empty" - disk_size_gb = "1" +output "id" { + value = data.azurerm_resource_group.example.id" } ``` -## Argument Reference +## Arguments Reference -* `name` - Specifies the name of the resource group. +The following arguments are supported: -~> **Note:** If the specified location doesn't match the actual resource group location, an error message with the actual location value will be shown. +* `name` - (Required) The Name of this Resource Group. ## Attributes Reference +In addition to the Arguments listed above - the following Attributes are exported: + * `id` - The ID of the Resource Group. -* `location` - The location of the resource group. -* `tags` - A mapping of tags assigned to the resource group. + +* `location` - The Azure Region where the Resource Group exists. + +* `tags` - A mapping of tags assigned to the Resource Group. ## Timeouts diff --git a/website/docs/r/resource_group.html.markdown b/website/docs/r/resource_group.html.markdown index cfea275b7ec3..3adaaa8aa75e 100644 --- a/website/docs/r/resource_group.html.markdown +++ b/website/docs/r/resource_group.html.markdown @@ -3,58 +3,53 @@ subcategory: "Base" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_resource_group" description: |- - Manages a resource group on Azure. + Manages a Resource Group. --- # azurerm_resource_group -Manages a resource group on Azure. +Manages a Resource Group. ## Example Usage ```hcl resource "azurerm_resource_group" "example" { - name = "testResourceGroup1" - location = "West US" - - tags = { - environment = "Production" - } + name = "example" + location = "West Europe" } ``` -## Argument Reference +## Arguments Reference The following arguments are supported: -* `name` - (Required) The name of the resource group. Must be unique on your - Azure subscription. +* `location` - (Required) The Azure Region where the Resource Group should exist. Changing this forces a new Resource Group to be created. + +* `name` - (Required) The Name which should be used for this Resource Group. Changing this forces a new Resource Group to be created. -* `location` - (Required) The location where the resource group should be created. - For a list of all Azure locations, please consult [this link](http://azure.microsoft.com/en-us/regions/) or run `az account list-locations --output table`. +--- -* `tags` - (Optional) A mapping of tags to assign to the resource. +* `tags` - (Optional) A mapping of tags which should be assigned to the Resource Group. ## Attributes Reference -In addition to the arguments above, the following attributes are exported: +In addition to the Arguments listed above - the following Attributes are exported: * `id` - The ID of the Resource Group. - ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: -* `create` - (Defaults to 90 minutes) Used when creating the Resource Group. -* `update` - (Defaults to 90 minutes) Used when updating the Resource Group. +* `create` - (Defaults to 1 hour and 30 minutes) Used when creating the Resource Group. * `read` - (Defaults to 5 minutes) Used when retrieving the Resource Group. -* `delete` - (Defaults to 90 minutes) Used when deleting the Resource Group. +* `update` - (Defaults to 1 hour and 30 minutes) Used when updating the Resource Group. +* `delete` - (Defaults to 1 hour and 30 minutes) Used when deleting the Resource Group. ## Import Resource Groups can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_resource_group.mygroup /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup +terraform import azurerm_resource_group.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1 ``` From 6ca5c8dcb038ccb2978613aaa88cb6fab9b4c3b1 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 24 Feb 2020 19:46:07 +0100 Subject: [PATCH 22/92] tooling: adding the scaffold-website tool to the makefile --- GNUmakefile | 5 ++++- README.md | 23 +++++++++++++++++++--- scripts/scaffold-website.sh | 38 +++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100755 scripts/scaffold-website.sh diff --git a/GNUmakefile b/GNUmakefile index c8893dee148a..a6b019fd3088 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -123,6 +123,9 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) endif @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) +scaffold-website: + ./scripts/scaffold-website.sh + website-test: ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." @@ -130,4 +133,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) endif @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) -.PHONY: build build-docker test test-docker testacc vet fmt fmtcheck errcheck test-compile website website-test +.PHONY: build build-docker test test-docker testacc vet fmt fmtcheck errcheck scaffold-website test-compile website website-test diff --git a/README.md b/README.md index 60022faafd3d..33eefeb0f4e3 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,9 @@ The AzureRM Provider supports Terraform 0.10.x and later - but Terraform 0.12.x provider "azurerm" { # We recommend pinning to the specific version of the Azure Provider you're using # since new versions are released frequently - version = "=1.43.0" + version = "=2.0.0" + + features {} # More information on the authentication methods supported by # the AzureRM Provider can be found here: @@ -45,7 +47,7 @@ Further [usage documentation is available on the Terraform website](https://www. ## Developer Requirements -* [Terraform](https://www.terraform.io/downloads.html) version 0.10.x + +* [Terraform](https://www.terraform.io/downloads.html) version 0.12.x + * [Go](https://golang.org/doc/install) version 1.13.x (to build the provider plugin) If you're on Windows you'll also need: @@ -93,7 +95,7 @@ $ make test The majority of tests in the provider are Acceptance Tests - which provisions real resources in Azure. It's possible to run the entire acceptance test suite by running `make testacc` - however it's likely you'll want to run a subset, which you can do using a prefix, by running: -``` +```sh make testacc SERVICE='resource' TESTARGS='-run=TestAccAzureRMResourceGroup' TESTTIMEOUT='60m' ``` @@ -110,3 +112,18 @@ The following Environment Variables must be set in your shell prior to running a **Note:** Acceptance tests create real resources in Azure which often cost money to run. +--- + +## Developer: Scaffolding the Website Documentation + +You can scaffold the documentation for a Data Source by running: + +```sh +$ make scaffold-website BRAND_NAME="Resource Group" RESOURCE_NAME="azurerm_resource_group" RESOURCE_TYPE="data" +``` + +You can scaffold the documentation for a Resource by running: + +```sh +$ make scaffold-website BRAND_NAME="Resource Group" RESOURCE_NAME="azurerm_resource_group" RESOURCE_TYPE="resource" RESOURCE_ID="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1" +``` diff --git a/scripts/scaffold-website.sh b/scripts/scaffold-website.sh new file mode 100755 index 000000000000..51e14f109d8f --- /dev/null +++ b/scripts/scaffold-website.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +function verifyVars { + echo "==> Verifying required variables are set..." + if [ "${BRAND_NAME}" == "" ]; then + echo "\nBRAND_NAME is unset, exiting" + exit 1 + fi + if [ "${RESOURCE_NAME}" == "" ]; then + echo "\nRESOURCE_NAME is unset, exiting" + exit 1 + fi + if [ "${RESOURCE_TYPE}" == "" ]; then + echo "\nRESOURCE_TYPE is unset, exiting" + exit 1 + fi + if [ "${RESOURCE_TYPE}" == "resource" ]; then + if [ "${RESOURCE_ID}" == "" ]; then + echo "\nRESOURCE_ID is unset, exiting" + exit 1 + fi + fi + + echo "==> Validated." +} + +function scaffoldDocumentation { + echo "==> Scaffolding Documentation..." + go run azurerm/internal/tools/website-scaffold/main.go -name "${RESOURCE_NAME}" -brand-name "${BRAND_NAME}" -type "${RESOURCE_TYPE}" -resource-id "${RESOURCE_ID}" -website-path ./website/ + echo "==> Done." +} + +function main { + verifyVars + scaffoldDocumentation +} + +main From 9b4f07c2a5ad2ceab6aefe943efe97bc4e228f09 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 24 Feb 2020 21:08:51 +0100 Subject: [PATCH 23/92] r/search_service: updating the docs --- website/docs/r/search_service.html.markdown | 56 +++++++++++---------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/website/docs/r/search_service.html.markdown b/website/docs/r/search_service.html.markdown index c997f14d503d..0756e213466e 100644 --- a/website/docs/r/search_service.html.markdown +++ b/website/docs/r/search_service.html.markdown @@ -8,73 +8,77 @@ description: |- # azurerm_search_service -Allows you to manage an Azure Search Service. +Manages a Search Service. ## Example Usage ```hcl resource "azurerm_resource_group" "example" { - name = "acceptanceTestResourceGroup1" - location = "West US" + name = "example-resources" + location = "West Europe" } resource "azurerm_search_service" "example" { - name = "acceptanceTestSearchService1" + name = "example-search-service" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location sku = "standard" - - tags = { - environment = "staging" - database = "test" - } } ``` -## Argument Reference + +## Arguments Reference The following arguments are supported: -* `name` - (Required) The name of the Search Service. Changing this forces a new resource to be created. +* `location` - (Required) The Azure Region where the Search Service should exist. Changing this forces a new Search Service to be created. + +* `name` - (Required) The Name which should be used for this Search Service. Changing this forces a new Search Service to be created. -* `resource_group_name` - (Required) The name of the resource group in which to create the Search Service. Changing this forces a new resource to be created. +* `resource_group_name` - (Required) The name of the Resource Group where the Search Service should exist. Changing this forces a new Search Service to be created. -* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. +* `sku` - (Required) The SKU which should be used for this Search Service. Possible values are `basic`, `free`, `standard`, `standard2` and `standard3` Changing this forces a new Search Service to be created. -* `sku` - (Required) Valid values are `basic`, `free` and `standard`. `standard2` and `standard3` are also valid, but can only be used when it's enabled on the backend by Microsoft support. `free` provisions the service in shared clusters. `standard` provisions the service in dedicated clusters. Changing this forces a new resource to be created. +-> The `basic` and `free` SKU's provision the Search Service in a Shared Cluster - the `standard` SKU's use a Dedicated Cluster. -* `replica_count` - (Optional) Default is 1. Valid values include 1 through 12. Valid only when `sku` is `standard`. Changing this forces a new resource to be created. +~> **Note:** The SKU's `standard2` and `standard3` are only available when enabled on the backend by Microsoft. -* `partition_count` - (Optional) Default is 1. Valid values include 1, 2, 3, 4, 6, or 12. Valid only when `sku` is `standard`. Changing this forces a new resource to be created. +--- -* `tags` - (Optional) A mapping of tags to assign to the resource. +* `partition_count` - (Optional) The number of partitions which should be created. Possible values are `1`, `2`, `3`, `4`, `6`, or `12`. Defaults to `1`. Changing this forces a new Search Service to be created. -## Attributes Reference +* `replica_count` - (Optional) The number of replica's which should be created. Changing this forces a new Search Service to be created. -The following attributes are exported: +-> **Note:** `partition_count` and `replica_count` can only be configured when using a `standard` sku. -* `id` - The Search Service ID. +* `tags` - (Optional) A mapping of tags which should be assigned to the Search Service. -* `primary_key` - The Search Service Administration primary key. +## Attributes Reference -* `secondary_key` - The Search Service Administration secondary key. +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Search Service. + +* `primary_key` - The Primary Key used for Search Service Administration. * `query_keys` - A `query_keys` block as defined below. +* `secondary_key` - The Secondary Key used for Search Service Administration. + --- A `query_keys` block exports the following: -* `name` - The name of the query key. +* `key` - The value of this Query Key. -* `key` - The value of the query key. +* `name` - The name of this Query Key. ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: * `create` - (Defaults to 30 minutes) Used when creating the Search Service. -* `update` - (Defaults to 30 minutes) Used when updating the Search Service. * `read` - (Defaults to 5 minutes) Used when retrieving the Search Service. +* `update` - (Defaults to 30 minutes) Used when updating the Search Service. * `delete` - (Defaults to 30 minutes) Used when deleting the Search Service. ## Import @@ -82,5 +86,5 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d Search Services can be imported using the `resource id`, e.g. ```shell -terraform import azurerm_search_service.service1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Search/searchServices/service1 +terraform import azurerm_search_service.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Search/searchServices/service1 ``` From d4312026eb6fd71020bee2c1e693f6775035c273 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 28 Feb 2020 11:46:14 -0500 Subject: [PATCH 24/92] tools: fixing an issue when scaffolding the example for a data source --- azurerm/internal/tools/website-scaffold/main.go | 2 +- website/docs/d/resource_group.html.markdown | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/tools/website-scaffold/main.go b/azurerm/internal/tools/website-scaffold/main.go index cde618488384..03d9c689a032 100644 --- a/azurerm/internal/tools/website-scaffold/main.go +++ b/azurerm/internal/tools/website-scaffold/main.go @@ -348,7 +348,7 @@ func (gen documentationGenerator) exampleUsageBlock() string { } output "id" { - value = data.%s.example.id" + value = data.%s.example.id }`, gen.resourceName, requiredFields, gen.resourceName) } diff --git a/website/docs/d/resource_group.html.markdown b/website/docs/d/resource_group.html.markdown index 9e4ec5220dfa..908792088fe0 100644 --- a/website/docs/d/resource_group.html.markdown +++ b/website/docs/d/resource_group.html.markdown @@ -18,7 +18,7 @@ data "azurerm_resource_group" "example" { } output "id" { - value = data.azurerm_resource_group.example.id" + value = data.azurerm_resource_group.example.id } ``` From 0861b1c305c76b47557862ebda5a43b9794e0909 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 28 Feb 2020 11:48:53 -0500 Subject: [PATCH 25/92] linting --- azurerm/internal/tools/website-scaffold/main.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/azurerm/internal/tools/website-scaffold/main.go b/azurerm/internal/tools/website-scaffold/main.go index 03d9c689a032..6b0960718d26 100644 --- a/azurerm/internal/tools/website-scaffold/main.go +++ b/azurerm/internal/tools/website-scaffold/main.go @@ -27,10 +27,10 @@ func main() { resourceType := f.String("type", "", "Whether this is a Data Source (data) or a Resource (resource)") websitePath := f.String("website-path", "", "The relative path to the website folder") - f.Parse(os.Args[1:]) + _ = f.Parse(os.Args[1:]) var quitWithError = func(message string) { - log.Printf(message) + log.Print(message) os.Exit(1) } @@ -71,7 +71,6 @@ func main() { } func run(resourceName, brandName string, resourceId *string, isResource bool, websitePath string) error { - content, err := getContent(resourceName, brandName, resourceId, isResource) if err != nil { return fmt.Errorf("Error building content: %s", err) @@ -665,7 +664,7 @@ func (gen documentationGenerator) determineDefaultValueForExample(name string, f func (gen documentationGenerator) distinctBlockNames(input []string) []string { // this is a delightful hack to work around multiple blocks being a thing - temp := make(map[string]struct{}, 0) + temp := make(map[string]struct{}) for _, v := range input { temp[v] = struct{}{} } @@ -759,12 +758,12 @@ func (gen documentationGenerator) sortFields(input map[string]*schema.Schema) [] func (gen documentationGenerator) uniqueBlockNamesForArgument(fields map[string]*schema.Schema) ([]string, map[string]map[string]*schema.Schema) { blockNames := make([]string, 0) - blocks := make(map[string]map[string]*schema.Schema, 0) + blocks := make(map[string]map[string]*schema.Schema) for _, fieldName := range gen.sortFields(fields) { field := fields[fieldName] - // compute-only fields can be omited + // compute-only fields can be omitted if field.Computed && !(field.Optional || field.Required) { continue } @@ -823,7 +822,7 @@ func (gen documentationGenerator) uniqueBlockNamesForArgument(fields map[string] func (gen documentationGenerator) uniqueBlockNamesForAttribute(fields map[string]*schema.Schema) ([]string, map[string]map[string]*schema.Schema) { blockNames := make([]string, 0) - blocks := make(map[string]map[string]*schema.Schema, 0) + blocks := make(map[string]map[string]*schema.Schema) for _, fieldName := range gen.sortFields(fields) { field := fields[fieldName] From 2c6f3276236db43c10075a338df9fd06fa77b247 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 28 Feb 2020 11:56:16 -0500 Subject: [PATCH 26/92] tools/website-scaffold: fixing a typo --- azurerm/internal/tools/website-scaffold/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/tools/website-scaffold/main.go b/azurerm/internal/tools/website-scaffold/main.go index 6b0960718d26..1029bcdeda3c 100644 --- a/azurerm/internal/tools/website-scaffold/main.go +++ b/azurerm/internal/tools/website-scaffold/main.go @@ -458,8 +458,8 @@ func (gen documentationGenerator) timeoutsBlock() string { timeoutsText += fmt.Sprintf("* `update` - (Defaults to %s) Used when updating the %s.\n", friendlyText, gen.brandName) } - if timeouts.Create != nil { - friendlyText := timeoutToFriendlyText(*timeouts.Create) + if timeouts.Delete != nil { + friendlyText := timeoutToFriendlyText(*timeouts.Delete) timeoutsText += fmt.Sprintf("* `delete` - (Defaults to %s) Used when deleting the %s.\n", friendlyText, gen.brandName) } From e3f683fc1c5ea4e2cb1a29cee153faa02521ff56 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 9 Mar 2020 09:49:17 +0100 Subject: [PATCH 27/92] r/search_service: the fields `partition_count` and `replica_count` are no longer forcenew --- website/docs/r/search_service.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/search_service.html.markdown b/website/docs/r/search_service.html.markdown index 0756e213466e..c73733214382 100644 --- a/website/docs/r/search_service.html.markdown +++ b/website/docs/r/search_service.html.markdown @@ -44,9 +44,9 @@ The following arguments are supported: --- -* `partition_count` - (Optional) The number of partitions which should be created. Possible values are `1`, `2`, `3`, `4`, `6`, or `12`. Defaults to `1`. Changing this forces a new Search Service to be created. +* `partition_count` - (Optional) The number of partitions which should be created. -* `replica_count` - (Optional) The number of replica's which should be created. Changing this forces a new Search Service to be created. +* `replica_count` - (Optional) The number of replica's which should be created. -> **Note:** `partition_count` and `replica_count` can only be configured when using a `standard` sku. From 8a5377bf0fd59adb207ab1ad131a8e6e59fac908 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 9 Mar 2020 10:08:01 +0100 Subject: [PATCH 28/92] tests: clarifying the features block is required going forward The temporary patch in the provider/test suite allows for us to gradually add provider blocks to the test suite, rather than doing it in a big-bang (and breaking open PR's). Unfortunately this workaround was unintentionally available in release binaries, as such this commit changes this patch to only work for test providers rather than released versions since this isn't intended to be used by users. Instead we require that Provider blocks and Feature blocks are both specified to be explicit about which instance of a provider is being used when provisioning resources. --- azurerm/internal/acceptance/data.go | 2 +- azurerm/internal/provider/features.go | 9 ++++----- azurerm/internal/provider/provider.go | 10 +++++++++- azurerm/internal/provider/provider_test.go | 13 +++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/azurerm/internal/acceptance/data.go b/azurerm/internal/acceptance/data.go index 2a7ad06e102e..e173e4d28348 100644 --- a/azurerm/internal/acceptance/data.go +++ b/azurerm/internal/acceptance/data.go @@ -52,7 +52,7 @@ type TestData struct { // BuildTestData generates some test data for the given resource func BuildTestData(t *testing.T, resourceType string, resourceLabel string) TestData { once.Do(func() { - azureProvider := provider.AzureProvider().(*schema.Provider) + azureProvider := provider.TestAzureProvider().(*schema.Provider) AzureProvider = azureProvider SupportedProviders = map[string]terraform.ResourceProvider{ diff --git a/azurerm/internal/provider/features.go b/azurerm/internal/provider/features.go index 3df1e7014a49..f5e56a24ba06 100644 --- a/azurerm/internal/provider/features.go +++ b/azurerm/internal/provider/features.go @@ -1,13 +1,11 @@ package provider import ( - "os" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" ) -func schemaFeatures() *schema.Schema { +func schemaFeatures(supportLegacyTestSuite bool) *schema.Schema { // NOTE: if there's only one nested field these want to be Required (since there's no point // specifying the block otherwise) - however for 2+ they should be optional features := map[string]*schema.Schema{ @@ -59,8 +57,9 @@ func schemaFeatures() *schema.Schema { }, } - runningAcceptanceTests := os.Getenv("TF_ACC") != "" - if runningAcceptanceTests { + // this is a temporary hack to enable us to gradually add provider blocks to test configurations + // rather than doing it as a big-bang and breaking all open PR's + if supportLegacyTestSuite { return &schema.Schema{ Type: schema.TypeList, Optional: true, diff --git a/azurerm/internal/provider/provider.go b/azurerm/internal/provider/provider.go index f55a6173d813..c99cf79247ed 100644 --- a/azurerm/internal/provider/provider.go +++ b/azurerm/internal/provider/provider.go @@ -15,6 +15,14 @@ import ( ) func AzureProvider() terraform.ResourceProvider { + return azureProvider(false) +} + +func TestAzureProvider() terraform.ResourceProvider { + return azureProvider(true) +} + +func azureProvider(supportLegacyTestSuite bool) terraform.ResourceProvider { // avoids this showing up in test output var debugLog = func(f string, v ...interface{}) { if os.Getenv("TF_LOG") == "" { @@ -149,7 +157,7 @@ func AzureProvider() terraform.ResourceProvider { Description: "This will disable the Terraform Partner ID which is used if a custom `partner_id` isn't specified.", }, - "features": schemaFeatures(), + "features": schemaFeatures(supportLegacyTestSuite), // Advanced feature flags "skip_credentials_validation": { diff --git a/azurerm/internal/provider/provider_test.go b/azurerm/internal/provider/provider_test.go index d41e663cfa3a..1e5a2d37844c 100644 --- a/azurerm/internal/provider/provider_test.go +++ b/azurerm/internal/provider/provider_test.go @@ -2,23 +2,19 @@ package provider import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) func TestProvider(t *testing.T) { - if err := AzureProvider().(*schema.Provider).InternalValidate(); err != nil { + if err := TestAzureProvider().(*schema.Provider).InternalValidate(); err != nil { t.Fatalf("err: %s", err) } } func TestDataSourcesSupportCustomTimeouts(t *testing.T) { - // this is required until 2.0 - os.Setenv("ARM_PROVIDER_CUSTOM_TIMEOUTS", "true") - - provider := AzureProvider().(*schema.Provider) + provider := TestAzureProvider().(*schema.Provider) for dataSourceName, dataSource := range provider.DataSourcesMap { t.Run(fmt.Sprintf("DataSource/%s", dataSourceName), func(t *testing.T) { t.Logf("[DEBUG] Testing Data Source %q..", dataSourceName) @@ -54,10 +50,7 @@ func TestDataSourcesSupportCustomTimeouts(t *testing.T) { } func TestResourcesSupportCustomTimeouts(t *testing.T) { - // this is required until 2.0 - os.Setenv("ARM_PROVIDER_CUSTOM_TIMEOUTS", "true") - - provider := AzureProvider().(*schema.Provider) + provider := TestAzureProvider().(*schema.Provider) for resourceName, resource := range provider.ResourcesMap { t.Run(fmt.Sprintf("Resource/%s", resourceName), func(t *testing.T) { t.Logf("[DEBUG] Testing Resource %q..", resourceName) From 5f27bdc2d7867a860abbedf3d99f1edbdf52de2f Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 9 Mar 2020 10:44:22 +0100 Subject: [PATCH 29/92] features: removing the unused "two point oh" feature --- azurerm/internal/features/two_point_oh.go | 23 ------------------- .../internal/services/compute/registration.go | 10 -------- 2 files changed, 33 deletions(-) delete mode 100644 azurerm/internal/features/two_point_oh.go diff --git a/azurerm/internal/features/two_point_oh.go b/azurerm/internal/features/two_point_oh.go deleted file mode 100644 index d028d8e88378..000000000000 --- a/azurerm/internal/features/two_point_oh.go +++ /dev/null @@ -1,23 +0,0 @@ -package features - -// SupportsTwoPointZeroResources returns whether the new VM and VMSS resources from 2.0 -// should be supported -// -// There's 5 new resources coming as a part of 2.0, which are intentionally feature-flagged off -// until all 5 are supported: -// * `azurerm_linux_virtual_machine` -// * `azurerm_linux_virtual_machine_scale_set` -// * `azurerm_windows_virtual_machine` -// * `azurerm_windows_virtual_machine_scale_set` -// * `azurerm_virtual_machine_scale_set_extension` -// -// This feature-toggle defaults to off in 1.x versions of the Azure Provider, however this will -// become enabled by default in version 2.0 of the Azure Provider (where this toggle will be removed). -// As outlined in the announcement for v2.0 of the Azure Provider: -// https://github.com/terraform-providers/terraform-provider-azurerm/issues/2807 -// -// Operators wishing to beta-test these resources can opt-into them in 1.x versions of the -// Azure Provider by setting the Environment Variable 'ARM_PROVIDER_TWOPOINTZERO_RESOURCES' to 'true' -func SupportsTwoPointZeroResources() bool { - return true -} diff --git a/azurerm/internal/services/compute/registration.go b/azurerm/internal/services/compute/registration.go index 5ab1ab2bdfe8..01e7eb742a91 100644 --- a/azurerm/internal/services/compute/registration.go +++ b/azurerm/internal/services/compute/registration.go @@ -2,7 +2,6 @@ package compute import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" ) type Registration struct{} @@ -64,14 +63,5 @@ func (r Registration) SupportedResources() map[string]*schema.Resource { "azurerm_windows_virtual_machine_scale_set": resourceArmWindowsVirtualMachineScaleSet(), } - // 2.0 resources - if features.SupportsTwoPointZeroResources() { - resources["azurerm_linux_virtual_machine"] = resourceLinuxVirtualMachine() - resources["azurerm_linux_virtual_machine_scale_set"] = resourceArmLinuxVirtualMachineScaleSet() - resources["azurerm_virtual_machine_scale_set_extension"] = resourceArmVirtualMachineScaleSetExtension() - resources["azurerm_windows_virtual_machine"] = resourceWindowsVirtualMachine() - resources["azurerm_windows_virtual_machine_scale_set"] = resourceArmWindowsVirtualMachineScaleSet() - } - return resources } From d72fe54b90d37bd4cf46764a0e24cc793fcee072 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Mon, 9 Mar 2020 11:45:50 +0100 Subject: [PATCH 30/92] tidying --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf7d04e47bc..99630a06bcac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,8 @@ FEATURES: IMPROVEMENTS: -batch: upgrading to API version `2019-08-01` [GH-5967] -netapp: upgrading to API version `2019-10-01` [GH-5485] +* batch: upgrading to API version `2019-08-01` [GH-5967] +* netapp: upgrading to API version `2019-10-01` [GH-5485] * `azurerm_application_gateway` - support up to `125` for the `capacity` property with V2 SKU's [GH-5906] * `azurerm_automation_dsc_configuration` - support for the `tags` property [GH-5827] * `azurerm_batch_pool` - support for the `public_ips` property [GH-5967] @@ -41,7 +41,6 @@ netapp: upgrading to API version `2019-10-01` [GH-5485] * `azurerm_storage_account` - support up to 50 tags [GH-5934] * `azurerm_virtual_wan` - support for the `type` property [GH-5877] - BUG FIXES: * `azurerm_app_service_plan` - no longer sends an empty `app_service_environment_id` property on update [GH-5915] @@ -53,7 +52,6 @@ BUG FIXES: * `azurerm_linux_virtual_machine_scale_set` - correct `source_image_id` validation [GH-5901] * `azurerm_netapp_volume` - support volmes uoto `100TB` in size [GH-5485] * `azurerm_search_service` - changing the properties `replica_count` & `partition_count` properties no longer force a new resource [GH-5935] -* `azurerm_app_service_plan` - Updates no longer fail if App Service Environment ID is not specified [GH-5915] ## 2.0.0 (February 24, 2020) From d1aaa51be0d094b74851f47ab7162114ae5594a9 Mon Sep 17 00:00:00 2001 From: Yuping Wei <56525716+yupwei68@users.noreply.github.com> Date: Tue, 10 Mar 2020 03:19:44 +0800 Subject: [PATCH 31/92] =?UTF-8?q?`azurerm=5Fsql=5Fserver`=20-=20support=20?= =?UTF-8?q?for=20the=20`extended=5Fauditing=5Fpolic=E2=80=A6=20(#5036)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #2217 --- .../internal/services/sql/client/client.go | 37 +++--- .../sql/helper/sqlExtendedAuditing.go | 98 ++++++++++++++ .../services/sql/resource_arm_sql_server.go | 22 ++++ .../sql/tests/resource_arm_sql_server_test.go | 120 ++++++++++++++++++ website/docs/r/sql_server.html.markdown | 31 ++++- 5 files changed, 291 insertions(+), 17 deletions(-) create mode 100644 azurerm/internal/services/sql/helper/sqlExtendedAuditing.go diff --git a/azurerm/internal/services/sql/client/client.go b/azurerm/internal/services/sql/client/client.go index 5510353d4680..7e47528b4cfc 100644 --- a/azurerm/internal/services/sql/client/client.go +++ b/azurerm/internal/services/sql/client/client.go @@ -6,14 +6,15 @@ import ( ) type Client struct { - DatabasesClient *sql.DatabasesClient - DatabaseThreatDetectionPoliciesClient *sql.DatabaseThreatDetectionPoliciesClient - ElasticPoolsClient *sql.ElasticPoolsClient - FirewallRulesClient *sql.FirewallRulesClient - FailoverGroupsClient *sql.FailoverGroupsClient - ServersClient *sql.ServersClient - ServerAzureADAdministratorsClient *sql.ServerAzureADAdministratorsClient - VirtualNetworkRulesClient *sql.VirtualNetworkRulesClient + DatabasesClient *sql.DatabasesClient + DatabaseThreatDetectionPoliciesClient *sql.DatabaseThreatDetectionPoliciesClient + ElasticPoolsClient *sql.ElasticPoolsClient + FirewallRulesClient *sql.FirewallRulesClient + FailoverGroupsClient *sql.FailoverGroupsClient + ServersClient *sql.ServersClient + ServerAzureADAdministratorsClient *sql.ServerAzureADAdministratorsClient + VirtualNetworkRulesClient *sql.VirtualNetworkRulesClient + ExtendedServerBlobAuditingPoliciesClient *sql.ExtendedServerBlobAuditingPoliciesClient } func NewClient(o *common.ClientOptions) *Client { @@ -42,14 +43,18 @@ func NewClient(o *common.ClientOptions) *Client { VirtualNetworkRulesClient := sql.NewVirtualNetworkRulesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&VirtualNetworkRulesClient.Client, o.ResourceManagerAuthorizer) + ExtendedServerBlobAuditingPoliciesClient := sql.NewExtendedServerBlobAuditingPoliciesClient(o.SubscriptionId) + o.ConfigureClient(&ExtendedServerBlobAuditingPoliciesClient.Client, o.ResourceManagerAuthorizer) + return &Client{ - DatabasesClient: &DatabasesClient, - DatabaseThreatDetectionPoliciesClient: &DatabaseThreatDetectionPoliciesClient, - ElasticPoolsClient: &ElasticPoolsClient, - FailoverGroupsClient: &FailoverGroupsClient, - FirewallRulesClient: &FirewallRulesClient, - ServersClient: &ServersClient, - ServerAzureADAdministratorsClient: &ServerAzureADAdministratorsClient, - VirtualNetworkRulesClient: &VirtualNetworkRulesClient, + DatabasesClient: &DatabasesClient, + DatabaseThreatDetectionPoliciesClient: &DatabaseThreatDetectionPoliciesClient, + ElasticPoolsClient: &ElasticPoolsClient, + FailoverGroupsClient: &FailoverGroupsClient, + FirewallRulesClient: &FirewallRulesClient, + ServersClient: &ServersClient, + ServerAzureADAdministratorsClient: &ServerAzureADAdministratorsClient, + VirtualNetworkRulesClient: &VirtualNetworkRulesClient, + ExtendedServerBlobAuditingPoliciesClient: &ExtendedServerBlobAuditingPoliciesClient, } } diff --git a/azurerm/internal/services/sql/helper/sqlExtendedAuditing.go b/azurerm/internal/services/sql/helper/sqlExtendedAuditing.go new file mode 100644 index 000000000000..b7129a628f9e --- /dev/null +++ b/azurerm/internal/services/sql/helper/sqlExtendedAuditing.go @@ -0,0 +1,98 @@ +package helper + +import ( + "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql" + "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 ExtendedAuditingSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "storage_account_access_key": { + Type: schema.TypeString, + Required: true, + Sensitive: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "storage_endpoint": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.IsURLWithHTTPS, + }, + + "storage_account_access_key_is_secondary": { + Type: schema.TypeBool, + Optional: true, + }, + + "retention_in_days": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(0, 3285), + }, + }, + }, + } +} + +func ExpandAzureRmSqlServerBlobAuditingPolicies(input []interface{}) *sql.ExtendedServerBlobAuditingPolicyProperties { + if len(input) == 0 { + return &sql.ExtendedServerBlobAuditingPolicyProperties{ + State: sql.BlobAuditingPolicyStateDisabled, + } + } + serverBlobAuditingPolicies := input[0].(map[string]interface{}) + + ExtendedServerBlobAuditingPolicyProperties := sql.ExtendedServerBlobAuditingPolicyProperties{ + State: sql.BlobAuditingPolicyStateEnabled, + StorageAccountAccessKey: utils.String(serverBlobAuditingPolicies["storage_account_access_key"].(string)), + StorageEndpoint: utils.String(serverBlobAuditingPolicies["storage_endpoint"].(string)), + } + if v, ok := serverBlobAuditingPolicies["storage_account_access_key_is_secondary"]; ok { + ExtendedServerBlobAuditingPolicyProperties.IsStorageSecondaryKeyInUse = utils.Bool(v.(bool)) + } + if v, ok := serverBlobAuditingPolicies["retention_in_days"]; ok { + ExtendedServerBlobAuditingPolicyProperties.RetentionDays = utils.Int32(int32(v.(int))) + } + + return &ExtendedServerBlobAuditingPolicyProperties +} + +func FlattenAzureRmSqlServerBlobAuditingPolicies(extendedServerBlobAuditingPolicy *sql.ExtendedServerBlobAuditingPolicy, d *schema.ResourceData) []interface{} { + if extendedServerBlobAuditingPolicy == nil || extendedServerBlobAuditingPolicy.State == sql.BlobAuditingPolicyStateDisabled { + return []interface{}{} + } + var storageEndpoint, storageAccessKey string + // storage_account_access_key will not be returned, so we transfer the schema value + if v, ok := d.GetOk("extended_auditing_policy.0.storage_account_access_key"); ok { + storageAccessKey = v.(string) + } + if extendedServerBlobAuditingPolicy.StorageEndpoint != nil { + storageEndpoint = *extendedServerBlobAuditingPolicy.StorageEndpoint + } + + var secondKeyInUse bool + if extendedServerBlobAuditingPolicy.IsStorageSecondaryKeyInUse != nil { + secondKeyInUse = *extendedServerBlobAuditingPolicy.IsStorageSecondaryKeyInUse + } + var retentionDays int32 + if extendedServerBlobAuditingPolicy.RetentionDays != nil { + retentionDays = *extendedServerBlobAuditingPolicy.RetentionDays + } + + return []interface{}{ + map[string]interface{}{ + "storage_account_access_key": storageAccessKey, + "storage_endpoint": storageEndpoint, + "storage_account_access_key_is_secondary": secondKeyInUse, + "retention_in_days": retentionDays, + }, + } +} diff --git a/azurerm/internal/services/sql/resource_arm_sql_server.go b/azurerm/internal/services/sql/resource_arm_sql_server.go index 648b3a820ed1..93ba4d02b7ef 100644 --- a/azurerm/internal/services/sql/resource_arm_sql_server.go +++ b/azurerm/internal/services/sql/resource_arm_sql_server.go @@ -13,6 +13,7 @@ import ( "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/sql/helper" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" @@ -100,6 +101,8 @@ func resourceArmSqlServer() *schema.Resource { }, }, + "extended_auditing_policy": helper.ExtendedAuditingSchema(), + "tags": tags.Schema(), }, } @@ -171,6 +174,14 @@ func resourceArmSqlServerCreateUpdate(d *schema.ResourceData, meta interface{}) d.SetId(*resp.ID) + auditingClient := meta.(*clients.Client).Sql.ExtendedServerBlobAuditingPoliciesClient + auditingProps := sql.ExtendedServerBlobAuditingPolicy{ + ExtendedServerBlobAuditingPolicyProperties: helper.ExpandAzureRmSqlServerBlobAuditingPolicies(d.Get("extended_auditing_policy").([]interface{})), + } + if _, err = auditingClient.CreateOrUpdate(ctx, resGroup, name, auditingProps); err != nil { + return fmt.Errorf("Error issuing create/update request for SQL Server %q Blob Auditing Policies(Resource Group %q): %+v", name, resGroup, err) + } + return resourceArmSqlServerRead(d, meta) } @@ -214,6 +225,17 @@ func resourceArmSqlServerRead(d *schema.ResourceData, meta interface{}) error { d.Set("fully_qualified_domain_name", serverProperties.FullyQualifiedDomainName) } + auditingClient := meta.(*clients.Client).Sql.ExtendedServerBlobAuditingPoliciesClient + auditingResp, err := auditingClient.Get(ctx, resGroup, name) + if err != nil { + return fmt.Errorf("Error reading SQL Server %s Blob Auditing Policies: %v ", name, err) + } + + flattenBlobAuditing := helper.FlattenAzureRmSqlServerBlobAuditingPolicies(&auditingResp, d) + if err := d.Set("extended_auditing_policy", flattenBlobAuditing); err != nil { + return fmt.Errorf("Error setting `extended_auditing_policy`: %+v", err) + } + return tags.FlattenAndSet(d, resp.Tags) } diff --git a/azurerm/internal/services/sql/tests/resource_arm_sql_server_test.go b/azurerm/internal/services/sql/tests/resource_arm_sql_server_test.go index 0ab1cfd03ae5..fce99e68a152 100644 --- a/azurerm/internal/services/sql/tests/resource_arm_sql_server_test.go +++ b/azurerm/internal/services/sql/tests/resource_arm_sql_server_test.go @@ -171,6 +171,36 @@ func TestAccAzureRMSqlServer_updateWithIdentityAdded(t *testing.T) { }) } +func TestAccAzureRMSqlServer_updateWithBlobAuditingPolices(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_sql_server", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMSqlServerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMSqlServer_withBlobAuditingPolices(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMSqlServerExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "extended_auditing_policy.0.storage_account_access_key_is_secondary", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "extended_auditing_policy.0.retention_in_days", "6"), + ), + }, + data.ImportStep("administrator_login_password", "extended_auditing_policy.0.storage_account_access_key"), + { + Config: testAccAzureRMSqlServer_withBlobAuditingPolicesUpdated(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMSqlServerExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "extended_auditing_policy.0.storage_account_access_key_is_secondary", "false"), + resource.TestCheckResourceAttr(data.ResourceName, "extended_auditing_policy.0.retention_in_days", "11"), + ), + }, + data.ImportStep("administrator_login_password", "extended_auditing_policy.0.storage_account_access_key"), + }, + }) +} + func testCheckAzureRMSqlServerExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { conn := acceptance.AzureProvider.Meta().(*clients.Client).Sql.ServersClient @@ -366,3 +396,93 @@ resource "azurerm_sql_server" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func testAccAzureRMSqlServer_withBlobAuditingPolices(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-sql-%[1]d" + location = "%[2]s" +} + +resource "azurerm_storage_account" "test" { + name = "acctest%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_storage_account" "test2" { + name = "acctest2%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_sql_server" "test" { + name = "acctestsqlserver%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + version = "12.0" + administrator_login = "mradministrator" + administrator_login_password = "thisIsDog11" + + extended_auditing_policy { + storage_account_access_key = azurerm_storage_account.test.primary_access_key + storage_endpoint = azurerm_storage_account.test.primary_blob_endpoint + storage_account_access_key_is_secondary = true + retention_in_days = 6 + } +} +`, data.RandomIntOfLength(15), data.Locations.Primary) +} + +func testAccAzureRMSqlServer_withBlobAuditingPolicesUpdated(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-sql-%[1]d" + location = "%[2]s" +} + +resource "azurerm_storage_account" "test" { + name = "acctest%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_storage_account" "test2" { + name = "acctest2%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_sql_server" "test" { + name = "acctestsqlserver%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + version = "12.0" + administrator_login = "mradministrator" + administrator_login_password = "thisIsDog11" + + extended_auditing_policy { + storage_account_access_key = azurerm_storage_account.test2.primary_access_key + storage_endpoint = azurerm_storage_account.test2.primary_blob_endpoint + storage_account_access_key_is_secondary = false + retention_in_days = 11 + } +} +`, data.RandomIntOfLength(15), data.Locations.Primary) +} diff --git a/website/docs/r/sql_server.html.markdown b/website/docs/r/sql_server.html.markdown index 5f258b06835d..3e41f9cbdc69 100644 --- a/website/docs/r/sql_server.html.markdown +++ b/website/docs/r/sql_server.html.markdown @@ -22,6 +22,14 @@ resource "azurerm_resource_group" "example" { location = "West US" } +resource "azurerm_storage_account" "example" { + name = "examplesa" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location + account_tier = "Standard" + account_replication_type = "LRS" +} + resource "azurerm_sql_server" "example" { name = "mysqlserver" resource_group_name = azurerm_resource_group.example.name @@ -30,6 +38,13 @@ resource "azurerm_sql_server" "example" { administrator_login = "mradministrator" administrator_login_password = "thisIsDog11" + extended_auditing_policy { + storage_endpoint = azurerm_storage_account.example.primary_blob_endpoint + storage_account_access_key = azurerm_storage_account.example.primary_access_key + storage_account_access_key_is_secondary = true + retention_in_days = 6 + } + tags = { environment = "production" } @@ -53,6 +68,8 @@ The following arguments are supported: * `identity` - (Optional) An `identity` block as defined below. +* `extended_auditing_policy` - (Optional) A `extended_auditing_policy` block as defined below. + * `tags` - (Optional) A mapping of tags to assign to the resource. --- @@ -80,7 +97,19 @@ The following attributes are exported: -> You can access the Principal ID via `${azurerm_sql_server.example.identity.0.principal_id}` and the Tenant ID via `${azurerm_sql_server.example.identity.0.tenant_id}` -## Timeouts +--- + +A `extended_auditing_policy` block supports the following: + +* `storage_account_access_key` - (Required) Specifies the access key to use for the auditing storage account. + +* `storage_endpoint` - (Required) Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). + +* `storage_account_access_key_is_secondary` - (Optional) Specifies whether `storage_account_access_key` value is the storage's secondary key. + +* `retention_in_days` - (Optional) Specifies the number of days to retain logs for in the storage account. + +### Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: From a2cba86c2f1569da95b902093060049c28e5e113 Mon Sep 17 00:00:00 2001 From: kt Date: Mon, 9 Mar 2020 12:20:32 -0700 Subject: [PATCH 32/92] Update CHANGELOG.md to include #5036 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99630a06bcac..7a8408a379f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ IMPROVEMENTS: * `azurerm_private_dns_srv_record` - export the `fqdn` property [GH-5949] * `azurerm_private_endpoint` - exposed `private_ip_address` as a computed attribute [GH-5838] * `azurerm_redis_cache` - support for the `primary_connection_string` and `secondary_connection_string` properties [GH-5958] +* `azurerm_sql_server` - support for the `extended_auditing_policy` property [GH-5036] * `azurerm_storage_account` - support up to 50 tags [GH-5934] * `azurerm_virtual_wan` - support for the `type` property [GH-5877] From d9d355839c4e7e92a29ff41c1c6f3d7c5f33d412 Mon Sep 17 00:00:00 2001 From: magodo Date: Tue, 10 Mar 2020 04:26:08 +0800 Subject: [PATCH 33/92] =?UTF-8?q?azurerm=5Fnetwork=5Fwatcher=5Fflow=5Flog?= =?UTF-8?q?=20=20-=20support=20for=20the`interval=5Fin=E2=80=A6=20(#5851)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fix issue #5830 Additionally, fix one bug of example in document, which lacks of specifying account_kind to StorageV2 (which defaults to v1) for storage account, which is required by azurerm_log_analytics_workspace. --- .../resource_arm_network_watcher_flow_log.go | 20 +++++-- ...ource_arm_network_watcher_flow_log_test.go | 58 +++++++++++++++++++ .../r/network_watcher_flow_log.html.markdown | 3 + 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/network/resource_arm_network_watcher_flow_log.go b/azurerm/internal/services/network/resource_arm_network_watcher_flow_log.go index e98419ee6c4c..3f089f552b45 100644 --- a/azurerm/internal/services/network/resource_arm_network_watcher_flow_log.go +++ b/azurerm/internal/services/network/resource_arm_network_watcher_flow_log.go @@ -141,6 +141,13 @@ func resourceArmNetworkWatcherFlowLog() *schema.Resource { Required: true, ValidateFunc: azure.ValidateResourceIDOrEmpty, }, + + "interval_in_minutes": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.IntInSlice([]int{10, 60}), + Default: 60, + }, }, }, }, @@ -386,6 +393,9 @@ func flattenAzureRmNetworkWatcherFlowLogTrafficAnalytics(input *network.TrafficA if cfg.WorkspaceResourceID != nil { result["workspace_resource_id"] = *cfg.WorkspaceResourceID } + if cfg.TrafficAnalyticsInterval != nil { + result["interval_in_minutes"] = int(*cfg.TrafficAnalyticsInterval) + } } return []interface{}{result} @@ -399,13 +409,15 @@ func expandAzureRmNetworkWatcherFlowLogTrafficAnalytics(d *schema.ResourceData) workspaceID := v["workspace_id"].(string) workspaceRegion := v["workspace_region"].(string) workspaceResourceID := v["workspace_resource_id"].(string) + interval := v["interval_in_minutes"].(int) return &network.TrafficAnalyticsProperties{ NetworkWatcherFlowAnalyticsConfiguration: &network.TrafficAnalyticsConfigurationProperties{ - Enabled: utils.Bool(enabled), - WorkspaceID: utils.String(workspaceID), - WorkspaceRegion: utils.String(workspaceRegion), - WorkspaceResourceID: utils.String(workspaceResourceID), + Enabled: utils.Bool(enabled), + WorkspaceID: utils.String(workspaceID), + WorkspaceRegion: utils.String(workspaceRegion), + WorkspaceResourceID: utils.String(workspaceResourceID), + TrafficAnalyticsInterval: utils.Int32(int32(interval)), }, } } diff --git a/azurerm/internal/services/network/tests/resource_arm_network_watcher_flow_log_test.go b/azurerm/internal/services/network/tests/resource_arm_network_watcher_flow_log_test.go index 4259d5c26303..091bcbc7a390 100644 --- a/azurerm/internal/services/network/tests/resource_arm_network_watcher_flow_log_test.go +++ b/azurerm/internal/services/network/tests/resource_arm_network_watcher_flow_log_test.go @@ -228,6 +228,7 @@ func testAccAzureRMNetworkWatcherFlowLog_trafficAnalytics(t *testing.T) { resource.TestCheckResourceAttr(data.ResourceName, "enabled", "true"), ), }, + data.ImportStep(), { Config: testAccAzureRMNetworkWatcherFlowLog_TrafficAnalyticsEnabledConfig(data), Check: resource.ComposeTestCheckFunc( @@ -242,6 +243,28 @@ func testAccAzureRMNetworkWatcherFlowLog_trafficAnalytics(t *testing.T) { resource.TestCheckResourceAttr(data.ResourceName, "enabled", "true"), resource.TestCheckResourceAttr(data.ResourceName, "traffic_analytics.#", "1"), resource.TestCheckResourceAttr(data.ResourceName, "traffic_analytics.0.enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "traffic_analytics.0.interval_in_minutes", "60"), + resource.TestCheckResourceAttrSet(data.ResourceName, "traffic_analytics.0.workspace_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "traffic_analytics.0.workspace_region"), + resource.TestCheckResourceAttrSet(data.ResourceName, "traffic_analytics.0.workspace_resource_id"), + ), + }, + data.ImportStep(), + { + Config: testAccAzureRMNetworkWatcherFlowLog_TrafficAnalyticsUpdateInterval(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMNetworkWatcherFlowLogExists(data.ResourceName), + resource.TestCheckResourceAttrSet(data.ResourceName, "network_watcher_name"), + resource.TestCheckResourceAttrSet(data.ResourceName, "resource_group_name"), + resource.TestCheckResourceAttrSet(data.ResourceName, "network_security_group_id"), + resource.TestCheckResourceAttrSet(data.ResourceName, "storage_account_id"), + resource.TestCheckResourceAttr(data.ResourceName, "retention_policy.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "retention_policy.0.enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "retention_policy.0.days", "7"), + resource.TestCheckResourceAttr(data.ResourceName, "enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "traffic_analytics.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "traffic_analytics.0.enabled", "true"), + resource.TestCheckResourceAttr(data.ResourceName, "traffic_analytics.0.interval_in_minutes", "10"), resource.TestCheckResourceAttrSet(data.ResourceName, "traffic_analytics.0.workspace_id"), resource.TestCheckResourceAttrSet(data.ResourceName, "traffic_analytics.0.workspace_region"), resource.TestCheckResourceAttrSet(data.ResourceName, "traffic_analytics.0.workspace_resource_id"), @@ -492,6 +515,41 @@ resource "azurerm_network_watcher_flow_log" "test" { `, testAccAzureRMNetworkWatcherFlowLog_prerequisites(data), data.RandomInteger) } +func testAccAzureRMNetworkWatcherFlowLog_TrafficAnalyticsUpdateInterval(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_log_analytics_workspace" "test" { + name = "acctestLAW-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "PerGB2018" +} + +resource "azurerm_network_watcher_flow_log" "test" { + network_watcher_name = "${azurerm_network_watcher.test.name}" + resource_group_name = "${azurerm_resource_group.test.name}" + + network_security_group_id = "${azurerm_network_security_group.test.id}" + storage_account_id = "${azurerm_storage_account.test.id}" + enabled = true + + retention_policy { + enabled = true + days = 7 + } + + traffic_analytics { + enabled = true + workspace_id = "${azurerm_log_analytics_workspace.test.workspace_id}" + workspace_region = "${azurerm_log_analytics_workspace.test.location}" + workspace_resource_id = "${azurerm_log_analytics_workspace.test.id}" + interval_in_minutes = 10 + } +} +`, testAccAzureRMNetworkWatcherFlowLog_prerequisites(data), data.RandomInteger) +} + func testAccAzureRMNetworkWatcherFlowLog_TrafficAnalyticsDisabledConfig(data acceptance.TestData) string { return fmt.Sprintf(` %s diff --git a/website/docs/r/network_watcher_flow_log.html.markdown b/website/docs/r/network_watcher_flow_log.html.markdown index 44c0a42852a4..2e2c91ee9346 100644 --- a/website/docs/r/network_watcher_flow_log.html.markdown +++ b/website/docs/r/network_watcher_flow_log.html.markdown @@ -37,6 +37,7 @@ resource "azurerm_storage_account" "test" { location = azurerm_resource_group.test.location account_tier = "Standard" + account_kind = "StorageV2" account_replication_type = "LRS" enable_https_traffic_only = true } @@ -66,6 +67,7 @@ resource "azurerm_network_watcher_flow_log" "test" { workspace_id = azurerm_log_analytics_workspace.test.workspace_id workspace_region = azurerm_log_analytics_workspace.test.location workspace_resource_id = azurerm_log_analytics_workspace.test.id + interval_in_minutes = 10 } } ``` @@ -105,6 +107,7 @@ The following arguments are supported: * `workspace_id` - (Required) The resource guid of the attached workspace. * `workspace_region` - (Required) The location of the attached workspace. * `workspace_resource_id` - (Required) The resource ID of the attached workspace. +* `interval_in_minutes` - (Optional) How frequently service should do flow analytics in minutes. ## Attributes Reference From 321a4fbac125be26b181eaab3161fa7b3b54d4a0 Mon Sep 17 00:00:00 2001 From: kt Date: Mon, 9 Mar 2020 13:27:27 -0700 Subject: [PATCH 34/92] Update CHANGELOG.md to include #5851 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a8408a379f7..b15039d367d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ IMPROVEMENTS: * `azurerm_netapp_volume` - support for the `tags` property [GH-5995] * `azurerm_netapp_volume` - support for the `protocol_types` property [GH-5485] * `azurerm_netapp_volume` - deprecated the `cifs_enabled`, `nfsv3_enabled`, and `nfsv4_enabled` properties in favour of `protocols_enabled` [GH-5485] +* `azurerm_network_watcher_flow_log` - support for the traffic analysis `interval_in_minutes` property [GH-5851] * `azurerm_private_dns_a_record` - export the `fqdn` property [GH-5949] * `azurerm_private_dns_aaaa_record` - export the `fqdn` property [GH-5949] * `azurerm_private_dns_cname_record` - export the `fqdn` property [GH-5949] From c63b56911a022d6af8696a026b54b64e763ba3f0 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 16:07:35 +0100 Subject: [PATCH 35/92] bump CDN api version --- .../internal/services/cdn/client/client.go | 2 +- .../services/cdn/resource_arm_cdn_endpoint.go | 4 +- .../services/cdn/resource_arm_cdn_profile.go | 2 +- .../cdn/mgmt/2017-10-12/cdn/models.go | 3305 ---------- .../{2017-10-12 => 2019-04-15}/cdn/client.go | 8 +- .../cdn/customdomains.go | 12 +- .../cdn/edgenodes.go | 2 +- .../cdn/endpoints.go | 22 +- .../cdn/mgmt/2019-04-15/cdn/models.go | 5859 +++++++++++++++++ .../cdn/operations.go | 2 +- .../{2017-10-12 => 2019-04-15}/cdn/origins.go | 6 +- .../cdn/profiles.go | 18 +- .../cdn/resourceusage.go | 2 +- .../{2017-10-12 => 2019-04-15}/cdn/version.go | 2 +- vendor/modules.txt | 2 +- 15 files changed, 5902 insertions(+), 3346 deletions(-) delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn/models.go rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/client.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/customdomains.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/edgenodes.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/endpoints.go (99%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn/models.go rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/operations.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/origins.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/profiles.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/resourceusage.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/{2017-10-12 => 2019-04-15}/cdn/version.go (94%) 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/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index cf4b9cb39983..ccad38c087c2 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" @@ -197,6 +197,8 @@ func resourceArmCdnEndpoint() *schema.Resource { Computed: true, }, + "delivery_policy": EndpointDeliveryPolicy(), + "tags": tags.Schema(), }, } 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/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 df3714c94d58..423a5b0f186b 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 @@ -100,7 +100,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, } @@ -268,7 +268,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 7fe0bdd42003..98a215398ac0 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 @@ -95,7 +95,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, } @@ -281,7 +281,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, } @@ -373,7 +373,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, } @@ -467,7 +467,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, } @@ -555,7 +555,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 11f184afda4e..4301bf55001d 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 @@ -76,7 +76,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 1b780ee65646..9d7e2925cfb1 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 @@ -94,7 +94,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, } @@ -277,7 +277,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, } @@ -363,7 +363,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, } @@ -488,7 +488,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, } @@ -610,7 +610,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, } @@ -703,7 +703,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, } @@ -791,7 +791,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, } @@ -878,7 +878,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, } @@ -968,7 +968,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, } @@ -1066,7 +1066,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 c6c4ee5e5446..07e8d0c31a6d 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 @@ -76,7 +76,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 0fe220e021e2..a3982f327053 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 @@ -97,7 +97,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, } @@ -306,7 +306,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 77b127b13d3b..cf3de82123e5 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 @@ -90,7 +90,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, } @@ -271,7 +271,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, } @@ -356,7 +356,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, } @@ -429,7 +429,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, } @@ -550,7 +550,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, } @@ -673,7 +673,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, } @@ -796,7 +796,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, } @@ -877,7 +877,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 42995a73dbd0..ada2d799c88f 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 @@ -80,7 +80,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 1f3baf5b6381..2d0d3729bc0f 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 From 6208d2479cec4bda583bd734452fefb12c5cac00 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 16:15:49 +0100 Subject: [PATCH 36/92] add delivery policy rule name validation function --- azurerm/helpers/validate/cdn.go | 14 +++++++ azurerm/helpers/validate/cdn_test.go | 60 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 azurerm/helpers/validate/cdn.go create mode 100644 azurerm/helpers/validate/cdn_test.go diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go new file mode 100644 index 000000000000..9988317d34a6 --- /dev/null +++ b/azurerm/helpers/validate/cdn.go @@ -0,0 +1,14 @@ +package validate + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "regexp" +) + +func CdnEndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$"), + "The Delivery Policy Rule Name must start with a letter any may only contain letters and numbers.", + ) +} diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go new file mode 100644 index 000000000000..d3b7807e0b6a --- /dev/null +++ b/azurerm/helpers/validate/cdn_test.go @@ -0,0 +1,60 @@ +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 := CdnEndpointDeliveryPolicyRuleName()(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)) + } + }) + } +} From ebb683a20fbe624296fac7e9ea64243355c9eefb Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 20:34:09 +0100 Subject: [PATCH 37/92] add endpoint delivery policy, rule, request schema condition and url redirect action --- azurerm/helpers/validate/cdn.go | 44 +++++- azurerm/helpers/validate/cdn_test.go | 133 ++++++++++++++++++ .../cdn/endpoint_delivery_policy_rule.go | 39 +++++ .../services/cdn/endpont_delivery_policy.go | 28 ++++ .../services/cdn/rule_action_url_redirect.go | 58 ++++++++ .../cdn/rule_condition_request_scheme.go | 38 +++++ 6 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go create mode 100644 azurerm/internal/services/cdn/endpont_delivery_policy.go create mode 100644 azurerm/internal/services/cdn/rule_action_url_redirect.go create mode 100644 azurerm/internal/services/cdn/rule_condition_request_scheme.go diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index 9988317d34a6..9c733d807a47 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -1,9 +1,12 @@ package validate import ( + "fmt" + "regexp" + "strings" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "regexp" ) func CdnEndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { @@ -12,3 +15,42 @@ func CdnEndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { "The Delivery Policy Rule Name must start with a letter any may only contain letters and numbers.", ) } + +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.Compile("^[?&]") + if re.MatchString(querystring) { + return nil, []error{fmt.Errorf("The Url Query String must not start with a question mark or ampersand.")} + } + + kvre, _ := regexp.Compile("^[^?&]+=[^?&]+$") + 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 Redirect Path must start with a slash.", + ) +} diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go index d3b7807e0b6a..aded6923d74f 100644 --- a/azurerm/helpers/validate/cdn_test.go +++ b/azurerm/helpers/validate/cdn_test.go @@ -58,3 +58,136 @@ func TestCdnEndpointDeliveryPolicyRuleName(t *testing.T) { }) } } + +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, "name") + + 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, "name") + + 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, "name") + + 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)) + } + }) + } +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go new file mode 100644 index 000000000000..78bf84b6e186 --- /dev/null +++ b/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go @@ -0,0 +1,39 @@ +package cdn + +import ( + "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" +) + +func EndpointDeliveryRule() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), + }, + + "order": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "request_scheme_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: RuleConditionRequestScheme(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: RuleActionUrlRedirect(), + }, + }, + } +} diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go new file mode 100644 index 000000000000..d38a97de6402 --- /dev/null +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -0,0 +1,28 @@ +package cdn + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +) + +func EndpointDeliveryPolicy() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Required: false, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Required: false, + }, + + "delivery_rule": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: EndpointDeliveryRule(), + }, + }, + }, + } +} diff --git a/azurerm/internal/services/cdn/rule_action_url_redirect.go b/azurerm/internal/services/cdn/rule_action_url_redirect.go new file mode 100644 index 000000000000..38b2f163426d --- /dev/null +++ b/azurerm/internal/services/cdn/rule_action_url_redirect.go @@ -0,0 +1,58 @@ +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" +) + +func RuleActionUrlRedirect() *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), + }, + + "destination_protocol": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.MatchRequest), + string(cdn.HTTP), + string(cdn.HTTPS), + }, false), + }, + + "hostname": { + Type: schema.TypeString, + Required: false, + }, + + "path": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "query_string": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "fragment": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectFragment(), + }, + }, + } +} diff --git a/azurerm/internal/services/cdn/rule_condition_request_scheme.go b/azurerm/internal/services/cdn/rule_condition_request_scheme.go new file mode 100644 index 000000000000..e6db5bea7a3c --- /dev/null +++ b/azurerm/internal/services/cdn/rule_condition_request_scheme.go @@ -0,0 +1,38 @@ +package cdn + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" +) + +func RuleConditionRequestScheme() *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.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + ValidateFunc: validation.StringInSlice([]string{ + "HTTP", + "HTTPS", + }, false), + }, + }, + } +} From 1354fcfa7bff27d00c1172e50dc363a6d3edb2d1 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 20:48:18 +0100 Subject: [PATCH 38/92] allow max 5 rules per delivery policy --- azurerm/internal/services/cdn/endpont_delivery_policy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index d38a97de6402..b9fa81c4a26f 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -20,6 +20,7 @@ func EndpointDeliveryPolicy() *schema.Schema { Type: schema.TypeList, Required: true, MinItems: 1, + MaxItems: 5, Elem: EndpointDeliveryRule(), }, }, From 13f3e95f317e5d5bec75713a0a2207736c6b47ef Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 22:03:38 +0100 Subject: [PATCH 39/92] rename delivery_rule to rule; allow max 4 rules (leave one spot for global rule) --- azurerm/internal/services/cdn/endpont_delivery_policy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index b9fa81c4a26f..598533e4f0c0 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -16,11 +16,11 @@ func EndpointDeliveryPolicy() *schema.Schema { Required: false, }, - "delivery_rule": { + "rule": { Type: schema.TypeList, Required: true, MinItems: 1, - MaxItems: 5, + MaxItems: 4, Elem: EndpointDeliveryRule(), }, }, From d344af3ad174f663db63530ef235e3d6efd3fcf7 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 1 Mar 2020 22:38:04 +0100 Subject: [PATCH 40/92] implement rad & update for delivery_policy --- .../services/cdn/resource_arm_cdn_endpoint.go | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index ccad38c087c2..cd9bd96078ce 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -238,6 +238,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) + deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -255,6 +256,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro IsCompressionEnabled: &compressionEnabled, QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), OriginHostHeader: utils.String(originHostHeader), + DeliveryPolicy: deliveryPolicy, }, Tags: tags.Expand(t), } @@ -315,6 +317,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) + deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -331,6 +334,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro IsCompressionEnabled: utils.Bool(compressionEnabled), QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), OriginHostHeader: utils.String(hostHeader), + DeliveryPolicy: deliveryPolicy, }, Tags: tags.Expand(t), } @@ -586,3 +590,108 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface return results } + +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { + policies := d.Get("delivery_policy").([]interface{}) + if len(policies) == 0 { + return nil + } + + deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} + + policy := policies[0].(map[string]interface{}) + if descr, ok := policy["description"]; ok { + deliveryPolicy.Description = utils.String(descr.(string)) + } + + rules := policy["rule"].([]interface{}) + deliveryRules := make([]cdn.DeliveryRule, len(rules)) + for i, rule := range rules { + deliveryRules[i] = expandArmCdnEndpointDeliveryPolicyRule(rule.(map[string]interface{})) + } + deliveryPolicy.Rules = &deliveryRules + + return &deliveryPolicy +} + +func expandArmCdnEndpointDeliveryPolicyRule(rule map[string]interface{}) cdn.DeliveryRule { + deliveryRule := cdn.DeliveryRule{ + Name: utils.String(rule["name"].(string)), + Order: utils.Int32(rule["order"].(int32)), + } + + conditions := make([]cdn.BasicDeliveryRuleCondition, 0) + + if rsc, ok := rule["request_scheme_condition"]; ok { + conditions = append(conditions, *expandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Conditions = &conditions + + actions := make([]cdn.BasicDeliveryRuleAction, 0) + + if ura, ok := rule["url_redirect_action"]; ok { + actions = append(actions, *expandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Actions = &actions + + return deliveryRule +} + +func expandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { + requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ + Name: cdn.NameRequestScheme, + } + + matchValues := rsc["match_values"].([]string) + params := cdn.RequestSchemeMatchConditionParameters{ + MatchValues: &matchValues, + } + + if operator, ok := rsc["operator"]; ok { + params.Operator = utils.String(operator.(string)) + } + + if negate, ok := rsc["negate_condition"]; ok { + params.NegateCondition = utils.Bool(negate.(bool)) + } + + requestSchemeCondition.Parameters = ¶ms + + return &requestSchemeCondition +} + +func expandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { + urlRedirectAction := cdn.URLRedirectAction{ + Name: cdn.NameURLRedirect, + } + + params := cdn.URLRedirectActionParameters{ + RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), + } + + if destProt, ok := ura["destination_protocol"]; ok { + params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) + } + + if hostname, ok := ura["hostname"]; ok { + params.CustomHostname = utils.String(hostname.(string)) + } + + if path, ok := ura["path"]; ok { + params.CustomPath = utils.String(path.(string)) + } + + if queryString, ok := ura["query_string"]; ok { + params.CustomQueryString = utils.String(queryString.(string)) + } + + if fragment, ok := ura["fragment"]; ok { + params.CustomFragment = utils.String(fragment.(string)) + } + + urlRedirectAction.Parameters = ¶ms + + return &urlRedirectAction +} From dedd4c717b4863d36303f350119e038c19b61145 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 14:12:42 +0100 Subject: [PATCH 41/92] move actions and condition into own dir; add flatten functions for url redirect action and request scheme condition --- .../cdn/delivery_rule_actions/url_redirect.go | 122 ++++++++++++++++++ .../request_scheme.go | 83 ++++++++++++ .../cdn/endpoint_delivery_policy_rule.go | 39 ------ .../services/cdn/endpoint_delivery_rule.go | 103 +++++++++++++++ .../services/cdn/endpont_delivery_policy.go | 47 +++++++ .../services/cdn/resource_arm_cdn_endpoint.go | 110 +--------------- .../services/cdn/rule_action_url_redirect.go | 58 --------- .../cdn/rule_condition_request_scheme.go | 38 ------ 8 files changed, 360 insertions(+), 240 deletions(-) create mode 100644 azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go create mode 100644 azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go delete mode 100644 azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go create mode 100644 azurerm/internal/services/cdn/endpoint_delivery_rule.go delete mode 100644 azurerm/internal/services/cdn/rule_action_url_redirect.go delete mode 100644 azurerm/internal/services/cdn/rule_condition_request_scheme.go diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go new file mode 100644 index 000000000000..e88b6e538c68 --- /dev/null +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -0,0 +1,122 @@ +package delivery_rule_actions + +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/utils" +) + +func RuleActionUrlRedirect() *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, + Required: false, + Default: string(cdn.MatchRequest), + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.MatchRequest), + string(cdn.HTTP), + string(cdn.HTTPS), + }, false), + }, + + "hostname": { + Type: schema.TypeString, + Required: false, + }, + + "path": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "query_string": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectPath(), + }, + + "fragment": { + Type: schema.TypeString, + Required: false, + ValidateFunc: validate.RuleActionUrlRedirectFragment(), + }, + }, + } +} + +func ExpandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { + urlRedirectAction := cdn.URLRedirectAction{ + Name: cdn.NameURLRedirect, + } + + params := cdn.URLRedirectActionParameters{ + RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), + } + + if destProt, ok := ura["protocol"]; ok { + params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) + } + + if hostname, ok := ura["hostname"]; ok { + params.CustomHostname = utils.String(hostname.(string)) + } + + if path, ok := ura["path"]; ok { + params.CustomPath = utils.String(path.(string)) + } + + if queryString, ok := ura["query_string"]; ok { + params.CustomQueryString = utils.String(queryString.(string)) + } + + if fragment, ok := ura["fragment"]; ok { + params.CustomFragment = utils.String(fragment.(string)) + } + + urlRedirectAction.Parameters = ¶ms + + return &urlRedirectAction +} + +func FlattenArmCdnEndpointActionUrlRedirect(ura *cdn.URLRedirectAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := ura.Parameters; params != nil { + res["redirect_type"] = string(params.RedirectType) + + res["protocol"] = string(params.DestinationProtocol) + + if params.CustomHostname != nil { + res["hostname"] = *params.CustomHostname + } + + if params.CustomPath != nil { + res["path"] = *params.CustomPath + } + + if params.CustomQueryString != nil { + res["query_string"] = *params.CustomQueryString + } + + if params.CustomFragment != nil { + res["fragment"] = *params.CustomFragment + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go new file mode 100644 index 000000000000..bc9863110510 --- /dev/null +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -0,0 +1,83 @@ +package delivery_rule_conditions + +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 RuleConditionRequestScheme() *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.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + ValidateFunc: validation.StringInSlice([]string{ + "HTTP", + "HTTPS", + }, false), + }, + }, + } +} + +func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { + requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ + Name: cdn.NameRequestScheme, + } + + matchValues := rsc["match_values"].([]string) + params := cdn.RequestSchemeMatchConditionParameters{ + MatchValues: &matchValues, + } + + if operator, ok := rsc["operator"]; ok { + params.Operator = utils.String(operator.(string)) + } + + if negate, ok := rsc["negate_condition"]; ok { + params.NegateCondition = utils.Bool(negate.(bool)) + } + + requestSchemeCondition.Parameters = ¶ms + + return &requestSchemeCondition +} + +func FlattenArmCdnEndpointConditionRequestScheme(condition *cdn.DeliveryRuleRequestSchemeCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := condition.Parameters; params != nil { + if params.Operator != nil { + res["operator"] = *params.Operator + } + + if params.NegateCondition != nil { + res["negate_condition"] = *params.NegateCondition + } + + if params.MatchValues != nil { + res["match_values"] = *params.MatchValues + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go deleted file mode 100644 index 78bf84b6e186..000000000000 --- a/azurerm/internal/services/cdn/endpoint_delivery_policy_rule.go +++ /dev/null @@ -1,39 +0,0 @@ -package cdn - -import ( - "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" -) - -func EndpointDeliveryRule() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), - }, - - "order": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, - - "request_scheme_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: RuleConditionRequestScheme(), - }, - - "url_redirect_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: RuleActionUrlRedirect(), - }, - }, - } -} 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..89f861dec5bb --- /dev/null +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -0,0 +1,103 @@ +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/delivery_rule_actions" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/delivery_rule_conditions" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func EndpointDeliveryRule() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), + }, + + "order": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "request_scheme_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_conditions.RuleConditionRequestScheme(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.RuleActionUrlRedirect(), + }, + }, + } +} + +func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryRule { + deliveryRule := cdn.DeliveryRule{ + Name: utils.String(rule["name"].(string)), + Order: utils.Int32(rule["order"].(int32)), + } + + conditions := make([]cdn.BasicDeliveryRuleCondition, 0) + + if rsc, ok := rule["request_scheme_condition"]; ok { + conditions = append(conditions, *delivery_rule_conditions.ExpandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Conditions = &conditions + + actions := make([]cdn.BasicDeliveryRuleAction, 0) + + if ura, ok := rule["url_redirect_action"]; ok { + actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + } + + deliveryRule.Actions = &actions + + return deliveryRule +} + +func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { + res := make(map[string]interface{}, 0) + + if deliveryRule == nil { + return res + } + + if deliveryRule.Name != nil { + res["name"] = *deliveryRule.Name + } + + if deliveryRule.Order != nil { + res["order"] = *deliveryRule.Order + } + + if deliveryRule.Conditions != nil { + for _, basicDeliveryRuleCondition := range *deliveryRule.Conditions { + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { + res["request_scheme_condition"] = delivery_rule_conditions.FlattenArmCdnEndpointConditionRequestScheme(condition) + continue + } + } + } + + if deliveryRule.Actions != nil { + for _, basicDeliveryRuleAction := range *deliveryRule.Actions { + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { + res["url_redirect_action"] = delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action) + } + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index 598533e4f0c0..333b7c96883e 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -1,7 +1,9 @@ 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/utils" ) func EndpointDeliveryPolicy() *schema.Schema { @@ -27,3 +29,48 @@ func EndpointDeliveryPolicy() *schema.Schema { }, } } + +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { + policies := d.Get("delivery_policy").([]interface{}) + if len(policies) == 0 { + return nil + } + + deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} + + policy := policies[0].(map[string]interface{}) + if descr, ok := policy["description"]; ok { + deliveryPolicy.Description = utils.String(descr.(string)) + } + + rules := policy["rule"].([]interface{}) + deliveryRules := make([]cdn.DeliveryRule, len(rules)) + for i, rule := range rules { + deliveryRules[i] = expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + } + deliveryPolicy.Rules = &deliveryRules + + return &deliveryPolicy +} + +func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { + deliveryPolicies := make([]interface{}, 0) + + if deliveryPolicy == nil { + return deliveryPolicies + } + + dp := make(map[string]interface{}) + if deliveryPolicy.Description != nil { + dp["description"] = *deliveryPolicy.Description + } + + if deliveryPolicy.Rules != nil && len(*deliveryPolicy.Rules) > 0 { + rules := make([]map[string]interface{}, len(*deliveryPolicy.Rules)) + for i, rule := range *deliveryPolicy.Rules { + rules[i] = flattenArmCdnEndpointDeliveryRule(&rule) + } + } + + return deliveryPolicies +} diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index cd9bd96078ce..1ad6ad768024 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -416,6 +416,11 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("origin", origins); err != nil { return fmt.Errorf("Error setting `origin`: %+v", err) } + + deliveryPolicy := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) + if err := d.Set("delivery_policy", deliveryPolicy); err != nil { + return fmt.Errorf("Error setting `delivery_policy`: %+v", err) + } } return tags.FlattenAndSet(d, resp.Tags) @@ -590,108 +595,3 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface return results } - -func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { - policies := d.Get("delivery_policy").([]interface{}) - if len(policies) == 0 { - return nil - } - - deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} - - policy := policies[0].(map[string]interface{}) - if descr, ok := policy["description"]; ok { - deliveryPolicy.Description = utils.String(descr.(string)) - } - - rules := policy["rule"].([]interface{}) - deliveryRules := make([]cdn.DeliveryRule, len(rules)) - for i, rule := range rules { - deliveryRules[i] = expandArmCdnEndpointDeliveryPolicyRule(rule.(map[string]interface{})) - } - deliveryPolicy.Rules = &deliveryRules - - return &deliveryPolicy -} - -func expandArmCdnEndpointDeliveryPolicyRule(rule map[string]interface{}) cdn.DeliveryRule { - deliveryRule := cdn.DeliveryRule{ - Name: utils.String(rule["name"].(string)), - Order: utils.Int32(rule["order"].(int32)), - } - - conditions := make([]cdn.BasicDeliveryRuleCondition, 0) - - if rsc, ok := rule["request_scheme_condition"]; ok { - conditions = append(conditions, *expandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) - } - - deliveryRule.Conditions = &conditions - - actions := make([]cdn.BasicDeliveryRuleAction, 0) - - if ura, ok := rule["url_redirect_action"]; ok { - actions = append(actions, *expandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) - } - - deliveryRule.Actions = &actions - - return deliveryRule -} - -func expandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { - requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ - Name: cdn.NameRequestScheme, - } - - matchValues := rsc["match_values"].([]string) - params := cdn.RequestSchemeMatchConditionParameters{ - MatchValues: &matchValues, - } - - if operator, ok := rsc["operator"]; ok { - params.Operator = utils.String(operator.(string)) - } - - if negate, ok := rsc["negate_condition"]; ok { - params.NegateCondition = utils.Bool(negate.(bool)) - } - - requestSchemeCondition.Parameters = ¶ms - - return &requestSchemeCondition -} - -func expandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { - urlRedirectAction := cdn.URLRedirectAction{ - Name: cdn.NameURLRedirect, - } - - params := cdn.URLRedirectActionParameters{ - RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), - } - - if destProt, ok := ura["destination_protocol"]; ok { - params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) - } - - if hostname, ok := ura["hostname"]; ok { - params.CustomHostname = utils.String(hostname.(string)) - } - - if path, ok := ura["path"]; ok { - params.CustomPath = utils.String(path.(string)) - } - - if queryString, ok := ura["query_string"]; ok { - params.CustomQueryString = utils.String(queryString.(string)) - } - - if fragment, ok := ura["fragment"]; ok { - params.CustomFragment = utils.String(fragment.(string)) - } - - urlRedirectAction.Parameters = ¶ms - - return &urlRedirectAction -} diff --git a/azurerm/internal/services/cdn/rule_action_url_redirect.go b/azurerm/internal/services/cdn/rule_action_url_redirect.go deleted file mode 100644 index 38b2f163426d..000000000000 --- a/azurerm/internal/services/cdn/rule_action_url_redirect.go +++ /dev/null @@ -1,58 +0,0 @@ -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" -) - -func RuleActionUrlRedirect() *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), - }, - - "destination_protocol": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validation.StringInSlice([]string{ - string(cdn.MatchRequest), - string(cdn.HTTP), - string(cdn.HTTPS), - }, false), - }, - - "hostname": { - Type: schema.TypeString, - Required: false, - }, - - "path": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validate.RuleActionUrlRedirectPath(), - }, - - "query_string": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validate.RuleActionUrlRedirectPath(), - }, - - "fragment": { - Type: schema.TypeString, - Required: false, - ValidateFunc: validate.RuleActionUrlRedirectFragment(), - }, - }, - } -} diff --git a/azurerm/internal/services/cdn/rule_condition_request_scheme.go b/azurerm/internal/services/cdn/rule_condition_request_scheme.go deleted file mode 100644 index e6db5bea7a3c..000000000000 --- a/azurerm/internal/services/cdn/rule_condition_request_scheme.go +++ /dev/null @@ -1,38 +0,0 @@ -package cdn - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" -) - -func RuleConditionRequestScheme() *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.TypeList, - Required: true, - MinItems: 1, - MaxItems: 1, - ValidateFunc: validation.StringInSlice([]string{ - "HTTP", - "HTTPS", - }, false), - }, - }, - } -} From 3c465386f53d05a540fc619dae41436573f2619a Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 15:09:53 +0100 Subject: [PATCH 42/92] fix basic issues in order to run `terraform plan` --- .../services/cdn/delivery_rule_actions/url_redirect.go | 10 +++++----- .../cdn/delivery_rule_conditions/request_scheme.go | 8 +++----- .../internal/services/cdn/endpont_delivery_policy.go | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go index e88b6e538c68..4572d3d053f2 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -24,7 +24,7 @@ func RuleActionUrlRedirect() *schema.Resource { "protocol": { Type: schema.TypeString, - Required: false, + Optional: true, Default: string(cdn.MatchRequest), ValidateFunc: validation.StringInSlice([]string{ string(cdn.MatchRequest), @@ -35,24 +35,24 @@ func RuleActionUrlRedirect() *schema.Resource { "hostname": { Type: schema.TypeString, - Required: false, + Optional: true, }, "path": { Type: schema.TypeString, - Required: false, + Optional: true, ValidateFunc: validate.RuleActionUrlRedirectPath(), }, "query_string": { Type: schema.TypeString, - Required: false, + Optional: true, ValidateFunc: validate.RuleActionUrlRedirectPath(), }, "fragment": { Type: schema.TypeString, - Required: false, + Optional: true, ValidateFunc: validate.RuleActionUrlRedirectFragment(), }, }, diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index bc9863110510..8ebb7ebbf9a5 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -25,11 +25,9 @@ func RuleConditionRequestScheme() *schema.Resource { Default: false, }, - "match_values": { - Type: schema.TypeList, + "match_value": { + Type: schema.TypeString, Required: true, - MinItems: 1, - MaxItems: 1, ValidateFunc: validation.StringInSlice([]string{ "HTTP", "HTTPS", @@ -44,7 +42,7 @@ func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn Name: cdn.NameRequestScheme, } - matchValues := rsc["match_values"].([]string) + matchValues := []string{rsc["match_value"].(string)} params := cdn.RequestSchemeMatchConditionParameters{ MatchValues: &matchValues, } diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpont_delivery_policy.go index 333b7c96883e..5e34bbefb666 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpont_delivery_policy.go @@ -9,13 +9,13 @@ import ( func EndpointDeliveryPolicy() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, - Required: false, + Optional: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "description": { Type: schema.TypeString, - Required: false, + Optional: true, }, "rule": { From 1543dc95c2d4deba40660559ebddfec88150c1e9 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 17:04:20 +0100 Subject: [PATCH 43/92] fix problems in order to apply correctly --- .../cdn/delivery_rule_actions/url_redirect.go | 11 ++++++----- .../cdn/delivery_rule_conditions/request_scheme.go | 10 +++++----- .../internal/services/cdn/endpoint_delivery_rule.go | 7 ++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go index 4572d3d053f2..c2ac0f7fe338 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -65,26 +65,27 @@ func ExpandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLR } params := cdn.URLRedirectActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRedirectActionParameters"), RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), } - if destProt, ok := ura["protocol"]; ok { + if destProt := ura["protocol"]; destProt.(string) != "" { params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) } - if hostname, ok := ura["hostname"]; ok { + if hostname := ura["hostname"]; hostname.(string) != "" { params.CustomHostname = utils.String(hostname.(string)) } - if path, ok := ura["path"]; ok { + if path := ura["path"]; path.(string) != "" { params.CustomPath = utils.String(path.(string)) } - if queryString, ok := ura["query_string"]; ok { + if queryString := ura["query_string"]; queryString.(string) != "" { params.CustomQueryString = utils.String(queryString.(string)) } - if fragment, ok := ura["fragment"]; ok { + if fragment := ura["fragment"]; fragment.(string) != "" { params.CustomFragment = utils.String(fragment.(string)) } diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index 8ebb7ebbf9a5..5573ff485f00 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -44,16 +44,16 @@ func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn matchValues := []string{rsc["match_value"].(string)} params := cdn.RequestSchemeMatchConditionParameters{ - MatchValues: &matchValues, + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), + MatchValues: &matchValues, + NegateCondition: utils.Bool(rsc["negate_condition"].(bool)), } - if operator, ok := rsc["operator"]; ok { + if operator := rsc["operator"]; operator.(string) != "" { params.Operator = utils.String(operator.(string)) } - if negate, ok := rsc["negate_condition"]; ok { - params.NegateCondition = utils.Bool(negate.(bool)) - } + params.NegateCondition = utils.Bool(rsc["negate_condition"].(bool)) requestSchemeCondition.Parameters = ¶ms diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 89f861dec5bb..fdf4dc24d33f 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -45,12 +45,12 @@ func EndpointDeliveryRule() *schema.Resource { func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryRule { deliveryRule := cdn.DeliveryRule{ Name: utils.String(rule["name"].(string)), - Order: utils.Int32(rule["order"].(int32)), + Order: utils.Int32(int32(rule["order"].(int))), } conditions := make([]cdn.BasicDeliveryRuleCondition, 0) - if rsc, ok := rule["request_scheme_condition"]; ok { + if rsc := rule["request_scheme_condition"]; len(rsc.([]interface{})) > 0 { conditions = append(conditions, *delivery_rule_conditions.ExpandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) } @@ -58,7 +58,7 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryR actions := make([]cdn.BasicDeliveryRuleAction, 0) - if ura, ok := rule["url_redirect_action"]; ok { + if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) } @@ -95,6 +95,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin for _, basicDeliveryRuleAction := range *deliveryRule.Actions { if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { res["url_redirect_action"] = delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action) + continue } } } From ca3b6fb38d30dc400246ab57ba85aff0f0870c87 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 17:47:59 +0100 Subject: [PATCH 44/92] fix rename of match_values to match_value; rename endpoint_delivery_policy.go --- .../services/cdn/delivery_rule_conditions/request_scheme.go | 4 ++-- ...endpont_delivery_policy.go => endpoint_delivery_policy.go} | 3 +++ azurerm/internal/services/cdn/endpoint_delivery_rule.go | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) rename azurerm/internal/services/cdn/{endpont_delivery_policy.go => endpoint_delivery_policy.go} (96%) diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index 5573ff485f00..f51bafaafbc2 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -72,8 +72,8 @@ func FlattenArmCdnEndpointConditionRequestScheme(condition *cdn.DeliveryRuleRequ res["negate_condition"] = *params.NegateCondition } - if params.MatchValues != nil { - res["match_values"] = *params.MatchValues + if params.MatchValues != nil && len(*params.MatchValues) > 0 { + res["match_value"] = (*params.MatchValues)[0] } } diff --git a/azurerm/internal/services/cdn/endpont_delivery_policy.go b/azurerm/internal/services/cdn/endpoint_delivery_policy.go similarity index 96% rename from azurerm/internal/services/cdn/endpont_delivery_policy.go rename to azurerm/internal/services/cdn/endpoint_delivery_policy.go index 5e34bbefb666..2163ce66b9e9 100644 --- a/azurerm/internal/services/cdn/endpont_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_policy.go @@ -70,7 +70,10 @@ func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesU for i, rule := range *deliveryPolicy.Rules { rules[i] = flattenArmCdnEndpointDeliveryRule(&rule) } + dp["rule"] = rules } + deliveryPolicies = append(deliveryPolicies, dp) + return deliveryPolicies } diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index fdf4dc24d33f..5982807f6946 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -85,7 +85,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Conditions != nil { for _, basicDeliveryRuleCondition := range *deliveryRule.Conditions { if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { - res["request_scheme_condition"] = delivery_rule_conditions.FlattenArmCdnEndpointConditionRequestScheme(condition) + res["request_scheme_condition"] = []interface{}{delivery_rule_conditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue } } @@ -94,7 +94,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Actions != nil { for _, basicDeliveryRuleAction := range *deliveryRule.Actions { if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { - res["url_redirect_action"] = delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action) + res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } } From f5c7d1fe32cd0ec5e182744a284be5545603a22a Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:10:25 +0100 Subject: [PATCH 45/92] add method to test cache expiration duration --- azurerm/helpers/validate/cdn.go | 7 ++++ azurerm/helpers/validate/cdn_test.go | 57 ++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index 9c733d807a47..015199845596 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -54,3 +54,10 @@ func RuleActionUrlRedirectFragment() schema.SchemaValidateFunc { "The Url Redirect Path must start with a slash.", ) } + +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.", + ) +} diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go index aded6923d74f..b98b64ab37e6 100644 --- a/azurerm/helpers/validate/cdn_test.go +++ b/azurerm/helpers/validate/cdn_test.go @@ -84,7 +84,7 @@ func TestRuleActionUrlRedirectPath(t *testing.T) { for _, tc := range cases { t.Run(tc.Path, func(t *testing.T) { - _, errors := RuleActionUrlRedirectPath()(tc.Path, "name") + _, errors := RuleActionUrlRedirectPath()(tc.Path, "path") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { @@ -135,7 +135,7 @@ func TestRuleActionUrlRedirectQueryString(t *testing.T) { for _, tc := range cases { t.Run(tc.QueryString, func(t *testing.T) { - _, errors := RuleActionUrlRedirectQueryString()(tc.QueryString, "name") + _, errors := RuleActionUrlRedirectQueryString()(tc.QueryString, "query_string") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { @@ -178,7 +178,7 @@ func TestRuleActionUrlRedirectFragment(t *testing.T) { for _, tc := range cases { t.Run(tc.Fragment, func(t *testing.T) { - _, errors := RuleActionUrlRedirectFragment()(tc.Fragment, "name") + _, errors := RuleActionUrlRedirectFragment()(tc.Fragment, "fragment") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { @@ -191,3 +191,54 @@ func TestRuleActionUrlRedirectFragment(t *testing.T) { }) } } + +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)) + } + }) + } +} From 8bea9b0943e2fbc25043699751c334f984a66e8b Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:11:17 +0100 Subject: [PATCH 46/92] shorten names of conditions and actions --- .../services/cdn/delivery_rule_actions/url_redirect.go | 2 +- .../services/cdn/delivery_rule_conditions/request_scheme.go | 2 +- azurerm/internal/services/cdn/endpoint_delivery_rule.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go index c2ac0f7fe338..9a8551ec8d3b 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go @@ -8,7 +8,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func RuleActionUrlRedirect() *schema.Resource { +func URLRedirect() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "redirect_type": { diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go index f51bafaafbc2..920175fa2fe5 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go @@ -7,7 +7,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func RuleConditionRequestScheme() *schema.Resource { +func RequestScheme() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "operator": { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 5982807f6946..43bc4da95c36 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -29,14 +29,14 @@ func EndpointDeliveryRule() *schema.Resource { Type: schema.TypeList, Optional: true, MaxItems: 1, - Elem: delivery_rule_conditions.RuleConditionRequestScheme(), + Elem: delivery_rule_conditions.RequestScheme(), }, "url_redirect_action": { Type: schema.TypeList, Optional: true, MaxItems: 1, - Elem: delivery_rule_actions.RuleActionUrlRedirect(), + Elem: delivery_rule_actions.URLRedirect(), }, }, } From 8660b2c2337ea9e24702fe6ba79d26684e3f203a Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:21:29 +0100 Subject: [PATCH 47/92] add cache expiration action --- .../delivery_rule_actions/cache_expiration.go | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go new file mode 100644 index 000000000000..c9b8f1ba08cc --- /dev/null +++ b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go @@ -0,0 +1,62 @@ +package delivery_rule_actions + +import ( + "github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/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(cea map[string]interface{}) *cdn.DeliveryRuleCacheExpirationAction { + cacheExpirationAction := cdn.DeliveryRuleCacheExpirationAction{ + Name: cdn.NameCacheExpiration, + Parameters: &cdn.CacheExpirationActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters"), + CacheBehavior: cdn.CacheBehavior(cea["behavior"].(string)), + CacheType: utils.String("All"), + }, + } + + if duration := cea["duration"].(string); duration != "" { + cacheExpirationAction.Parameters.CacheDuration = utils.String(duration) + } + + return &cacheExpirationAction +} + +func FlattenArmCdnEndpointActionCacheExpiry(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := cea.Parameters; params != nil { + res["behavior"] = string(params.CacheBehavior) + + if params.CacheDuration != nil { + res["duration"] = *params.CacheDuration + } + } + + return res +} From 1a0ab9f524e21638c0d0981cfe5763c25f0520cd Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:24:34 +0100 Subject: [PATCH 48/92] add cache expiration action to delivery_rule --- .../delivery_rule_actions/cache_expiration.go | 2 +- .../services/cdn/endpoint_delivery_rule.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go index c9b8f1ba08cc..1fccf6a58826 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go @@ -47,7 +47,7 @@ func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) *cdn. return &cacheExpirationAction } -func FlattenArmCdnEndpointActionCacheExpiry(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { +func FlattenArmCdnEndpointActionCacheExpiration(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { res := make(map[string]interface{}, 1) if params := cea.Parameters; params != nil { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 43bc4da95c36..a74503832493 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -38,6 +38,13 @@ func EndpointDeliveryRule() *schema.Resource { MaxItems: 1, Elem: delivery_rule_actions.URLRedirect(), }, + + "cache_expiration_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.CacheExpiration(), + }, }, } } @@ -62,6 +69,10 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryR actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) } + if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { + actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{}))) + } + deliveryRule.Actions = &actions return deliveryRule @@ -97,6 +108,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } + + if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { + res["cache_expiration_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionCacheExpiration(action)} + continue + } } } From 9fce0fcd6829254ea44aa9f9512b669ddef22228 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 21:43:17 +0100 Subject: [PATCH 49/92] fix not working build --- .../services/cdn/endpoint_delivery_rule.go | 8 +- .../profiles/latest/cdn/mgmt/cdn/models.go | 711 ++++++++++++++++++ vendor/modules.txt | 1 + 3 files changed, 716 insertions(+), 4 deletions(-) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index a74503832493..971d798618bc 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -104,13 +104,13 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Actions != nil { for _, basicDeliveryRuleAction := range *deliveryRule.Actions { - if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { - res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} + if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { + res["cache_expiration_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionCacheExpiration(action)} continue } - if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { - res["cache_expiration_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionCacheExpiration(action)} + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { + res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go b/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go new file mode 100644 index 000000000000..efa977211a2a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go @@ -0,0 +1,711 @@ +// +build go1.9 + +// Copyright 2020 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package cdn + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type CacheBehavior = original.CacheBehavior + +const ( + BypassCache CacheBehavior = original.BypassCache + Override CacheBehavior = original.Override + SetIfMissing CacheBehavior = original.SetIfMissing +) + +type CertificateSource = original.CertificateSource + +const ( + CertificateSourceAzureKeyVault CertificateSource = original.CertificateSourceAzureKeyVault + CertificateSourceCdn CertificateSource = original.CertificateSourceCdn + CertificateSourceCustomDomainHTTPSParameters CertificateSource = original.CertificateSourceCustomDomainHTTPSParameters +) + +type CertificateType = original.CertificateType + +const ( + Dedicated CertificateType = original.Dedicated + Shared CertificateType = original.Shared +) + +type CookiesOperator = original.CookiesOperator + +const ( + Any CookiesOperator = original.Any + BeginsWith CookiesOperator = original.BeginsWith + Contains CookiesOperator = original.Contains + EndsWith CookiesOperator = original.EndsWith + Equal CookiesOperator = original.Equal + GreaterThan CookiesOperator = original.GreaterThan + GreaterThanOrEqual CookiesOperator = original.GreaterThanOrEqual + LessThan CookiesOperator = original.LessThan + LessThanOrEqual CookiesOperator = original.LessThanOrEqual +) + +type CustomDomainResourceState = original.CustomDomainResourceState + +const ( + Active CustomDomainResourceState = original.Active + Creating CustomDomainResourceState = original.Creating + Deleting CustomDomainResourceState = original.Deleting +) + +type CustomHTTPSProvisioningState = original.CustomHTTPSProvisioningState + +const ( + Disabled CustomHTTPSProvisioningState = original.Disabled + Disabling CustomHTTPSProvisioningState = original.Disabling + Enabled CustomHTTPSProvisioningState = original.Enabled + Enabling CustomHTTPSProvisioningState = original.Enabling + Failed CustomHTTPSProvisioningState = original.Failed +) + +type CustomHTTPSProvisioningSubstate = original.CustomHTTPSProvisioningSubstate + +const ( + CertificateDeleted CustomHTTPSProvisioningSubstate = original.CertificateDeleted + CertificateDeployed CustomHTTPSProvisioningSubstate = original.CertificateDeployed + DeletingCertificate CustomHTTPSProvisioningSubstate = original.DeletingCertificate + DeployingCertificate CustomHTTPSProvisioningSubstate = original.DeployingCertificate + DomainControlValidationRequestApproved CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestApproved + DomainControlValidationRequestRejected CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestRejected + DomainControlValidationRequestTimedOut CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestTimedOut + IssuingCertificate CustomHTTPSProvisioningSubstate = original.IssuingCertificate + PendingDomainControlValidationREquestApproval CustomHTTPSProvisioningSubstate = original.PendingDomainControlValidationREquestApproval + SubmittingDomainControlValidationRequest CustomHTTPSProvisioningSubstate = original.SubmittingDomainControlValidationRequest +) + +type DestinationProtocol = original.DestinationProtocol + +const ( + HTTP DestinationProtocol = original.HTTP + HTTPS DestinationProtocol = original.HTTPS + MatchRequest DestinationProtocol = original.MatchRequest +) + +type EndpointResourceState = original.EndpointResourceState + +const ( + EndpointResourceStateCreating EndpointResourceState = original.EndpointResourceStateCreating + EndpointResourceStateDeleting EndpointResourceState = original.EndpointResourceStateDeleting + EndpointResourceStateRunning EndpointResourceState = original.EndpointResourceStateRunning + EndpointResourceStateStarting EndpointResourceState = original.EndpointResourceStateStarting + EndpointResourceStateStopped EndpointResourceState = original.EndpointResourceStateStopped + EndpointResourceStateStopping EndpointResourceState = original.EndpointResourceStateStopping +) + +type GeoFilterActions = original.GeoFilterActions + +const ( + Allow GeoFilterActions = original.Allow + Block GeoFilterActions = original.Block +) + +type HeaderAction = original.HeaderAction + +const ( + Append HeaderAction = original.Append + Delete HeaderAction = original.Delete + Overwrite HeaderAction = original.Overwrite +) + +type MinimumTLSVersion = original.MinimumTLSVersion + +const ( + None MinimumTLSVersion = original.None + TLS10 MinimumTLSVersion = original.TLS10 + TLS12 MinimumTLSVersion = original.TLS12 +) + +type Name = original.Name + +const ( + NameCookies Name = original.NameCookies + NameDeliveryRuleCondition Name = original.NameDeliveryRuleCondition + NameHTTPVersion Name = original.NameHTTPVersion + NameIsDevice Name = original.NameIsDevice + NamePostArgs Name = original.NamePostArgs + NameQueryString Name = original.NameQueryString + NameRemoteAddress Name = original.NameRemoteAddress + NameRequestBody Name = original.NameRequestBody + NameRequestHeader Name = original.NameRequestHeader + NameRequestMethod Name = original.NameRequestMethod + NameRequestScheme Name = original.NameRequestScheme + NameRequestURI Name = original.NameRequestURI + NameURLFileExtension Name = original.NameURLFileExtension + NameURLFileName Name = original.NameURLFileName + NameURLPath Name = original.NameURLPath +) + +type NameBasicDeliveryRuleAction = original.NameBasicDeliveryRuleAction + +const ( + NameCacheExpiration NameBasicDeliveryRuleAction = original.NameCacheExpiration + NameCacheKeyQueryString NameBasicDeliveryRuleAction = original.NameCacheKeyQueryString + NameDeliveryRuleAction NameBasicDeliveryRuleAction = original.NameDeliveryRuleAction + NameModifyRequestHeader NameBasicDeliveryRuleAction = original.NameModifyRequestHeader + NameModifyResponseHeader NameBasicDeliveryRuleAction = original.NameModifyResponseHeader + NameURLRedirect NameBasicDeliveryRuleAction = original.NameURLRedirect + NameURLRewrite NameBasicDeliveryRuleAction = original.NameURLRewrite +) + +type OptimizationType = original.OptimizationType + +const ( + DynamicSiteAcceleration OptimizationType = original.DynamicSiteAcceleration + GeneralMediaStreaming OptimizationType = original.GeneralMediaStreaming + GeneralWebDelivery OptimizationType = original.GeneralWebDelivery + LargeFileDownload OptimizationType = original.LargeFileDownload + VideoOnDemandMediaStreaming OptimizationType = original.VideoOnDemandMediaStreaming +) + +type OriginResourceState = original.OriginResourceState + +const ( + OriginResourceStateActive OriginResourceState = original.OriginResourceStateActive + OriginResourceStateCreating OriginResourceState = original.OriginResourceStateCreating + OriginResourceStateDeleting OriginResourceState = original.OriginResourceStateDeleting +) + +type PostArgsOperator = original.PostArgsOperator + +const ( + PostArgsOperatorAny PostArgsOperator = original.PostArgsOperatorAny + PostArgsOperatorBeginsWith PostArgsOperator = original.PostArgsOperatorBeginsWith + PostArgsOperatorContains PostArgsOperator = original.PostArgsOperatorContains + PostArgsOperatorEndsWith PostArgsOperator = original.PostArgsOperatorEndsWith + PostArgsOperatorEqual PostArgsOperator = original.PostArgsOperatorEqual + PostArgsOperatorGreaterThan PostArgsOperator = original.PostArgsOperatorGreaterThan + PostArgsOperatorGreaterThanOrEqual PostArgsOperator = original.PostArgsOperatorGreaterThanOrEqual + PostArgsOperatorLessThan PostArgsOperator = original.PostArgsOperatorLessThan + PostArgsOperatorLessThanOrEqual PostArgsOperator = original.PostArgsOperatorLessThanOrEqual +) + +type ProfileResourceState = original.ProfileResourceState + +const ( + ProfileResourceStateActive ProfileResourceState = original.ProfileResourceStateActive + ProfileResourceStateCreating ProfileResourceState = original.ProfileResourceStateCreating + ProfileResourceStateDeleting ProfileResourceState = original.ProfileResourceStateDeleting + ProfileResourceStateDisabled ProfileResourceState = original.ProfileResourceStateDisabled +) + +type ProtocolType = original.ProtocolType + +const ( + IPBased ProtocolType = original.IPBased + ServerNameIndication ProtocolType = original.ServerNameIndication +) + +type QueryStringBehavior = original.QueryStringBehavior + +const ( + Exclude QueryStringBehavior = original.Exclude + ExcludeAll QueryStringBehavior = original.ExcludeAll + Include QueryStringBehavior = original.Include + IncludeAll QueryStringBehavior = original.IncludeAll +) + +type QueryStringCachingBehavior = original.QueryStringCachingBehavior + +const ( + BypassCaching QueryStringCachingBehavior = original.BypassCaching + IgnoreQueryString QueryStringCachingBehavior = original.IgnoreQueryString + NotSet QueryStringCachingBehavior = original.NotSet + UseQueryString QueryStringCachingBehavior = original.UseQueryString +) + +type QueryStringOperator = original.QueryStringOperator + +const ( + QueryStringOperatorAny QueryStringOperator = original.QueryStringOperatorAny + QueryStringOperatorBeginsWith QueryStringOperator = original.QueryStringOperatorBeginsWith + QueryStringOperatorContains QueryStringOperator = original.QueryStringOperatorContains + QueryStringOperatorEndsWith QueryStringOperator = original.QueryStringOperatorEndsWith + QueryStringOperatorEqual QueryStringOperator = original.QueryStringOperatorEqual + QueryStringOperatorGreaterThan QueryStringOperator = original.QueryStringOperatorGreaterThan + QueryStringOperatorGreaterThanOrEqual QueryStringOperator = original.QueryStringOperatorGreaterThanOrEqual + QueryStringOperatorLessThan QueryStringOperator = original.QueryStringOperatorLessThan + QueryStringOperatorLessThanOrEqual QueryStringOperator = original.QueryStringOperatorLessThanOrEqual +) + +type RedirectType = original.RedirectType + +const ( + Found RedirectType = original.Found + Moved RedirectType = original.Moved + PermanentRedirect RedirectType = original.PermanentRedirect + TemporaryRedirect RedirectType = original.TemporaryRedirect +) + +type RemoteAddressOperator = original.RemoteAddressOperator + +const ( + RemoteAddressOperatorAny RemoteAddressOperator = original.RemoteAddressOperatorAny + RemoteAddressOperatorGeoMatch RemoteAddressOperator = original.RemoteAddressOperatorGeoMatch + RemoteAddressOperatorIPMatch RemoteAddressOperator = original.RemoteAddressOperatorIPMatch +) + +type RequestBodyOperator = original.RequestBodyOperator + +const ( + RequestBodyOperatorAny RequestBodyOperator = original.RequestBodyOperatorAny + RequestBodyOperatorBeginsWith RequestBodyOperator = original.RequestBodyOperatorBeginsWith + RequestBodyOperatorContains RequestBodyOperator = original.RequestBodyOperatorContains + RequestBodyOperatorEndsWith RequestBodyOperator = original.RequestBodyOperatorEndsWith + RequestBodyOperatorEqual RequestBodyOperator = original.RequestBodyOperatorEqual + RequestBodyOperatorGreaterThan RequestBodyOperator = original.RequestBodyOperatorGreaterThan + RequestBodyOperatorGreaterThanOrEqual RequestBodyOperator = original.RequestBodyOperatorGreaterThanOrEqual + RequestBodyOperatorLessThan RequestBodyOperator = original.RequestBodyOperatorLessThan + RequestBodyOperatorLessThanOrEqual RequestBodyOperator = original.RequestBodyOperatorLessThanOrEqual +) + +type RequestHeaderOperator = original.RequestHeaderOperator + +const ( + RequestHeaderOperatorAny RequestHeaderOperator = original.RequestHeaderOperatorAny + RequestHeaderOperatorBeginsWith RequestHeaderOperator = original.RequestHeaderOperatorBeginsWith + RequestHeaderOperatorContains RequestHeaderOperator = original.RequestHeaderOperatorContains + RequestHeaderOperatorEndsWith RequestHeaderOperator = original.RequestHeaderOperatorEndsWith + RequestHeaderOperatorEqual RequestHeaderOperator = original.RequestHeaderOperatorEqual + RequestHeaderOperatorGreaterThan RequestHeaderOperator = original.RequestHeaderOperatorGreaterThan + RequestHeaderOperatorGreaterThanOrEqual RequestHeaderOperator = original.RequestHeaderOperatorGreaterThanOrEqual + RequestHeaderOperatorLessThan RequestHeaderOperator = original.RequestHeaderOperatorLessThan + RequestHeaderOperatorLessThanOrEqual RequestHeaderOperator = original.RequestHeaderOperatorLessThanOrEqual +) + +type RequestURIOperator = original.RequestURIOperator + +const ( + RequestURIOperatorAny RequestURIOperator = original.RequestURIOperatorAny + RequestURIOperatorBeginsWith RequestURIOperator = original.RequestURIOperatorBeginsWith + RequestURIOperatorContains RequestURIOperator = original.RequestURIOperatorContains + RequestURIOperatorEndsWith RequestURIOperator = original.RequestURIOperatorEndsWith + RequestURIOperatorEqual RequestURIOperator = original.RequestURIOperatorEqual + RequestURIOperatorGreaterThan RequestURIOperator = original.RequestURIOperatorGreaterThan + RequestURIOperatorGreaterThanOrEqual RequestURIOperator = original.RequestURIOperatorGreaterThanOrEqual + RequestURIOperatorLessThan RequestURIOperator = original.RequestURIOperatorLessThan + RequestURIOperatorLessThanOrEqual RequestURIOperator = original.RequestURIOperatorLessThanOrEqual +) + +type ResourceType = original.ResourceType + +const ( + MicrosoftCdnProfilesEndpoints ResourceType = original.MicrosoftCdnProfilesEndpoints +) + +type SkuName = original.SkuName + +const ( + CustomVerizon SkuName = original.CustomVerizon + PremiumChinaCdn SkuName = original.PremiumChinaCdn + PremiumVerizon SkuName = original.PremiumVerizon + StandardAkamai SkuName = original.StandardAkamai + StandardChinaCdn SkuName = original.StandardChinaCdn + StandardMicrosoft SkuName = original.StandardMicrosoft + StandardVerizon SkuName = original.StandardVerizon +) + +type Transform = original.Transform + +const ( + Lowercase Transform = original.Lowercase + Uppercase Transform = original.Uppercase +) + +type URLFileExtensionOperator = original.URLFileExtensionOperator + +const ( + URLFileExtensionOperatorAny URLFileExtensionOperator = original.URLFileExtensionOperatorAny + URLFileExtensionOperatorBeginsWith URLFileExtensionOperator = original.URLFileExtensionOperatorBeginsWith + URLFileExtensionOperatorContains URLFileExtensionOperator = original.URLFileExtensionOperatorContains + URLFileExtensionOperatorEndsWith URLFileExtensionOperator = original.URLFileExtensionOperatorEndsWith + URLFileExtensionOperatorEqual URLFileExtensionOperator = original.URLFileExtensionOperatorEqual + URLFileExtensionOperatorGreaterThan URLFileExtensionOperator = original.URLFileExtensionOperatorGreaterThan + URLFileExtensionOperatorGreaterThanOrEqual URLFileExtensionOperator = original.URLFileExtensionOperatorGreaterThanOrEqual + URLFileExtensionOperatorLessThan URLFileExtensionOperator = original.URLFileExtensionOperatorLessThan + URLFileExtensionOperatorLessThanOrEqual URLFileExtensionOperator = original.URLFileExtensionOperatorLessThanOrEqual +) + +type URLFileNameOperator = original.URLFileNameOperator + +const ( + URLFileNameOperatorAny URLFileNameOperator = original.URLFileNameOperatorAny + URLFileNameOperatorBeginsWith URLFileNameOperator = original.URLFileNameOperatorBeginsWith + URLFileNameOperatorContains URLFileNameOperator = original.URLFileNameOperatorContains + URLFileNameOperatorEndsWith URLFileNameOperator = original.URLFileNameOperatorEndsWith + URLFileNameOperatorEqual URLFileNameOperator = original.URLFileNameOperatorEqual + URLFileNameOperatorGreaterThan URLFileNameOperator = original.URLFileNameOperatorGreaterThan + URLFileNameOperatorGreaterThanOrEqual URLFileNameOperator = original.URLFileNameOperatorGreaterThanOrEqual + URLFileNameOperatorLessThan URLFileNameOperator = original.URLFileNameOperatorLessThan + URLFileNameOperatorLessThanOrEqual URLFileNameOperator = original.URLFileNameOperatorLessThanOrEqual +) + +type URLPathOperator = original.URLPathOperator + +const ( + URLPathOperatorAny URLPathOperator = original.URLPathOperatorAny + URLPathOperatorBeginsWith URLPathOperator = original.URLPathOperatorBeginsWith + URLPathOperatorContains URLPathOperator = original.URLPathOperatorContains + URLPathOperatorEndsWith URLPathOperator = original.URLPathOperatorEndsWith + URLPathOperatorEqual URLPathOperator = original.URLPathOperatorEqual + URLPathOperatorGreaterThan URLPathOperator = original.URLPathOperatorGreaterThan + URLPathOperatorGreaterThanOrEqual URLPathOperator = original.URLPathOperatorGreaterThanOrEqual + URLPathOperatorLessThan URLPathOperator = original.URLPathOperatorLessThan + URLPathOperatorLessThanOrEqual URLPathOperator = original.URLPathOperatorLessThanOrEqual + URLPathOperatorWildcard URLPathOperator = original.URLPathOperatorWildcard +) + +type BaseClient = original.BaseClient +type BasicCustomDomainHTTPSParameters = original.BasicCustomDomainHTTPSParameters +type BasicDeliveryRuleAction = original.BasicDeliveryRuleAction +type BasicDeliveryRuleCondition = original.BasicDeliveryRuleCondition +type CacheExpirationActionParameters = original.CacheExpirationActionParameters +type CacheKeyQueryStringActionParameters = original.CacheKeyQueryStringActionParameters +type CertificateSourceParameters = original.CertificateSourceParameters +type CheckNameAvailabilityInput = original.CheckNameAvailabilityInput +type CheckNameAvailabilityOutput = original.CheckNameAvailabilityOutput +type CidrIPAddress = original.CidrIPAddress +type CookiesMatchConditionParameters = original.CookiesMatchConditionParameters +type CustomDomain = original.CustomDomain +type CustomDomainHTTPSParameters = original.CustomDomainHTTPSParameters +type CustomDomainListResult = original.CustomDomainListResult +type CustomDomainListResultIterator = original.CustomDomainListResultIterator +type CustomDomainListResultPage = original.CustomDomainListResultPage +type CustomDomainParameters = original.CustomDomainParameters +type CustomDomainProperties = original.CustomDomainProperties +type CustomDomainPropertiesParameters = original.CustomDomainPropertiesParameters +type CustomDomainsClient = original.CustomDomainsClient +type CustomDomainsCreateFuture = original.CustomDomainsCreateFuture +type CustomDomainsDeleteFuture = original.CustomDomainsDeleteFuture +type DeepCreatedOrigin = original.DeepCreatedOrigin +type DeepCreatedOriginProperties = original.DeepCreatedOriginProperties +type DeliveryRule = original.DeliveryRule +type DeliveryRuleAction = original.DeliveryRuleAction +type DeliveryRuleCacheExpirationAction = original.DeliveryRuleCacheExpirationAction +type DeliveryRuleCacheKeyQueryStringAction = original.DeliveryRuleCacheKeyQueryStringAction +type DeliveryRuleCondition = original.DeliveryRuleCondition +type DeliveryRuleCookiesCondition = original.DeliveryRuleCookiesCondition +type DeliveryRuleHTTPVersionCondition = original.DeliveryRuleHTTPVersionCondition +type DeliveryRuleIsDeviceCondition = original.DeliveryRuleIsDeviceCondition +type DeliveryRulePostArgsCondition = original.DeliveryRulePostArgsCondition +type DeliveryRuleQueryStringCondition = original.DeliveryRuleQueryStringCondition +type DeliveryRuleRemoteAddressCondition = original.DeliveryRuleRemoteAddressCondition +type DeliveryRuleRequestBodyCondition = original.DeliveryRuleRequestBodyCondition +type DeliveryRuleRequestHeaderAction = original.DeliveryRuleRequestHeaderAction +type DeliveryRuleRequestHeaderCondition = original.DeliveryRuleRequestHeaderCondition +type DeliveryRuleRequestMethodCondition = original.DeliveryRuleRequestMethodCondition +type DeliveryRuleRequestSchemeCondition = original.DeliveryRuleRequestSchemeCondition +type DeliveryRuleRequestURICondition = original.DeliveryRuleRequestURICondition +type DeliveryRuleResponseHeaderAction = original.DeliveryRuleResponseHeaderAction +type DeliveryRuleURLFileExtensionCondition = original.DeliveryRuleURLFileExtensionCondition +type DeliveryRuleURLFileNameCondition = original.DeliveryRuleURLFileNameCondition +type DeliveryRuleURLPathCondition = original.DeliveryRuleURLPathCondition +type EdgeNode = original.EdgeNode +type EdgeNodeProperties = original.EdgeNodeProperties +type EdgeNodesClient = original.EdgeNodesClient +type EdgenodeResult = original.EdgenodeResult +type EdgenodeResultIterator = original.EdgenodeResultIterator +type EdgenodeResultPage = original.EdgenodeResultPage +type Endpoint = original.Endpoint +type EndpointListResult = original.EndpointListResult +type EndpointListResultIterator = original.EndpointListResultIterator +type EndpointListResultPage = original.EndpointListResultPage +type EndpointProperties = original.EndpointProperties +type EndpointPropertiesUpdateParameters = original.EndpointPropertiesUpdateParameters +type EndpointPropertiesUpdateParametersDeliveryPolicy = original.EndpointPropertiesUpdateParametersDeliveryPolicy +type EndpointUpdateParameters = original.EndpointUpdateParameters +type EndpointsClient = original.EndpointsClient +type EndpointsCreateFuture = original.EndpointsCreateFuture +type EndpointsDeleteFuture = original.EndpointsDeleteFuture +type EndpointsLoadContentFuture = original.EndpointsLoadContentFuture +type EndpointsPurgeContentFuture = original.EndpointsPurgeContentFuture +type EndpointsStartFuture = original.EndpointsStartFuture +type EndpointsStopFuture = original.EndpointsStopFuture +type EndpointsUpdateFuture = original.EndpointsUpdateFuture +type ErrorResponse = original.ErrorResponse +type GeoFilter = original.GeoFilter +type HTTPVersionMatchConditionParameters = original.HTTPVersionMatchConditionParameters +type HeaderActionParameters = original.HeaderActionParameters +type IPAddressGroup = original.IPAddressGroup +type IsDeviceMatchConditionParameters = original.IsDeviceMatchConditionParameters +type KeyVaultCertificateSourceParameters = original.KeyVaultCertificateSourceParameters +type LoadParameters = original.LoadParameters +type ManagedHTTPSParameters = original.ManagedHTTPSParameters +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationsClient = original.OperationsClient +type OperationsListResult = original.OperationsListResult +type OperationsListResultIterator = original.OperationsListResultIterator +type OperationsListResultPage = original.OperationsListResultPage +type Origin = original.Origin +type OriginListResult = original.OriginListResult +type OriginListResultIterator = original.OriginListResultIterator +type OriginListResultPage = original.OriginListResultPage +type OriginProperties = original.OriginProperties +type OriginPropertiesParameters = original.OriginPropertiesParameters +type OriginUpdateParameters = original.OriginUpdateParameters +type OriginsClient = original.OriginsClient +type OriginsUpdateFuture = original.OriginsUpdateFuture +type PostArgsMatchConditionParameters = original.PostArgsMatchConditionParameters +type Profile = original.Profile +type ProfileListResult = original.ProfileListResult +type ProfileListResultIterator = original.ProfileListResultIterator +type ProfileListResultPage = original.ProfileListResultPage +type ProfileProperties = original.ProfileProperties +type ProfileUpdateParameters = original.ProfileUpdateParameters +type ProfilesClient = original.ProfilesClient +type ProfilesCreateFuture = original.ProfilesCreateFuture +type ProfilesDeleteFuture = original.ProfilesDeleteFuture +type ProfilesUpdateFuture = original.ProfilesUpdateFuture +type ProxyResource = original.ProxyResource +type PurgeParameters = original.PurgeParameters +type QueryStringMatchConditionParameters = original.QueryStringMatchConditionParameters +type RemoteAddressMatchConditionParameters = original.RemoteAddressMatchConditionParameters +type RequestBodyMatchConditionParameters = original.RequestBodyMatchConditionParameters +type RequestHeaderMatchConditionParameters = original.RequestHeaderMatchConditionParameters +type RequestMethodMatchConditionParameters = original.RequestMethodMatchConditionParameters +type RequestSchemeMatchConditionParameters = original.RequestSchemeMatchConditionParameters +type RequestURIMatchConditionParameters = original.RequestURIMatchConditionParameters +type Resource = original.Resource +type ResourceUsage = original.ResourceUsage +type ResourceUsageClient = original.ResourceUsageClient +type ResourceUsageListResult = original.ResourceUsageListResult +type ResourceUsageListResultIterator = original.ResourceUsageListResultIterator +type ResourceUsageListResultPage = original.ResourceUsageListResultPage +type Sku = original.Sku +type SsoURI = original.SsoURI +type SupportedOptimizationTypesListResult = original.SupportedOptimizationTypesListResult +type TrackedResource = original.TrackedResource +type URLFileExtensionMatchConditionParameters = original.URLFileExtensionMatchConditionParameters +type URLFileNameMatchConditionParameters = original.URLFileNameMatchConditionParameters +type URLPathMatchConditionParameters = original.URLPathMatchConditionParameters +type URLRedirectAction = original.URLRedirectAction +type URLRedirectActionParameters = original.URLRedirectActionParameters +type URLRewriteAction = original.URLRewriteAction +type URLRewriteActionParameters = original.URLRewriteActionParameters +type UserManagedHTTPSParameters = original.UserManagedHTTPSParameters +type ValidateCustomDomainInput = original.ValidateCustomDomainInput +type ValidateCustomDomainOutput = original.ValidateCustomDomainOutput +type ValidateProbeInput = original.ValidateProbeInput +type ValidateProbeOutput = original.ValidateProbeOutput + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewCustomDomainListResultIterator(page CustomDomainListResultPage) CustomDomainListResultIterator { + return original.NewCustomDomainListResultIterator(page) +} +func NewCustomDomainListResultPage(getNextPage func(context.Context, CustomDomainListResult) (CustomDomainListResult, error)) CustomDomainListResultPage { + return original.NewCustomDomainListResultPage(getNextPage) +} +func NewCustomDomainsClient(subscriptionID string) CustomDomainsClient { + return original.NewCustomDomainsClient(subscriptionID) +} +func NewCustomDomainsClientWithBaseURI(baseURI string, subscriptionID string) CustomDomainsClient { + return original.NewCustomDomainsClientWithBaseURI(baseURI, subscriptionID) +} +func NewEdgeNodesClient(subscriptionID string) EdgeNodesClient { + return original.NewEdgeNodesClient(subscriptionID) +} +func NewEdgeNodesClientWithBaseURI(baseURI string, subscriptionID string) EdgeNodesClient { + return original.NewEdgeNodesClientWithBaseURI(baseURI, subscriptionID) +} +func NewEdgenodeResultIterator(page EdgenodeResultPage) EdgenodeResultIterator { + return original.NewEdgenodeResultIterator(page) +} +func NewEdgenodeResultPage(getNextPage func(context.Context, EdgenodeResult) (EdgenodeResult, error)) EdgenodeResultPage { + return original.NewEdgenodeResultPage(getNextPage) +} +func NewEndpointListResultIterator(page EndpointListResultPage) EndpointListResultIterator { + return original.NewEndpointListResultIterator(page) +} +func NewEndpointListResultPage(getNextPage func(context.Context, EndpointListResult) (EndpointListResult, error)) EndpointListResultPage { + return original.NewEndpointListResultPage(getNextPage) +} +func NewEndpointsClient(subscriptionID string) EndpointsClient { + return original.NewEndpointsClient(subscriptionID) +} +func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient { + return original.NewEndpointsClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewOperationsListResultIterator(page OperationsListResultPage) OperationsListResultIterator { + return original.NewOperationsListResultIterator(page) +} +func NewOperationsListResultPage(getNextPage func(context.Context, OperationsListResult) (OperationsListResult, error)) OperationsListResultPage { + return original.NewOperationsListResultPage(getNextPage) +} +func NewOriginListResultIterator(page OriginListResultPage) OriginListResultIterator { + return original.NewOriginListResultIterator(page) +} +func NewOriginListResultPage(getNextPage func(context.Context, OriginListResult) (OriginListResult, error)) OriginListResultPage { + return original.NewOriginListResultPage(getNextPage) +} +func NewOriginsClient(subscriptionID string) OriginsClient { + return original.NewOriginsClient(subscriptionID) +} +func NewOriginsClientWithBaseURI(baseURI string, subscriptionID string) OriginsClient { + return original.NewOriginsClientWithBaseURI(baseURI, subscriptionID) +} +func NewProfileListResultIterator(page ProfileListResultPage) ProfileListResultIterator { + return original.NewProfileListResultIterator(page) +} +func NewProfileListResultPage(getNextPage func(context.Context, ProfileListResult) (ProfileListResult, error)) ProfileListResultPage { + return original.NewProfileListResultPage(getNextPage) +} +func NewProfilesClient(subscriptionID string) ProfilesClient { + return original.NewProfilesClient(subscriptionID) +} +func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) ProfilesClient { + return original.NewProfilesClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceUsageClient(subscriptionID string) ResourceUsageClient { + return original.NewResourceUsageClient(subscriptionID) +} +func NewResourceUsageClientWithBaseURI(baseURI string, subscriptionID string) ResourceUsageClient { + return original.NewResourceUsageClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceUsageListResultIterator(page ResourceUsageListResultPage) ResourceUsageListResultIterator { + return original.NewResourceUsageListResultIterator(page) +} +func NewResourceUsageListResultPage(getNextPage func(context.Context, ResourceUsageListResult) (ResourceUsageListResult, error)) ResourceUsageListResultPage { + return original.NewResourceUsageListResultPage(getNextPage) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleCacheBehaviorValues() []CacheBehavior { + return original.PossibleCacheBehaviorValues() +} +func PossibleCertificateSourceValues() []CertificateSource { + return original.PossibleCertificateSourceValues() +} +func PossibleCertificateTypeValues() []CertificateType { + return original.PossibleCertificateTypeValues() +} +func PossibleCookiesOperatorValues() []CookiesOperator { + return original.PossibleCookiesOperatorValues() +} +func PossibleCustomDomainResourceStateValues() []CustomDomainResourceState { + return original.PossibleCustomDomainResourceStateValues() +} +func PossibleCustomHTTPSProvisioningStateValues() []CustomHTTPSProvisioningState { + return original.PossibleCustomHTTPSProvisioningStateValues() +} +func PossibleCustomHTTPSProvisioningSubstateValues() []CustomHTTPSProvisioningSubstate { + return original.PossibleCustomHTTPSProvisioningSubstateValues() +} +func PossibleDestinationProtocolValues() []DestinationProtocol { + return original.PossibleDestinationProtocolValues() +} +func PossibleEndpointResourceStateValues() []EndpointResourceState { + return original.PossibleEndpointResourceStateValues() +} +func PossibleGeoFilterActionsValues() []GeoFilterActions { + return original.PossibleGeoFilterActionsValues() +} +func PossibleHeaderActionValues() []HeaderAction { + return original.PossibleHeaderActionValues() +} +func PossibleMinimumTLSVersionValues() []MinimumTLSVersion { + return original.PossibleMinimumTLSVersionValues() +} +func PossibleNameBasicDeliveryRuleActionValues() []NameBasicDeliveryRuleAction { + return original.PossibleNameBasicDeliveryRuleActionValues() +} +func PossibleNameValues() []Name { + return original.PossibleNameValues() +} +func PossibleOptimizationTypeValues() []OptimizationType { + return original.PossibleOptimizationTypeValues() +} +func PossibleOriginResourceStateValues() []OriginResourceState { + return original.PossibleOriginResourceStateValues() +} +func PossiblePostArgsOperatorValues() []PostArgsOperator { + return original.PossiblePostArgsOperatorValues() +} +func PossibleProfileResourceStateValues() []ProfileResourceState { + return original.PossibleProfileResourceStateValues() +} +func PossibleProtocolTypeValues() []ProtocolType { + return original.PossibleProtocolTypeValues() +} +func PossibleQueryStringBehaviorValues() []QueryStringBehavior { + return original.PossibleQueryStringBehaviorValues() +} +func PossibleQueryStringCachingBehaviorValues() []QueryStringCachingBehavior { + return original.PossibleQueryStringCachingBehaviorValues() +} +func PossibleQueryStringOperatorValues() []QueryStringOperator { + return original.PossibleQueryStringOperatorValues() +} +func PossibleRedirectTypeValues() []RedirectType { + return original.PossibleRedirectTypeValues() +} +func PossibleRemoteAddressOperatorValues() []RemoteAddressOperator { + return original.PossibleRemoteAddressOperatorValues() +} +func PossibleRequestBodyOperatorValues() []RequestBodyOperator { + return original.PossibleRequestBodyOperatorValues() +} +func PossibleRequestHeaderOperatorValues() []RequestHeaderOperator { + return original.PossibleRequestHeaderOperatorValues() +} +func PossibleRequestURIOperatorValues() []RequestURIOperator { + return original.PossibleRequestURIOperatorValues() +} +func PossibleResourceTypeValues() []ResourceType { + return original.PossibleResourceTypeValues() +} +func PossibleSkuNameValues() []SkuName { + return original.PossibleSkuNameValues() +} +func PossibleTransformValues() []Transform { + return original.PossibleTransformValues() +} +func PossibleURLFileExtensionOperatorValues() []URLFileExtensionOperator { + return original.PossibleURLFileExtensionOperatorValues() +} +func PossibleURLFileNameOperatorValues() []URLFileNameOperator { + return original.PossibleURLFileNameOperatorValues() +} +func PossibleURLPathOperatorValues() []URLPathOperator { + return original.PossibleURLPathOperatorValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/latest" +} +func Version() string { + return original.Version() +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 2d0d3729bc0f..f257ea508842 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -8,6 +8,7 @@ cloud.google.com/go/internal/version cloud.google.com/go/storage # github.com/Azure/azure-sdk-for-go v38.1.0+incompatible github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources +github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn github.com/Azure/azure-sdk-for-go/services/analysisservices/mgmt/2017-08-01/analysisservices github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2018-01-01/apimanagement github.com/Azure/azure-sdk-for-go/services/appconfiguration/mgmt/2019-10-01/appconfiguration From 808ee7c25bf3bf820ec788835508896c2ce7b75c Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 8 Mar 2020 22:00:32 +0100 Subject: [PATCH 50/92] disable adding of duration when using BypassCache behavior --- .../cdn/delivery_rule_actions/cache_expiration.go | 10 ++++++++-- .../services/cdn/endpoint_delivery_policy.go | 12 ++++++++---- .../internal/services/cdn/endpoint_delivery_rule.go | 10 +++++++--- .../services/cdn/resource_arm_cdn_endpoint.go | 12 ++++++++++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go index 1fccf6a58826..8db750c39160 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go +++ b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go @@ -1,6 +1,8 @@ package delivery_rule_actions import ( + "fmt" + "github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -30,7 +32,7 @@ func CacheExpiration() *schema.Resource { } } -func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) *cdn.DeliveryRuleCacheExpirationAction { +func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) (*cdn.DeliveryRuleCacheExpirationAction, error) { cacheExpirationAction := cdn.DeliveryRuleCacheExpirationAction{ Name: cdn.NameCacheExpiration, Parameters: &cdn.CacheExpirationActionParameters{ @@ -41,10 +43,14 @@ func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) *cdn. } if duration := cea["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) } - return &cacheExpirationAction + return &cacheExpirationAction, nil } func FlattenArmCdnEndpointActionCacheExpiration(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy.go b/azurerm/internal/services/cdn/endpoint_delivery_policy.go index 2163ce66b9e9..387b3aa25875 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_policy.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_policy.go @@ -30,10 +30,10 @@ func EndpointDeliveryPolicy() *schema.Schema { } } -func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy { +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { policies := d.Get("delivery_policy").([]interface{}) if len(policies) == 0 { - return nil + return nil, nil } deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} @@ -46,11 +46,15 @@ func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) *cdn.EndpointPro rules := policy["rule"].([]interface{}) deliveryRules := make([]cdn.DeliveryRule, len(rules)) for i, rule := range rules { - deliveryRules[i] = expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + delRule, err := expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + if err != nil { + return nil, err + } + deliveryRules[i] = *delRule } deliveryPolicy.Rules = &deliveryRules - return &deliveryPolicy + return &deliveryPolicy, nil } func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 971d798618bc..3e292bf54c2c 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -49,7 +49,7 @@ func EndpointDeliveryRule() *schema.Resource { } } -func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryRule { +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))), @@ -70,12 +70,16 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) cdn.DeliveryR } if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { - actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{}))) + action, err := delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{})) + if err != nil { + return nil, err + } + actions = append(actions, *action) } deliveryRule.Actions = &actions - return deliveryRule + return &deliveryRule, nil } func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index 1ad6ad768024..e725509732c7 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -238,7 +238,6 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) - deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -246,6 +245,11 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error expanding `geo_filter`: %s", err) } + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + if err != nil { + return fmt.Errorf("Error expanding `delivery_policy`: %s", err) + } + endpoint := cdn.Endpoint{ Location: &location, EndpointProperties: &cdn.EndpointProperties{ @@ -317,7 +321,6 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro probePath := d.Get("probe_path").(string) optimizationType := d.Get("optimization_type").(string) contentTypes := expandArmCdnEndpointContentTypesToCompress(d) - deliveryPolicy := expandArmCdnEndpointDeliveryPolicy(d) t := d.Get("tags").(map[string]interface{}) geoFilters, err := expandArmCdnEndpointGeoFilters(d) @@ -325,6 +328,11 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error expanding `geo_filter`: %s", err) } + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + if err != nil { + return fmt.Errorf("Error expanding `delivery_policy`: %s", err) + } + endpoint := cdn.EndpointUpdateParameters{ EndpointPropertiesUpdateParameters: &cdn.EndpointPropertiesUpdateParameters{ ContentTypesToCompress: &contentTypes, From 91a7763513fa6eb020ef635225dec10f2922336c Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 9 Mar 2020 21:32:13 +0100 Subject: [PATCH 51/92] remove obsolete policy layer; make removing of rules working as well --- .../services/cdn/endpoint_delivery_policy.go | 83 ------------------- .../services/cdn/endpoint_delivery_rule.go | 80 +++++++++--------- .../services/cdn/resource_arm_cdn_endpoint.go | 46 ++++++++-- 3 files changed, 83 insertions(+), 126 deletions(-) delete mode 100644 azurerm/internal/services/cdn/endpoint_delivery_policy.go diff --git a/azurerm/internal/services/cdn/endpoint_delivery_policy.go b/azurerm/internal/services/cdn/endpoint_delivery_policy.go deleted file mode 100644 index 387b3aa25875..000000000000 --- a/azurerm/internal/services/cdn/endpoint_delivery_policy.go +++ /dev/null @@ -1,83 +0,0 @@ -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/utils" -) - -func EndpointDeliveryPolicy() *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Optional: true, - }, - - "rule": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 4, - Elem: EndpointDeliveryRule(), - }, - }, - }, - } -} - -func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { - policies := d.Get("delivery_policy").([]interface{}) - if len(policies) == 0 { - return nil, nil - } - - deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{} - - policy := policies[0].(map[string]interface{}) - if descr, ok := policy["description"]; ok { - deliveryPolicy.Description = utils.String(descr.(string)) - } - - rules := policy["rule"].([]interface{}) - deliveryRules := make([]cdn.DeliveryRule, len(rules)) - for i, rule := range rules { - delRule, err := expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) - if err != nil { - return nil, err - } - deliveryRules[i] = *delRule - } - deliveryPolicy.Rules = &deliveryRules - - return &deliveryPolicy, nil -} - -func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { - deliveryPolicies := make([]interface{}, 0) - - if deliveryPolicy == nil { - return deliveryPolicies - } - - dp := make(map[string]interface{}) - if deliveryPolicy.Description != nil { - dp["description"] = *deliveryPolicy.Description - } - - if deliveryPolicy.Rules != nil && len(*deliveryPolicy.Rules) > 0 { - rules := make([]map[string]interface{}, len(*deliveryPolicy.Rules)) - for i, rule := range *deliveryPolicy.Rules { - rules[i] = flattenArmCdnEndpointDeliveryRule(&rule) - } - dp["rule"] = rules - } - - deliveryPolicies = append(deliveryPolicies, dp) - - return deliveryPolicies -} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 3e292bf54c2c..fcf494884618 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -10,40 +10,44 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func EndpointDeliveryRule() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), - }, - - "order": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, - - "request_scheme_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: delivery_rule_conditions.RequestScheme(), - }, - - "url_redirect_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: delivery_rule_actions.URLRedirect(), - }, - - "cache_expiration_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: delivery_rule_actions.CacheExpiration(), +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.CdnEndpointDeliveryPolicyRuleName(), + }, + + "order": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + + "request_scheme_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_conditions.RequestScheme(), + }, + + "url_redirect_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.URLRedirect(), + }, + + "cache_expiration_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: delivery_rule_actions.CacheExpiration(), + }, }, }, } @@ -65,10 +69,6 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver actions := make([]cdn.BasicDeliveryRuleAction, 0) - if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { - actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) - } - if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { action, err := delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{})) if err != nil { @@ -77,6 +77,10 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver actions = append(actions, *action) } + if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { + actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + } + deliveryRule.Actions = &actions return &deliveryRule, nil diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index e725509732c7..db44894802cb 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -197,7 +197,7 @@ func resourceArmCdnEndpoint() *schema.Resource { Computed: true, }, - "delivery_policy": EndpointDeliveryPolicy(), + "delivery_rule": EndpointDeliveryRule(), "tags": tags.Schema(), }, @@ -330,7 +330,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) if err != nil { - return fmt.Errorf("Error expanding `delivery_policy`: %s", err) + return fmt.Errorf("Error expanding `delivery_rule`: %s", err) } endpoint := cdn.EndpointUpdateParameters{ @@ -425,9 +425,9 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting `origin`: %+v", err) } - deliveryPolicy := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) - if err := d.Set("delivery_policy", deliveryPolicy); err != nil { - return fmt.Errorf("Error setting `delivery_policy`: %+v", err) + deliveryRules := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) + if err := d.Set("delivery_rule", deliveryRules); err != nil { + return fmt.Errorf("Error setting `delivery_rule`: %+v", err) } } @@ -603,3 +603,39 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface return results } + +func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { + deliveryRules := make([]cdn.DeliveryRule, 0) + deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{ + Description: utils.String(""), + Rules: &deliveryRules, + } + + rules := d.Get("delivery_rule").([]interface{}) + if len(rules) == 0 { + return &deliveryPolicy, nil + } + + for _, rule := range rules { + delRule, err := expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + if err != nil { + return nil, err + } + deliveryRules = append(deliveryRules, *delRule) + } + + return &deliveryPolicy, nil +} + +func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { + if deliveryPolicy == nil { + return nil + } + + deliveryRules := make([]interface{}, len(*deliveryPolicy.Rules)) + for i, rule := range *deliveryPolicy.Rules { + deliveryRules[i] = flattenArmCdnEndpointDeliveryRule(&rule) + } + + return deliveryRules +} From 75a23dd695391a4267e091b68e83fc968d78f15b Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 11 Mar 2020 20:19:45 +0100 Subject: [PATCH 52/92] rename packages without underscores --- .../cache_expiration.go | 2 +- .../url_redirect.go | 2 +- .../request_scheme.go | 2 +- .../services/cdn/endpoint_delivery_rule.go | 26 +++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) rename azurerm/internal/services/cdn/{delivery_rule_actions => deliveryruleactions}/cache_expiration.go (98%) rename azurerm/internal/services/cdn/{delivery_rule_actions => deliveryruleactions}/url_redirect.go (99%) rename azurerm/internal/services/cdn/{delivery_rule_conditions => deliveryruleconditions}/request_scheme.go (98%) diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go similarity index 98% rename from azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go rename to azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go index 8db750c39160..d0730948d229 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go @@ -1,4 +1,4 @@ -package delivery_rule_actions +package deliveryruleactions import ( "fmt" diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go similarity index 99% rename from azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go rename to azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go index 9a8551ec8d3b..3aec171fd9a6 100644 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go @@ -1,4 +1,4 @@ -package delivery_rule_actions +package deliveryruleactions import ( "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go similarity index 98% rename from azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go rename to azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go index 920175fa2fe5..81954c1f7437 100644 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go @@ -1,4 +1,4 @@ -package delivery_rule_conditions +package deliveryruleconditions import ( "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index fcf494884618..ee36c6600433 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -5,8 +5,8 @@ import ( "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/delivery_rule_actions" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/cdn/delivery_rule_conditions" + "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" ) @@ -32,21 +32,21 @@ func EndpointDeliveryRule() *schema.Schema { Type: schema.TypeList, Optional: true, MaxItems: 1, - Elem: delivery_rule_conditions.RequestScheme(), + Elem: deliveryruleconditions.RequestScheme(), }, - "url_redirect_action": { + "cache_expiration_action": { Type: schema.TypeList, Optional: true, MaxItems: 1, - Elem: delivery_rule_actions.URLRedirect(), + Elem: deliveryruleactions.CacheExpiration(), }, - "cache_expiration_action": { + "url_redirect_action": { Type: schema.TypeList, Optional: true, MaxItems: 1, - Elem: delivery_rule_actions.CacheExpiration(), + Elem: deliveryruleactions.URLRedirect(), }, }, }, @@ -62,7 +62,7 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver conditions := make([]cdn.BasicDeliveryRuleCondition, 0) if rsc := rule["request_scheme_condition"]; len(rsc.([]interface{})) > 0 { - conditions = append(conditions, *delivery_rule_conditions.ExpandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) } deliveryRule.Conditions = &conditions @@ -70,7 +70,7 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver actions := make([]cdn.BasicDeliveryRuleAction, 0) if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { - action, err := delivery_rule_actions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{})) + action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{})) if err != nil { return nil, err } @@ -78,7 +78,7 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver } if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { - actions = append(actions, *delivery_rule_actions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) } deliveryRule.Actions = &actions @@ -104,7 +104,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Conditions != nil { for _, basicDeliveryRuleCondition := range *deliveryRule.Conditions { if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { - res["request_scheme_condition"] = []interface{}{delivery_rule_conditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} + res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue } } @@ -113,12 +113,12 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Actions != nil { for _, basicDeliveryRuleAction := range *deliveryRule.Actions { if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { - res["cache_expiration_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionCacheExpiration(action)} + res["cache_expiration_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheExpiration(action)} continue } if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { - res["url_redirect_action"] = []interface{}{delivery_rule_actions.FlattenArmCdnEndpointActionUrlRedirect(action)} + res["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } } From 7ffd32ed5a1f5d4207a80f3889bffc28e8d4da35 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 11 Mar 2020 21:04:34 +0100 Subject: [PATCH 53/92] add cache key query string action --- .../cache_key_query_string.go | 66 +++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 20 ++++++ 2 files changed, 86 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleactions/cache_key_query_string.go 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..db001b9feceb --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/cache_key_query_string.go @@ -0,0 +1,66 @@ +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(ckqsa map[string]interface{}) (*cdn.DeliveryRuleCacheKeyQueryStringAction, error) { + cacheKeyQueryStringAction := cdn.DeliveryRuleCacheKeyQueryStringAction{ + Name: cdn.NameCacheKeyQueryString, + Parameters: &cdn.CacheKeyQueryStringActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheKeyQueryStringBehaviorActionParameters"), + QueryStringBehavior: cdn.QueryStringBehavior(ckqsa["behavior"].(string)), + }, + } + + if parameters := ckqsa["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) + } + + return &cacheKeyQueryStringAction, nil +} + +func FlattenArmCdnEndpointActionCacheKeyQueryString(ckqsa *cdn.DeliveryRuleCacheKeyQueryStringAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := ckqsa.Parameters; params != nil { + res["behavior"] = string(params.QueryStringBehavior) + + if params.QueryParameters != nil { + res["parameters"] = *params.QueryParameters + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index ee36c6600433..0aed0dde9cd8 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -42,6 +42,13 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleactions.CacheExpiration(), }, + "cache_key_query_string_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.CacheKeyQueryString(), + }, + "url_redirect_action": { Type: schema.TypeList, Optional: true, @@ -77,6 +84,14 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver actions = append(actions, *action) } + if ckqsa := rule["cache_key_query_string_action"]; len(ckqsa.([]interface{})) > 0 { + action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheKeyQueryString(ckqsa.([]interface{})[0].(map[string]interface{})) + if err != nil { + return nil, err + } + actions = append(actions, *action) + } + if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) } @@ -117,6 +132,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if action, isCacheKeyQueryStringAction := basicDeliveryRuleAction.AsDeliveryRuleCacheKeyQueryStringAction(); isCacheKeyQueryStringAction { + res["cache_key_query_string_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheKeyQueryString(action)} + continue + } + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { res["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue From fe21aa5425be0689c3eefa2e9787092030de6449 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 11 Mar 2020 21:14:26 +0100 Subject: [PATCH 54/92] remove obsolete files --- .../delivery_rule_actions/cache_expiration.go | 68 ---------- .../cdn/delivery_rule_actions/url_redirect.go | 123 ------------------ .../request_scheme.go | 81 ------------ 3 files changed, 272 deletions(-) delete mode 100644 azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go delete mode 100644 azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go delete mode 100644 azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go b/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go deleted file mode 100644 index 8db750c39160..000000000000 --- a/azurerm/internal/services/cdn/delivery_rule_actions/cache_expiration.go +++ /dev/null @@ -1,68 +0,0 @@ -package delivery_rule_actions - -import ( - "fmt" - - "github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/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(cea map[string]interface{}) (*cdn.DeliveryRuleCacheExpirationAction, error) { - cacheExpirationAction := cdn.DeliveryRuleCacheExpirationAction{ - Name: cdn.NameCacheExpiration, - Parameters: &cdn.CacheExpirationActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters"), - CacheBehavior: cdn.CacheBehavior(cea["behavior"].(string)), - CacheType: utils.String("All"), - }, - } - - if duration := cea["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) - } - - return &cacheExpirationAction, nil -} - -func FlattenArmCdnEndpointActionCacheExpiration(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { - res := make(map[string]interface{}, 1) - - if params := cea.Parameters; params != nil { - res["behavior"] = string(params.CacheBehavior) - - if params.CacheDuration != nil { - res["duration"] = *params.CacheDuration - } - } - - return res -} diff --git a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go b/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go deleted file mode 100644 index 9a8551ec8d3b..000000000000 --- a/azurerm/internal/services/cdn/delivery_rule_actions/url_redirect.go +++ /dev/null @@ -1,123 +0,0 @@ -package delivery_rule_actions - -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/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.RuleActionUrlRedirectPath(), - }, - - "fragment": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.RuleActionUrlRedirectFragment(), - }, - }, - } -} - -func ExpandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { - urlRedirectAction := cdn.URLRedirectAction{ - Name: cdn.NameURLRedirect, - } - - params := cdn.URLRedirectActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRedirectActionParameters"), - RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), - } - - if destProt := ura["protocol"]; destProt.(string) != "" { - params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) - } - - if hostname := ura["hostname"]; hostname.(string) != "" { - params.CustomHostname = utils.String(hostname.(string)) - } - - if path := ura["path"]; path.(string) != "" { - params.CustomPath = utils.String(path.(string)) - } - - if queryString := ura["query_string"]; queryString.(string) != "" { - params.CustomQueryString = utils.String(queryString.(string)) - } - - if fragment := ura["fragment"]; fragment.(string) != "" { - params.CustomFragment = utils.String(fragment.(string)) - } - - urlRedirectAction.Parameters = ¶ms - - return &urlRedirectAction -} - -func FlattenArmCdnEndpointActionUrlRedirect(ura *cdn.URLRedirectAction) map[string]interface{} { - res := make(map[string]interface{}, 1) - - if params := ura.Parameters; params != nil { - res["redirect_type"] = string(params.RedirectType) - - res["protocol"] = string(params.DestinationProtocol) - - if params.CustomHostname != nil { - res["hostname"] = *params.CustomHostname - } - - if params.CustomPath != nil { - res["path"] = *params.CustomPath - } - - if params.CustomQueryString != nil { - res["query_string"] = *params.CustomQueryString - } - - if params.CustomFragment != nil { - res["fragment"] = *params.CustomFragment - } - } - - return res -} diff --git a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go b/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go deleted file mode 100644 index 920175fa2fe5..000000000000 --- a/azurerm/internal/services/cdn/delivery_rule_conditions/request_scheme.go +++ /dev/null @@ -1,81 +0,0 @@ -package delivery_rule_conditions - -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 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_value": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{ - "HTTP", - "HTTPS", - }, false), - }, - }, - } -} - -func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { - requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ - Name: cdn.NameRequestScheme, - } - - matchValues := []string{rsc["match_value"].(string)} - params := cdn.RequestSchemeMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), - MatchValues: &matchValues, - NegateCondition: utils.Bool(rsc["negate_condition"].(bool)), - } - - if operator := rsc["operator"]; operator.(string) != "" { - params.Operator = utils.String(operator.(string)) - } - - params.NegateCondition = utils.Bool(rsc["negate_condition"].(bool)) - - requestSchemeCondition.Parameters = ¶ms - - return &requestSchemeCondition -} - -func FlattenArmCdnEndpointConditionRequestScheme(condition *cdn.DeliveryRuleRequestSchemeCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) - - if params := condition.Parameters; params != nil { - if params.Operator != nil { - res["operator"] = *params.Operator - } - - if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition - } - - if params.MatchValues != nil && len(*params.MatchValues) > 0 { - res["match_value"] = (*params.MatchValues)[0] - } - } - - return res -} From 000bd25e42f49d43008e0b6dafbc6452ab898300 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 11 Mar 2020 21:44:08 +0100 Subject: [PATCH 55/92] add modify request header action --- .../modify_request_header.go | 66 +++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 33 +++++++--- 2 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 azurerm/internal/services/cdn/deliveryruleactions/modify_request_header.go 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..d8fbbca7a94b --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/modify_request_header.go @@ -0,0 +1,66 @@ +package deliveryruleactions + +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 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(mrha map[string]interface{}) *cdn.DeliveryRuleRequestHeaderAction { + requestHeaderAction := cdn.DeliveryRuleRequestHeaderAction{ + Name: cdn.NameModifyRequestHeader, + Parameters: &cdn.HeaderActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters"), + HeaderAction: cdn.HeaderAction(mrha["action"].(string)), + HeaderName: utils.String(mrha["name"].(string)), + }, + } + + if value := mrha["value"].(string); value != "" { + requestHeaderAction.Parameters.Value = utils.String(value) + } + + return &requestHeaderAction +} + +func FlattenArmCdnEndpointActionModifyRequestHeader(mrha *cdn.DeliveryRuleRequestHeaderAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := mrha.Parameters; params != nil { + res["action"] = string(params.HeaderAction) + res["name"] = *params.HeaderName + + if params.Value != nil { + res["value"] = *params.Value + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 0aed0dde9cd8..445305a14d2f 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -49,6 +49,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleactions.CacheKeyQueryString(), }, + "modify_request_header_action": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleactions.ModifyRequestHeader(), + }, + "url_redirect_action": { Type: schema.TypeList, Optional: true, @@ -68,32 +74,38 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver conditions := make([]cdn.BasicDeliveryRuleCondition, 0) - if rsc := rule["request_scheme_condition"]; len(rsc.([]interface{})) > 0 { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc.([]interface{})[0].(map[string]interface{}))) + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } deliveryRule.Conditions = &conditions actions := make([]cdn.BasicDeliveryRuleAction, 0) - if cea := rule["cache_expiration_action"]; len(cea.([]interface{})) > 0 { - action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheExpiration(cea.([]interface{})[0].(map[string]interface{})) + if cea := rule["cache_expiration_action"].([]interface{}); len(cea) > 0 { + action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheExpiration(cea[0].(map[string]interface{})) if err != nil { return nil, err } actions = append(actions, *action) } - if ckqsa := rule["cache_key_query_string_action"]; len(ckqsa.([]interface{})) > 0 { - action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheKeyQueryString(ckqsa.([]interface{})[0].(map[string]interface{})) + if ckqsa := rule["cache_key_query_string_action"].([]interface{}); len(ckqsa) > 0 { + action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheKeyQueryString(ckqsa[0].(map[string]interface{})) if err != nil { return nil, err } actions = append(actions, *action) } - if ura := rule["url_redirect_action"]; len(ura.([]interface{})) > 0 { - actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura.([]interface{})[0].(map[string]interface{}))) + if mrha := rule["modify_request_header_action"].([]interface{}); len(mrha) > 0 { + for _, rawAction := range mrha { + actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionModifyRequestHeader(rawAction.(map[string]interface{}))) + } + } + + if ura := rule["url_redirect_action"].([]interface{}); len(ura) > 0 { + actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura[0].(map[string]interface{}))) } deliveryRule.Actions = &actions @@ -137,6 +149,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if action, isModifyRequestHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleRequestHeaderAction(); isModifyRequestHeaderAction { + res["modify_request_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyRequestHeader(action)} + continue + } + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { res["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue From 1820029a2ec96c4dab2c4005839864178e85f32e Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 11 Mar 2020 22:05:19 +0100 Subject: [PATCH 56/92] add modify response header action --- .../modify_response_header.go | 66 +++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 17 +++++ 2 files changed, 83 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleactions/modify_response_header.go 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..f8ed28dee3dd --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/modify_response_header.go @@ -0,0 +1,66 @@ +package deliveryruleactions + +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 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(mrha map[string]interface{}) *cdn.DeliveryRuleResponseHeaderAction { + requestHeaderAction := cdn.DeliveryRuleResponseHeaderAction{ + Name: cdn.NameModifyResponseHeader, + Parameters: &cdn.HeaderActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters"), + HeaderAction: cdn.HeaderAction(mrha["action"].(string)), + HeaderName: utils.String(mrha["name"].(string)), + }, + } + + if value := mrha["value"].(string); value != "" { + requestHeaderAction.Parameters.Value = utils.String(value) + } + + return &requestHeaderAction +} + +func FlattenArmCdnEndpointActionModifyResponseHeader(mrha *cdn.DeliveryRuleResponseHeaderAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := mrha.Parameters; params != nil { + res["action"] = string(params.HeaderAction) + res["name"] = *params.HeaderName + + if params.Value != nil { + res["value"] = *params.Value + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 445305a14d2f..8a865a6431e3 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -55,6 +55,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleactions.ModifyRequestHeader(), }, + "modify_response_header_action": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleactions.ModifyResponseHeader(), + }, + "url_redirect_action": { Type: schema.TypeList, Optional: true, @@ -104,6 +110,12 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver } } + if mrha := rule["modify_response_header_action"].([]interface{}); len(mrha) > 0 { + for _, rawAction := range mrha { + actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionModifyResponseHeader(rawAction.(map[string]interface{}))) + } + } + if ura := rule["url_redirect_action"].([]interface{}); len(ura) > 0 { actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura[0].(map[string]interface{}))) } @@ -154,6 +166,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if action, isModifyResponseHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleResponseHeaderAction(); isModifyResponseHeaderAction { + res["modify_response_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyResponseHeader(action)} + continue + } + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { res["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue From 3cf2cec66894d8f76df9dcec152cbef46143d4e6 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 11 Mar 2020 22:27:50 +0100 Subject: [PATCH 57/92] extract delivery rule actions and conditions into own function --- .../services/cdn/endpoint_delivery_rule.go | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 8a865a6431e3..177df70b86df 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -78,14 +78,29 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver Order: utils.Int32(int32(rule["order"].(int))), } + conditions := expandDeliveryRuleConditions(rule) + deliveryRule.Conditions = &conditions + + actions, err := expandDeliveryRuleActions(rule) + if err != nil { + return nil, err + } + deliveryRule.Actions = &actions + + return &deliveryRule, nil +} + +func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDeliveryRuleCondition { conditions := make([]cdn.BasicDeliveryRuleCondition, 0) if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } - deliveryRule.Conditions = &conditions + return conditions +} +func expandDeliveryRuleActions(rule map[string]interface{}) ([]cdn.BasicDeliveryRuleAction, error) { actions := make([]cdn.BasicDeliveryRuleAction, 0) if cea := rule["cache_expiration_action"].([]interface{}); len(cea) > 0 { @@ -120,9 +135,7 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura[0].(map[string]interface{}))) } - deliveryRule.Actions = &actions - - return &deliveryRule, nil + return actions, nil } func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { From dd5e6811474ff6cc63416f08d526deb6e9b10480 Mon Sep 17 00:00:00 2001 From: rob Date: Thu, 12 Mar 2020 11:52:02 +0100 Subject: [PATCH 58/92] add URL Rewrite action --- azurerm/helpers/validate/cdn.go | 27 ++++-- azurerm/helpers/validate/cdn_test.go | 88 ++++++++++++++++++- .../cdn/deliveryruleactions/url_rewrite.go | 61 +++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 18 +++- 4 files changed, 185 insertions(+), 9 deletions(-) create mode 100644 azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index 015199845596..878a036aee50 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -2,20 +2,26 @@ package validate import ( "fmt" - "regexp" - "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "regexp" + "strings" ) -func CdnEndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { +func EndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { return validation.StringMatch( regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$"), "The Delivery Policy 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("^(/.*)?$"), @@ -55,9 +61,16 @@ func RuleActionUrlRedirectFragment() schema.SchemaValidateFunc { ) } -func RuleActionCacheExpirationDuration() schema.SchemaValidateFunc { +func RuleActionUrlRewriteSourcePattern() 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.", + 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 index b98b64ab37e6..cf7035318466 100644 --- a/azurerm/helpers/validate/cdn_test.go +++ b/azurerm/helpers/validate/cdn_test.go @@ -45,7 +45,7 @@ func TestCdnEndpointDeliveryPolicyRuleName(t *testing.T) { for _, tc := range cases { t.Run(tc.Name, func(t *testing.T) { - _, errors := CdnEndpointDeliveryPolicyRuleName()(tc.Name, "name") + _, errors := EndpointDeliveryPolicyRuleName()(tc.Name, "name") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { @@ -242,3 +242,89 @@ func TestRuleActionCacheExpirationDuration(t *testing.T) { }) } } + +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/deliveryruleactions/url_rewrite.go b/azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go new file mode 100644 index 000000000000..f92c87b03a70 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go @@ -0,0 +1,61 @@ +package deliveryruleactions + +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/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(ura map[string]interface{}) *cdn.URLRewriteAction { + return &cdn.URLRewriteAction{ + Name: cdn.NameURLRewrite, + Parameters: &cdn.URLRewriteActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRewriteActionParameters"), + SourcePattern: utils.String(ura["source_pattern"].(string)), + Destination: utils.String(ura["destination"].(string)), + PreserveUnmatchedPath: utils.Bool(ura["preserve_unmatched_path"].(bool)), + }, + } +} + +func FlattenArmCdnEndpointActionURLRewrite(ura *cdn.URLRewriteAction) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := ura.Parameters; params != nil { + res["source_pattern"] = *params.SourcePattern + res["destination"] = *params.Destination + + if params.PreserveUnmatchedPath != nil { + res["preserve_unmatched_path"] = *params.PreserveUnmatchedPath + } else { + res["preserve_unmatched_path"] = true + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 177df70b86df..748cd101c51d 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -19,7 +19,7 @@ func EndpointDeliveryRule() *schema.Schema { "name": { Type: schema.TypeString, Required: true, - ValidateFunc: validate.CdnEndpointDeliveryPolicyRuleName(), + ValidateFunc: validate.EndpointDeliveryPolicyRuleName(), }, "order": { @@ -67,6 +67,13 @@ func EndpointDeliveryRule() *schema.Schema { MaxItems: 1, Elem: deliveryruleactions.URLRedirect(), }, + + "url_rewrite_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleactions.URLRewrite(), + }, }, }, } @@ -135,6 +142,10 @@ func expandDeliveryRuleActions(rule map[string]interface{}) ([]cdn.BasicDelivery actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura[0].(map[string]interface{}))) } + if ura := rule["url_rewrite_action"].([]interface{}); len(ura) > 0 { + actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionURLRewrite(ura[0].(map[string]interface{}))) + } + return actions, nil } @@ -188,6 +199,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin res["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} continue } + + if action, isURLRewriteAction := basicDeliveryRuleAction.AsURLRewriteAction(); isURLRewriteAction { + res["url_rewrite_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionURLRewrite(action)} + continue + } } } From d0989bfe9adf3ff20a63a4d3e1a7d10ef83f478e Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 15 Mar 2020 13:55:14 +0100 Subject: [PATCH 59/92] refactor/shorten ExpandArmCdnEndpointConditionRequestScheme function --- .../cdn/deliveryruleconditions/request_scheme.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go index 81954c1f7437..aa749b14067c 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go @@ -40,23 +40,19 @@ func RequestScheme() *schema.Resource { func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ Name: cdn.NameRequestScheme, + Parameters: &cdn.RequestSchemeMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), + NegateCondition: utils.Bool(rsc["negate_condition"].(bool)), + }, } matchValues := []string{rsc["match_value"].(string)} - params := cdn.RequestSchemeMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), - MatchValues: &matchValues, - NegateCondition: utils.Bool(rsc["negate_condition"].(bool)), - } + requestSchemeCondition.Parameters.MatchValues = &matchValues if operator := rsc["operator"]; operator.(string) != "" { - params.Operator = utils.String(operator.(string)) + requestSchemeCondition.Parameters.Operator = utils.String(operator.(string)) } - params.NegateCondition = utils.Bool(rsc["negate_condition"].(bool)) - - requestSchemeCondition.Parameters = ¶ms - return &requestSchemeCondition } From 7b77d6beac657004753ecf06d5da54a351d2b0be Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 15 Mar 2020 20:21:27 +0100 Subject: [PATCH 60/92] add cookies condition --- .../cdn/deliveryruleconditions/cookies.go | 109 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 21 ++++ 2 files changed, 130 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/cookies.go diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go new file mode 100644 index 000000000000..79fb6dfe70ce --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go @@ -0,0 +1,109 @@ +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 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_value": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, + + "transforms": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, + }, + } +} + +func ExpandArmCdnEndpointConditionCookies(cc map[string]interface{}) *cdn.DeliveryRuleCookiesCondition { + cookiesCondition := cdn.DeliveryRuleCookiesCondition{ + Name: cdn.NameCookies, + Parameters: &cdn.CookiesMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCookiesConditionParameters"), + Selector: utils.String(cc["selector"].(string)), + Operator: cdn.CookiesOperator(cc["operator"].(string)), + NegateCondition: utils.Bool(cc["negate_condition"].(bool)), + }, + } + + matchValues := []string{cc["match_value"].(string)} + cookiesCondition.Parameters.MatchValues = &matchValues + + if transform := cc["transforms"].(string); transform != "" { + transforms := []cdn.Transform{cdn.Transform(transform)} + cookiesCondition.Parameters.Transforms = &transforms + } + + return &cookiesCondition +} + +func FlattenArmCdnEndpointConditionCookies(cc *cdn.DeliveryRuleCookiesCondition) 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"] = params.Operator + + if params.NegateCondition != nil { + res["negate_condition"] = *params.NegateCondition + } + + if params.MatchValues != nil && len(*params.MatchValues) > 0 { + res["match_value"] = (*params.MatchValues)[0] + } + + if params.Transforms != nil && len(*params.Transforms) > 0 { + 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 748cd101c51d..8911c67a8d7a 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -28,6 +28,12 @@ func EndpointDeliveryRule() *schema.Schema { ValidateFunc: validation.IntAtLeast(1), }, + "cookies_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.Cookies(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -100,6 +106,12 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDeliveryRuleCondition { conditions := make([]cdn.BasicDeliveryRuleCondition, 0) + if ccs := rule["cookies_condition"].([]interface{}); len(ccs) > 0 { + for _, cc := range ccs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionCookies(cc.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -166,6 +178,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin if deliveryRule.Conditions != nil { for _, basicDeliveryRuleCondition := range *deliveryRule.Conditions { + if condition, isCookiesCondition := basicDeliveryRuleCondition.AsDeliveryRuleCookiesCondition(); isCookiesCondition { + if _, ok := res["cookies_condition"]; !ok { + res["cookies_condition"] = []map[string]interface{}{} + } + + res["cookies_condition"] = append(res["cookies_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionCookies(condition)) + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From 4371be87ee79bdaaa8f5c49dfad3a9a966098df0 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 15 Mar 2020 21:12:08 +0100 Subject: [PATCH 61/92] add HTTP version condition --- .../deliveryruleconditions/http_version.go | 76 +++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 21 +++++ 2 files changed, 97 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/http_version.go 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..4c821e5d354e --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/http_version.go @@ -0,0 +1,76 @@ +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 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(hvc map[string]interface{}) *cdn.DeliveryRuleHTTPVersionCondition { + return &cdn.DeliveryRuleHTTPVersionCondition{ + Name: cdn.NameHTTPVersion, + Parameters: &cdn.HTTPVersionMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHttpVersionConditionParameters"), + Operator: utils.String(hvc["operator"].(string)), + NegateCondition: utils.Bool(hvc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(hvc["match_values"].(*schema.Set).List()), + }, + } +} + +func FlattenArmCdnEndpointConditionHTTPVersion(hvc *cdn.DeliveryRuleHTTPVersionCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := hvc.Parameters; params != nil { + if params.Operator != nil { + res["operator"] = *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)) + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 8911c67a8d7a..99377408ee74 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -34,6 +34,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.Cookies(), }, + "http_version_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.HTTPVersion(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -112,6 +118,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if hvcs := rule["http_version_condition"].([]interface{}); len(hvcs) > 0 { + for _, hvc := range hvcs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionHTTPVersion(hvc.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -187,6 +199,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isHTTPVersionCondition := basicDeliveryRuleCondition.AsDeliveryRuleHTTPVersionCondition(); isHTTPVersionCondition { + if _, ok := res["http_version_condition"]; !ok { + res["http_version_condition"] = []map[string]interface{}{} + } + + res["http_version_condition"] = append(res["http_version_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionHTTPVersion(condition)) + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From ff613b43e45e3a9fbd3cdbbb3d73cffca337cedb Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 15 Mar 2020 21:24:34 +0100 Subject: [PATCH 62/92] allow multiple values for cookies condition --- .../cdn/deliveryruleconditions/cookies.go | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go index 79fb6dfe70ce..324ed129f5ed 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go @@ -38,10 +38,14 @@ func Cookies() *schema.Resource { Default: false, }, - "match_value": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotWhiteSpace, + "match_values": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotWhiteSpace, + }, }, "transforms": { @@ -64,12 +68,10 @@ func ExpandArmCdnEndpointConditionCookies(cc map[string]interface{}) *cdn.Delive Selector: utils.String(cc["selector"].(string)), Operator: cdn.CookiesOperator(cc["operator"].(string)), NegateCondition: utils.Bool(cc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(cc["match_values"].(*schema.Set).List()), }, } - matchValues := []string{cc["match_value"].(string)} - cookiesCondition.Parameters.MatchValues = &matchValues - if transform := cc["transforms"].(string); transform != "" { transforms := []cdn.Transform{cdn.Transform(transform)} cookiesCondition.Parameters.Transforms = &transforms @@ -92,8 +94,8 @@ func FlattenArmCdnEndpointConditionCookies(cc *cdn.DeliveryRuleCookiesCondition) res["negate_condition"] = *params.NegateCondition } - if params.MatchValues != nil && len(*params.MatchValues) > 0 { - res["match_value"] = (*params.MatchValues)[0] + if params.MatchValues != nil { + res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) } if params.Transforms != nil && len(*params.Transforms) > 0 { From ff83fb5d066c44722457af7fe7d0120636a912d0 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 15 Mar 2020 21:31:00 +0100 Subject: [PATCH 63/92] allow multiple values for request scheme --- .../deliveryruleconditions/request_scheme.go | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go index aa749b14067c..0ec91021621b 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go @@ -25,13 +25,17 @@ func RequestScheme() *schema.Resource { Default: false, }, - "match_value": { - Type: schema.TypeString, + "match_values": { + Type: schema.TypeSet, Required: true, - ValidateFunc: validation.StringInSlice([]string{ - "HTTP", - "HTTPS", - }, false), + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + "HTTP", + "HTTPS", + }, false), + }, }, }, } @@ -43,12 +47,10 @@ func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn Parameters: &cdn.RequestSchemeMatchConditionParameters{ OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), NegateCondition: utils.Bool(rsc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(rsc["match_values"].(*schema.Set).List()), }, } - matchValues := []string{rsc["match_value"].(string)} - requestSchemeCondition.Parameters.MatchValues = &matchValues - if operator := rsc["operator"]; operator.(string) != "" { requestSchemeCondition.Parameters.Operator = utils.String(operator.(string)) } @@ -68,8 +70,8 @@ func FlattenArmCdnEndpointConditionRequestScheme(condition *cdn.DeliveryRuleRequ res["negate_condition"] = *params.NegateCondition } - if params.MatchValues != nil && len(*params.MatchValues) > 0 { - res["match_value"] = (*params.MatchValues)[0] + if params.MatchValues != nil { + res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) } } From fc439175c656498fc64aab0155abc2a8b916a1d9 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 15 Mar 2020 21:42:43 +0100 Subject: [PATCH 64/92] add device condition --- .../cdn/deliveryruleconditions/device.go | 74 +++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 16 ++++ 2 files changed, 90 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/device.go diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/device.go b/azurerm/internal/services/cdn/deliveryruleconditions/device.go new file mode 100644 index 000000000000..6d6c5c7f4584 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/device.go @@ -0,0 +1,74 @@ +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 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(dc map[string]interface{}) *cdn.DeliveryRuleIsDeviceCondition { + return &cdn.DeliveryRuleIsDeviceCondition{ + Name: cdn.NameHTTPVersion, + Parameters: &cdn.IsDeviceMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleIsDeviceConditionParameters"), + Operator: utils.String(dc["operator"].(string)), + NegateCondition: utils.Bool(dc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(dc["match_values"].(*schema.Set).List()), + }, + } +} + +func FlattenArmCdnEndpointConditionDevice(dc *cdn.DeliveryRuleIsDeviceCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := dc.Parameters; params != nil { + if params.Operator != nil { + res["operator"] = *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)) + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 99377408ee74..57d4180a7fa1 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -40,6 +40,13 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.HTTPVersion(), }, + "device_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleconditions.Device(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -124,6 +131,10 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if rsc := rule["device_condition"].([]interface{}); len(rsc) > 0 { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionDevice(rsc[0].(map[string]interface{}))) + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -208,6 +219,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isDeviceCondition := basicDeliveryRuleCondition.AsDeliveryRuleIsDeviceCondition(); isDeviceCondition { + res["device_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionDevice(condition)} + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From 6a3798dbe5c2213aa94ecdf6207956d454ee3ae5 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 15 Mar 2020 22:07:32 +0100 Subject: [PATCH 65/92] allow transforms to be a list instead of single value --- .../cdn/deliveryruleconditions/cookies.go | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go index 324ed129f5ed..a6f213125ba8 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go @@ -49,12 +49,15 @@ func Cookies() *schema.Resource { }, "transforms": { - Type: schema.TypeString, + Type: schema.TypeList, Optional: true, - ValidateFunc: validation.StringInSlice([]string{ - string(cdn.Lowercase), - string(cdn.Uppercase), - }, false), + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice([]string{ + string(cdn.Lowercase), + string(cdn.Uppercase), + }, false), + }, }, }, } @@ -72,8 +75,11 @@ func ExpandArmCdnEndpointConditionCookies(cc map[string]interface{}) *cdn.Delive }, } - if transform := cc["transforms"].(string); transform != "" { - transforms := []cdn.Transform{cdn.Transform(transform)} + if rawTransforms := cc["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 } @@ -98,7 +104,7 @@ func FlattenArmCdnEndpointConditionCookies(cc *cdn.DeliveryRuleCookiesCondition) res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) } - if params.Transforms != nil && len(*params.Transforms) > 0 { + if params.Transforms != nil { transforms := make([]string, 0) for _, transform := range *params.Transforms { transforms = append(transforms, string(transform)) From 8e07d5681fb4752812df8a3e96743d5174d94cc7 Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 16 Mar 2020 07:20:34 +0100 Subject: [PATCH 66/92] add post arg condition --- .../cdn/deliveryruleconditions/post_arg.go | 117 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 21 ++++ 2 files changed, 138 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go 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..210e51c742a4 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go @@ -0,0 +1,117 @@ +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 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(pac map[string]interface{}) *cdn.DeliveryRulePostArgsCondition { + cookiesCondition := cdn.DeliveryRulePostArgsCondition{ + Name: cdn.NameCookies, + Parameters: &cdn.PostArgsMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRulePostArgsConditionParameters"), + Selector: utils.String(pac["selector"].(string)), + Operator: cdn.PostArgsOperator(pac["operator"].(string)), + NegateCondition: utils.Bool(pac["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(pac["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := pac["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 + } + + return &cookiesCondition +} + +func FlattenArmCdnEndpointConditionPostArg(pac *cdn.DeliveryRulePostArgsCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := pac.Parameters; params != nil { + if params.Selector != nil { + res["selector"] = *params.Selector + } + + res["operator"] = 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 57d4180a7fa1..08b97f70e193 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -47,6 +47,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.Device(), }, + "post_arg_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.PostArg(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -135,6 +141,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionDevice(rsc[0].(map[string]interface{}))) } + if pacs := rule["post_arg_condition"].([]interface{}); len(pacs) > 0 { + for _, pac := range pacs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionPostArg(pac.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -224,6 +236,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isPostArgCondition := basicDeliveryRuleCondition.AsDeliveryRulePostArgsCondition(); isPostArgCondition { + if _, ok := res["post_arg_condition"]; !ok { + res["post_arg_condition"] = []map[string]interface{}{} + } + + res["post_arg_condition"] = append(res["post_arg_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionPostArg(condition)) + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From b68da8692252a57440b4ef8f112e44c083bc071d Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 16 Mar 2020 07:24:13 +0100 Subject: [PATCH 67/92] convert operator to string --- azurerm/internal/services/cdn/deliveryruleconditions/cookies.go | 2 +- .../internal/services/cdn/deliveryruleconditions/post_arg.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go index a6f213125ba8..36b25827d512 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go @@ -94,7 +94,7 @@ func FlattenArmCdnEndpointConditionCookies(cc *cdn.DeliveryRuleCookiesCondition) res["selector"] = *params.Selector } - res["operator"] = params.Operator + res["operator"] = string(params.Operator) if params.NegateCondition != nil { res["negate_condition"] = *params.NegateCondition diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go b/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go index 210e51c742a4..fe6d903ab79b 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go @@ -94,7 +94,7 @@ func FlattenArmCdnEndpointConditionPostArg(pac *cdn.DeliveryRulePostArgsConditio res["selector"] = *params.Selector } - res["operator"] = params.Operator + res["operator"] = string(params.Operator) if params.NegateCondition != nil { res["negate_condition"] = *params.NegateCondition From 6374f986a5ca3a372d2a4483727cd8d6dc53a8f7 Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 16 Mar 2020 07:33:26 +0100 Subject: [PATCH 68/92] add query string condition --- .../deliveryruleconditions/query_string.go | 106 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 21 ++++ 2 files changed, 127 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/query_string.go 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..3e00af164d59 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go @@ -0,0 +1,106 @@ +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 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(qsc map[string]interface{}) *cdn.DeliveryRuleQueryStringCondition { + cookiesCondition := cdn.DeliveryRuleQueryStringCondition{ + Name: cdn.NameQueryString, + Parameters: &cdn.QueryStringMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleQueryStringConditionParameters"), + Operator: cdn.QueryStringOperator(qsc["operator"].(string)), + NegateCondition: utils.Bool(qsc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(qsc["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := qsc["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 + } + + return &cookiesCondition +} + +func FlattenArmCdnEndpointConditionQueryString(qsc *cdn.DeliveryRuleQueryStringCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := qsc.Parameters; params != nil { + 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 08b97f70e193..6f7eed251846 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -53,6 +53,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.PostArg(), }, + "query_string_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.QueryString(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -147,6 +153,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if qscs := rule["query_string_condition"].([]interface{}); len(qscs) > 0 { + for _, qsc := range qscs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionQueryString(qsc.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -245,6 +257,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isQueryStringCondition := basicDeliveryRuleCondition.AsDeliveryRuleQueryStringCondition(); isQueryStringCondition { + if _, ok := res["query_string_condition"]; !ok { + res["query_string_condition"] = []map[string]interface{}{} + } + + res["query_string_condition"] = append(res["query_string_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionQueryString(condition)) + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From c0ace33f3c24e36fa79a7d136ded281fd12e1f37 Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 16 Mar 2020 07:55:35 +0100 Subject: [PATCH 69/92] add remote address condition --- .../deliveryruleconditions/query_string.go | 6 +- .../deliveryruleconditions/remote_address.go | 72 +++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 21 ++++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/remote_address.go diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go b/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go index 3e00af164d59..fccb7dc85a2b 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go @@ -58,7 +58,7 @@ func QueryString() *schema.Resource { } func ExpandArmCdnEndpointConditionQueryString(qsc map[string]interface{}) *cdn.DeliveryRuleQueryStringCondition { - cookiesCondition := cdn.DeliveryRuleQueryStringCondition{ + queryStringCondition := cdn.DeliveryRuleQueryStringCondition{ Name: cdn.NameQueryString, Parameters: &cdn.QueryStringMatchConditionParameters{ OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleQueryStringConditionParameters"), @@ -73,10 +73,10 @@ func ExpandArmCdnEndpointConditionQueryString(qsc map[string]interface{}) *cdn.D for _, t := range rawTransforms { transforms = append(transforms, cdn.Transform(t.(string))) } - cookiesCondition.Parameters.Transforms = &transforms + queryStringCondition.Parameters.Transforms = &transforms } - return &cookiesCondition + return &queryStringCondition } func FlattenArmCdnEndpointConditionQueryString(qsc *cdn.DeliveryRuleQueryStringCondition) map[string]interface{} { 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..7b5277a21f9f --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/remote_address.go @@ -0,0 +1,72 @@ +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 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(qsc map[string]interface{}) *cdn.DeliveryRuleRemoteAddressCondition { + remoteAddressCondition := cdn.DeliveryRuleRemoteAddressCondition{ + Name: cdn.NameRemoteAddress, + Parameters: &cdn.RemoteAddressMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRemoteAddressConditionParameters"), + Operator: cdn.RemoteAddressOperator(qsc["operator"].(string)), + NegateCondition: utils.Bool(qsc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(qsc["match_values"].(*schema.Set).List()), + }, + } + + return &remoteAddressCondition +} + +func FlattenArmCdnEndpointConditionRemoteAddress(qsc *cdn.DeliveryRuleRemoteAddressCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := qsc.Parameters; params != nil { + 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)) + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 6f7eed251846..4fbcb8b3423e 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -59,6 +59,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.QueryString(), }, + "remote_address_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RemoteAddress(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -159,6 +165,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if racs := rule["remote_address_condition"].([]interface{}); len(racs) > 0 { + for _, rac := range racs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRemoteAddress(rac.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -266,6 +278,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isRemoteAddressCondition := basicDeliveryRuleCondition.AsDeliveryRuleRemoteAddressCondition(); isRemoteAddressCondition { + if _, ok := res["remote_address_condition"]; !ok { + res["remote_address_condition"] = []map[string]interface{}{} + } + + res["remote_address_condition"] = append(res["remote_address_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRemoteAddress(condition)) + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From a978dccd95d5a4ab7ec77d37a688a69a1b8a6266 Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 16 Mar 2020 08:21:37 +0100 Subject: [PATCH 70/92] add request body condition --- .../deliveryruleconditions/request_body.go | 106 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 21 ++++ 2 files changed, 127 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/request_body.go 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..f06dde1a64cc --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_body.go @@ -0,0 +1,106 @@ +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 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(rbc map[string]interface{}) *cdn.DeliveryRuleRequestBodyCondition { + queryStringCondition := cdn.DeliveryRuleRequestBodyCondition{ + Name: cdn.NameRequestBody, + Parameters: &cdn.RequestBodyMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestBodyConditionParameters"), + Operator: cdn.RequestBodyOperator(rbc["operator"].(string)), + NegateCondition: utils.Bool(rbc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(rbc["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := rbc["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 + } + + return &queryStringCondition +} + +func FlattenArmCdnEndpointConditionRequestBody(rbc *cdn.DeliveryRuleRequestBodyCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := rbc.Parameters; params != nil { + 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 4fbcb8b3423e..55552872ef6f 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -65,6 +65,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.RemoteAddress(), }, + "request_body_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RequestBody(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -171,6 +177,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if rbcs := rule["request_body_condition"].([]interface{}); len(rbcs) > 0 { + for _, rbc := range rbcs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestBody(rbc.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -287,6 +299,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isRequestBodyCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestBodyCondition(); isRequestBodyCondition { + if _, ok := res["request_body_condition"]; !ok { + res["request_body_condition"] = []map[string]interface{}{} + } + + res["request_body_condition"] = append(res["request_body_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestBody(condition)) + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From 5d5cbbd12ecb8a945a780e755427dda9b17f05cd Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 17 Mar 2020 06:54:22 +0100 Subject: [PATCH 71/92] add request header condition --- .../deliveryruleconditions/request_header.go | 117 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 12 ++ 2 files changed, 129 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/request_header.go 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..1adf2fd8e34e --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_header.go @@ -0,0 +1,117 @@ +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(cc map[string]interface{}) *cdn.DeliveryRuleRequestHeaderCondition { + requestHeaderCondition := cdn.DeliveryRuleRequestHeaderCondition{ + Name: cdn.NameRequestHeader, + Parameters: &cdn.RequestHeaderMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestHeaderConditionParameters"), + Selector: utils.String(cc["selector"].(string)), + Operator: cdn.RequestHeaderOperator(cc["operator"].(string)), + NegateCondition: utils.Bool(cc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(cc["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := cc["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 + } + + return &requestHeaderCondition +} + +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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 55552872ef6f..fb703e8ed7a4 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -71,6 +71,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.RequestBody(), }, + "request_header_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RequestHeader(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -183,6 +189,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if rhcs := rule["request_header_condition"].([]interface{}); len(rhcs) > 0 { + for _, rhc := range rhcs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestHeader(rhc.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } From 50c2c08baa111a2d5077fd17e157969ae9198d7a Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 17 Mar 2020 16:39:22 +0100 Subject: [PATCH 72/92] add request method condition --- .../deliveryruleconditions/request_method.go | 78 +++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 16 ++++ 2 files changed, 94 insertions(+) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/request_method.go 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..3cc1941a3053 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go @@ -0,0 +1,78 @@ +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 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(hvc map[string]interface{}) *cdn.DeliveryRuleRequestMethodCondition { + return &cdn.DeliveryRuleRequestMethodCondition{ + Name: cdn.NameRequestMethod, + Parameters: &cdn.RequestMethodMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestMethodConditionParameters"), + Operator: utils.String(hvc["operator"].(string)), + NegateCondition: utils.Bool(hvc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(hvc["match_values"].(*schema.Set).List()), + }, + } +} + +func FlattenArmCdnEndpointConditionRequestMethod(hvc *cdn.DeliveryRuleRequestMethodCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := hvc.Parameters; params != nil { + if params.Operator != nil { + res["operator"] = *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)) + } + } + + return res +} diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index fb703e8ed7a4..4098ea11ece5 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -77,6 +77,13 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.RequestHeader(), }, + "request_method_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: deliveryruleconditions.RequestMethod(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -195,6 +202,10 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if rsc := rule["request_method_condition"].([]interface{}); len(rsc) > 0 { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestMethod(rsc[0].(map[string]interface{}))) + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -320,6 +331,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isRequestMethodCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestMethodCondition(); isRequestMethodCondition { + res["request_method_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestMethod(condition)} + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From 683899b8fbe96dcc94e85cc782215801e4678aec Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 17 Mar 2020 16:57:32 +0100 Subject: [PATCH 73/92] add request uri condition --- .../deliveryruleconditions/request_method.go | 12 +- .../cdn/deliveryruleconditions/request_uri.go | 106 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 21 ++++ 3 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/request_uri.go diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go index 3cc1941a3053..ceebb8bae824 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go @@ -45,22 +45,22 @@ func RequestMethod() *schema.Resource { } } -func ExpandArmCdnEndpointConditionRequestMethod(hvc map[string]interface{}) *cdn.DeliveryRuleRequestMethodCondition { +func ExpandArmCdnEndpointConditionRequestMethod(rmc map[string]interface{}) *cdn.DeliveryRuleRequestMethodCondition { return &cdn.DeliveryRuleRequestMethodCondition{ Name: cdn.NameRequestMethod, Parameters: &cdn.RequestMethodMatchConditionParameters{ OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestMethodConditionParameters"), - Operator: utils.String(hvc["operator"].(string)), - NegateCondition: utils.Bool(hvc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(hvc["match_values"].(*schema.Set).List()), + Operator: utils.String(rmc["operator"].(string)), + NegateCondition: utils.Bool(rmc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(rmc["match_values"].(*schema.Set).List()), }, } } -func FlattenArmCdnEndpointConditionRequestMethod(hvc *cdn.DeliveryRuleRequestMethodCondition) map[string]interface{} { +func FlattenArmCdnEndpointConditionRequestMethod(rmc *cdn.DeliveryRuleRequestMethodCondition) map[string]interface{} { res := make(map[string]interface{}, 1) - if params := hvc.Parameters; params != nil { + if params := rmc.Parameters; params != nil { if params.Operator != nil { res["operator"] = *params.Operator } 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..d647403011c0 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_uri.go @@ -0,0 +1,106 @@ +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 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(ruc map[string]interface{}) *cdn.DeliveryRuleRequestURICondition { + requestURICondition := cdn.DeliveryRuleRequestURICondition{ + Name: cdn.NameRequestURI, + Parameters: &cdn.RequestURIMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestUriConditionParameters"), + Operator: cdn.RequestURIOperator(ruc["operator"].(string)), + NegateCondition: utils.Bool(ruc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(ruc["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := ruc["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 + } + + return &requestURICondition +} + +func FlattenArmCdnEndpointConditionRequestURI(ruc *cdn.DeliveryRuleRequestURICondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := ruc.Parameters; params != nil { + 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 4098ea11ece5..6a13f0e65049 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -84,6 +84,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.RequestMethod(), }, + "request_uri_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.RequestURI(), + }, + "request_scheme_condition": { Type: schema.TypeList, Optional: true, @@ -206,6 +212,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestMethod(rsc[0].(map[string]interface{}))) } + if rucs := rule["request_uri_condition"].([]interface{}); len(rucs) > 0 { + for _, ruc := range rucs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestURI(ruc.(map[string]interface{}))) + } + } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) } @@ -336,6 +348,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isRequestURICondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestURICondition(); isRequestURICondition { + if _, ok := res["request_uri_condition"]; !ok { + res["request_uri_condition"] = []map[string]interface{}{} + } + + res["request_uri_condition"] = append(res["request_uri_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestURI(condition)) + continue + } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} continue From 5fbfcea53d14525a2a21d450e4f92a8f5f73d0c4 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 17 Mar 2020 17:14:31 +0100 Subject: [PATCH 74/92] add url file extension condition --- .../url_file_extension.go | 106 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 35 ++++-- 2 files changed, 134 insertions(+), 7 deletions(-) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/url_file_extension.go 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..830073ed5f54 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_extension.go @@ -0,0 +1,106 @@ +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 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(ufec map[string]interface{}) *cdn.DeliveryRuleURLFileExtensionCondition { + requestURICondition := cdn.DeliveryRuleURLFileExtensionCondition{ + Name: cdn.NameURLFileExtension, + Parameters: &cdn.URLFileExtensionMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlFileExtensionMatchConditionParameters"), + Operator: cdn.URLFileExtensionOperator(ufec["operator"].(string)), + NegateCondition: utils.Bool(ufec["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(ufec["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := ufec["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 + } + + return &requestURICondition +} + +func FlattenArmCdnEndpointConditionURLFileExtension(ufec *cdn.DeliveryRuleURLFileExtensionCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := ufec.Parameters; params != nil { + 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 6a13f0e65049..d53cdcfcd38f 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -84,17 +84,23 @@ func EndpointDeliveryRule() *schema.Schema { 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(), }, - "request_scheme_condition": { + "url_file_extension_condition": { Type: schema.TypeList, Optional: true, - MaxItems: 1, - Elem: deliveryruleconditions.RequestScheme(), + Elem: deliveryruleconditions.URLFileExtension(), }, "cache_expiration_action": { @@ -212,14 +218,20 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestMethod(rsc[0].(map[string]interface{}))) } + if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) + } + if rucs := rule["request_uri_condition"].([]interface{}); len(rucs) > 0 { for _, ruc := range rucs { conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestURI(ruc.(map[string]interface{}))) } } - if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) + if ufecs := rule["url_file_extension_condition"].([]interface{}); len(ufecs) > 0 { + for _, ufec := range ufecs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionURLFileExtension(ufec.(map[string]interface{}))) + } } return conditions @@ -348,6 +360,11 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { + res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} + continue + } + if condition, isRequestURICondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestURICondition(); isRequestURICondition { if _, ok := res["request_uri_condition"]; !ok { res["request_uri_condition"] = []map[string]interface{}{} @@ -357,8 +374,12 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } - if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { - res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} + if condition, isRequestURICondition := basicDeliveryRuleCondition.AsDeliveryRuleURLFileExtensionCondition(); isRequestURICondition { + if _, ok := res["url_file_extension_condition"]; !ok { + res["url_file_extension_condition"] = []map[string]interface{}{} + } + + res["url_file_extension_condition"] = append(res["url_file_extension_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileExtension(condition)) continue } } From af905f96674bd76f3d776ec235a3d4b1ff09168f Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 17 Mar 2020 17:28:40 +0100 Subject: [PATCH 75/92] add url file name condition --- .../deliveryruleconditions/url_file_name.go | 106 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 23 +++- 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/url_file_name.go 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..78b3d1d43610 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_name.go @@ -0,0 +1,106 @@ +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 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(ufnc map[string]interface{}) *cdn.DeliveryRuleURLFileNameCondition { + requestURICondition := cdn.DeliveryRuleURLFileNameCondition{ + Name: cdn.NameURLFileName, + Parameters: &cdn.URLFileNameMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlFilenameConditionParameters"), + Operator: cdn.URLFileNameOperator(ufnc["operator"].(string)), + NegateCondition: utils.Bool(ufnc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(ufnc["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := ufnc["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 + } + + return &requestURICondition +} + +func FlattenArmCdnEndpointConditionURLFileName(ufnc *cdn.DeliveryRuleURLFileNameCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := ufnc.Parameters; params != nil { + 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index d53cdcfcd38f..86b7a1842fb8 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -103,6 +103,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.URLFileExtension(), }, + "url_file_name_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.URLFileName(), + }, + "cache_expiration_action": { Type: schema.TypeList, Optional: true, @@ -234,6 +240,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if ufncs := rule["url_file_name_condition"].([]interface{}); len(ufncs) > 0 { + for _, ufnc := range ufncs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionURLFileName(ufnc.(map[string]interface{}))) + } + } + return conditions } @@ -374,7 +386,7 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin continue } - if condition, isRequestURICondition := basicDeliveryRuleCondition.AsDeliveryRuleURLFileExtensionCondition(); isRequestURICondition { + if condition, isURLFileExtensionCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLFileExtensionCondition(); isURLFileExtensionCondition { if _, ok := res["url_file_extension_condition"]; !ok { res["url_file_extension_condition"] = []map[string]interface{}{} } @@ -382,6 +394,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin res["url_file_extension_condition"] = append(res["url_file_extension_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileExtension(condition)) continue } + + if condition, isURLFileNameExtension := basicDeliveryRuleCondition.AsDeliveryRuleURLFileNameCondition(); isURLFileNameExtension { + if _, ok := res["url_file_name_condition"]; !ok { + res["url_file_name_condition"] = []map[string]interface{}{} + } + + res["url_file_name_condition"] = append(res["url_file_name_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileName(condition)) + continue + } } } From 4ba44097513d30377adf07933f899a8050d5be37 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 17 Mar 2020 17:45:40 +0100 Subject: [PATCH 76/92] ad url path condition --- azurerm/helpers/validate/cdn.go | 4 +- azurerm/helpers/validate/cdn_test.go | 2 +- .../cdn/deliveryruleconditions/url_path.go | 106 ++++++++++++++++++ .../services/cdn/endpoint_delivery_rule.go | 23 +++- 4 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 azurerm/internal/services/cdn/deliveryruleconditions/url_path.go diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index 878a036aee50..be1bfcd5d73f 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -8,10 +8,10 @@ import ( "strings" ) -func EndpointDeliveryPolicyRuleName() schema.SchemaValidateFunc { +func EndpointDeliveryRuleName() schema.SchemaValidateFunc { return validation.StringMatch( regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$"), - "The Delivery Policy Rule Name must start with a letter any may only contain letters and numbers.", + "The Delivery Rule Name must start with a letter any may only contain letters and numbers.", ) } diff --git a/azurerm/helpers/validate/cdn_test.go b/azurerm/helpers/validate/cdn_test.go index cf7035318466..357f032d64d9 100644 --- a/azurerm/helpers/validate/cdn_test.go +++ b/azurerm/helpers/validate/cdn_test.go @@ -45,7 +45,7 @@ func TestCdnEndpointDeliveryPolicyRuleName(t *testing.T) { for _, tc := range cases { t.Run(tc.Name, func(t *testing.T) { - _, errors := EndpointDeliveryPolicyRuleName()(tc.Name, "name") + _, errors := EndpointDeliveryRuleName()(tc.Name, "name") hasErrors := len(errors) > 0 if !hasErrors && tc.ShouldError { 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..69d6da966368 --- /dev/null +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_path.go @@ -0,0 +1,106 @@ +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 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(upc map[string]interface{}) *cdn.DeliveryRuleURLPathCondition { + requestURICondition := cdn.DeliveryRuleURLPathCondition{ + Name: cdn.NameURLPath, + Parameters: &cdn.URLPathMatchConditionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlPathMatchConditionParameters"), + Operator: cdn.URLPathOperator(upc["operator"].(string)), + NegateCondition: utils.Bool(upc["negate_condition"].(bool)), + MatchValues: utils.ExpandStringSlice(upc["match_values"].(*schema.Set).List()), + }, + } + + if rawTransforms := upc["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 + } + + return &requestURICondition +} + +func FlattenArmCdnEndpointConditionURLPath(upc *cdn.DeliveryRuleURLPathCondition) map[string]interface{} { + res := make(map[string]interface{}, 1) + + if params := upc.Parameters; params != nil { + 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/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 86b7a1842fb8..a27a8962c852 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -19,7 +19,7 @@ func EndpointDeliveryRule() *schema.Schema { "name": { Type: schema.TypeString, Required: true, - ValidateFunc: validate.EndpointDeliveryPolicyRuleName(), + ValidateFunc: validate.EndpointDeliveryRuleName(), }, "order": { @@ -109,6 +109,12 @@ func EndpointDeliveryRule() *schema.Schema { Elem: deliveryruleconditions.URLFileName(), }, + "url_path_condition": { + Type: schema.TypeList, + Optional: true, + Elem: deliveryruleconditions.URLPath(), + }, + "cache_expiration_action": { Type: schema.TypeList, Optional: true, @@ -246,6 +252,12 @@ func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDelive } } + if upcs := rule["url_path_condition"].([]interface{}); len(upcs) > 0 { + for _, upc := range upcs { + conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionURLPath(upc.(map[string]interface{}))) + } + } + return conditions } @@ -403,6 +415,15 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin res["url_file_name_condition"] = append(res["url_file_name_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileName(condition)) continue } + + if condition, isURLPathCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLPathCondition(); isURLPathCondition { + if _, ok := res["url_path_condition"]; !ok { + res["url_path_condition"] = []map[string]interface{}{} + } + + res["url_path_condition"] = append(res["url_path_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLPath(condition)) + continue + } } } From 2f629eba2933ec4993af9cc34cfef2948f50ad1f Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 17 Mar 2020 19:40:45 +0100 Subject: [PATCH 77/92] add global delivery rule --- .../services/cdn/endpoint_delivery_rule.go | 220 +++++++++--------- .../cdn/endpoint_global_delivery_rule.go | 86 +++++++ .../services/cdn/resource_arm_cdn_endpoint.go | 37 ++- 3 files changed, 232 insertions(+), 111 deletions(-) create mode 100644 azurerm/internal/services/cdn/endpoint_global_delivery_rule.go diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index a27a8962c852..228ff45864c2 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -318,148 +318,160 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[strin res["order"] = *deliveryRule.Order } - if deliveryRule.Conditions != nil { - for _, basicDeliveryRuleCondition := range *deliveryRule.Conditions { - if condition, isCookiesCondition := basicDeliveryRuleCondition.AsDeliveryRuleCookiesCondition(); isCookiesCondition { - if _, ok := res["cookies_condition"]; !ok { - res["cookies_condition"] = []map[string]interface{}{} - } - - res["cookies_condition"] = append(res["cookies_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionCookies(condition)) - continue - } + flattenDeliveryRuleConditions(deliveryRule.Conditions, &res) - if condition, isHTTPVersionCondition := basicDeliveryRuleCondition.AsDeliveryRuleHTTPVersionCondition(); isHTTPVersionCondition { - if _, ok := res["http_version_condition"]; !ok { - res["http_version_condition"] = []map[string]interface{}{} - } + flattenDeliveryRuleActions(deliveryRule.Actions, &res) - res["http_version_condition"] = append(res["http_version_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionHTTPVersion(condition)) - continue - } + return res +} - if condition, isDeviceCondition := basicDeliveryRuleCondition.AsDeliveryRuleIsDeviceCondition(); isDeviceCondition { - res["device_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionDevice(condition)} - continue - } +func flattenDeliveryRuleActions(actions *[]cdn.BasicDeliveryRuleAction, res *map[string]interface{}) { + if actions == nil { + return + } - if condition, isPostArgCondition := basicDeliveryRuleCondition.AsDeliveryRulePostArgsCondition(); isPostArgCondition { - if _, ok := res["post_arg_condition"]; !ok { - res["post_arg_condition"] = []map[string]interface{}{} - } + for _, basicDeliveryRuleAction := range *actions { + if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { + (*res)["cache_expiration_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheExpiration(action)} + continue + } - res["post_arg_condition"] = append(res["post_arg_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionPostArg(condition)) - continue - } + if action, isCacheKeyQueryStringAction := basicDeliveryRuleAction.AsDeliveryRuleCacheKeyQueryStringAction(); isCacheKeyQueryStringAction { + (*res)["cache_key_query_string_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheKeyQueryString(action)} + continue + } - if condition, isQueryStringCondition := basicDeliveryRuleCondition.AsDeliveryRuleQueryStringCondition(); isQueryStringCondition { - if _, ok := res["query_string_condition"]; !ok { - res["query_string_condition"] = []map[string]interface{}{} - } + if action, isModifyRequestHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleRequestHeaderAction(); isModifyRequestHeaderAction { + (*res)["modify_request_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyRequestHeader(action)} + continue + } - res["query_string_condition"] = append(res["query_string_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionQueryString(condition)) - continue - } + if action, isModifyResponseHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleResponseHeaderAction(); isModifyResponseHeaderAction { + (*res)["modify_response_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyResponseHeader(action)} + continue + } - if condition, isRemoteAddressCondition := basicDeliveryRuleCondition.AsDeliveryRuleRemoteAddressCondition(); isRemoteAddressCondition { - if _, ok := res["remote_address_condition"]; !ok { - res["remote_address_condition"] = []map[string]interface{}{} - } + if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { + (*res)["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} + continue + } - res["remote_address_condition"] = append(res["remote_address_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRemoteAddress(condition)) - continue - } + if action, isURLRewriteAction := basicDeliveryRuleAction.AsURLRewriteAction(); isURLRewriteAction { + (*res)["url_rewrite_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionURLRewrite(action)} + continue + } + } +} - if condition, isRequestBodyCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestBodyCondition(); isRequestBodyCondition { - if _, ok := res["request_body_condition"]; !ok { - res["request_body_condition"] = []map[string]interface{}{} - } +func flattenDeliveryRuleConditions(conditions *[]cdn.BasicDeliveryRuleCondition, res *map[string]interface{}) { + if conditions == nil { + return + } - res["request_body_condition"] = append(res["request_body_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestBody(condition)) - continue + for _, basicDeliveryRuleCondition := range *conditions { + if condition, isCookiesCondition := basicDeliveryRuleCondition.AsDeliveryRuleCookiesCondition(); isCookiesCondition { + if _, ok := (*res)["cookies_condition"]; !ok { + (*res)["cookies_condition"] = []map[string]interface{}{} } - if condition, isRequestMethodCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestMethodCondition(); isRequestMethodCondition { - res["request_method_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestMethod(condition)} - continue - } + (*res)["cookies_condition"] = append((*res)["cookies_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionCookies(condition)) + continue + } - if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { - res["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} - continue + if condition, isHTTPVersionCondition := basicDeliveryRuleCondition.AsDeliveryRuleHTTPVersionCondition(); isHTTPVersionCondition { + if _, ok := (*res)["http_version_condition"]; !ok { + (*res)["http_version_condition"] = []map[string]interface{}{} } - if condition, isRequestURICondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestURICondition(); isRequestURICondition { - if _, ok := res["request_uri_condition"]; !ok { - res["request_uri_condition"] = []map[string]interface{}{} - } + (*res)["http_version_condition"] = append((*res)["http_version_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionHTTPVersion(condition)) + continue + } - res["request_uri_condition"] = append(res["request_uri_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestURI(condition)) - continue + if condition, isDeviceCondition := basicDeliveryRuleCondition.AsDeliveryRuleIsDeviceCondition(); isDeviceCondition { + (*res)["device_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionDevice(condition)} + continue + } + + if condition, isPostArgCondition := basicDeliveryRuleCondition.AsDeliveryRulePostArgsCondition(); isPostArgCondition { + if _, ok := (*res)["post_arg_condition"]; !ok { + (*res)["post_arg_condition"] = []map[string]interface{}{} } - if condition, isURLFileExtensionCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLFileExtensionCondition(); isURLFileExtensionCondition { - if _, ok := res["url_file_extension_condition"]; !ok { - res["url_file_extension_condition"] = []map[string]interface{}{} - } + (*res)["post_arg_condition"] = append((*res)["post_arg_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionPostArg(condition)) + continue + } - res["url_file_extension_condition"] = append(res["url_file_extension_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileExtension(condition)) - continue + if condition, isQueryStringCondition := basicDeliveryRuleCondition.AsDeliveryRuleQueryStringCondition(); isQueryStringCondition { + if _, ok := (*res)["query_string_condition"]; !ok { + (*res)["query_string_condition"] = []map[string]interface{}{} } - if condition, isURLFileNameExtension := basicDeliveryRuleCondition.AsDeliveryRuleURLFileNameCondition(); isURLFileNameExtension { - if _, ok := res["url_file_name_condition"]; !ok { - res["url_file_name_condition"] = []map[string]interface{}{} - } + (*res)["query_string_condition"] = append((*res)["query_string_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionQueryString(condition)) + continue + } - res["url_file_name_condition"] = append(res["url_file_name_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileName(condition)) - continue + if condition, isRemoteAddressCondition := basicDeliveryRuleCondition.AsDeliveryRuleRemoteAddressCondition(); isRemoteAddressCondition { + if _, ok := (*res)["remote_address_condition"]; !ok { + (*res)["remote_address_condition"] = []map[string]interface{}{} } - if condition, isURLPathCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLPathCondition(); isURLPathCondition { - if _, ok := res["url_path_condition"]; !ok { - res["url_path_condition"] = []map[string]interface{}{} - } + (*res)["remote_address_condition"] = append((*res)["remote_address_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRemoteAddress(condition)) + continue + } - res["url_path_condition"] = append(res["url_path_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLPath(condition)) - continue + if condition, isRequestBodyCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestBodyCondition(); isRequestBodyCondition { + if _, ok := (*res)["request_body_condition"]; !ok { + (*res)["request_body_condition"] = []map[string]interface{}{} } + + (*res)["request_body_condition"] = append((*res)["request_body_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestBody(condition)) + continue } - } - if deliveryRule.Actions != nil { - for _, basicDeliveryRuleAction := range *deliveryRule.Actions { - if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { - res["cache_expiration_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheExpiration(action)} - continue - } + if condition, isRequestMethodCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestMethodCondition(); isRequestMethodCondition { + (*res)["request_method_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestMethod(condition)} + continue + } - if action, isCacheKeyQueryStringAction := basicDeliveryRuleAction.AsDeliveryRuleCacheKeyQueryStringAction(); isCacheKeyQueryStringAction { - res["cache_key_query_string_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheKeyQueryString(action)} - continue - } + if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { + (*res)["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} + continue + } - if action, isModifyRequestHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleRequestHeaderAction(); isModifyRequestHeaderAction { - res["modify_request_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyRequestHeader(action)} - continue + if condition, isRequestURICondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestURICondition(); isRequestURICondition { + if _, ok := (*res)["request_uri_condition"]; !ok { + (*res)["request_uri_condition"] = []map[string]interface{}{} } - if action, isModifyResponseHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleResponseHeaderAction(); isModifyResponseHeaderAction { - res["modify_response_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyResponseHeader(action)} - continue + (*res)["request_uri_condition"] = append((*res)["request_uri_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestURI(condition)) + continue + } + + if condition, isURLFileExtensionCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLFileExtensionCondition(); isURLFileExtensionCondition { + if _, ok := (*res)["url_file_extension_condition"]; !ok { + (*res)["url_file_extension_condition"] = []map[string]interface{}{} } - if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { - res["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} - continue + (*res)["url_file_extension_condition"] = append((*res)["url_file_extension_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileExtension(condition)) + continue + } + + if condition, isURLFileNameExtension := basicDeliveryRuleCondition.AsDeliveryRuleURLFileNameCondition(); isURLFileNameExtension { + if _, ok := (*res)["url_file_name_condition"]; !ok { + (*res)["url_file_name_condition"] = []map[string]interface{}{} } - if action, isURLRewriteAction := basicDeliveryRuleAction.AsURLRewriteAction(); isURLRewriteAction { - res["url_rewrite_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionURLRewrite(action)} - continue + (*res)["url_file_name_condition"] = append((*res)["url_file_name_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileName(condition)) + continue + } + + if condition, isURLPathCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLPathCondition(); isURLPathCondition { + if _, ok := (*res)["url_path_condition"]; !ok { + (*res)["url_path_condition"] = []map[string]interface{}{} } + + (*res)["url_path_condition"] = append((*res)["url_path_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLPath(condition)) + continue } } - - return res } 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..b08363cb2b22 --- /dev/null +++ b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go @@ -0,0 +1,86 @@ +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{} { + res := make(map[string]interface{}, 0) + + if deliveryRule == nil { + return res + } + + flattenDeliveryRuleActions(deliveryRule.Actions, &res) + + return res +} diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index db44894802cb..120608142c05 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -197,6 +197,8 @@ func resourceArmCdnEndpoint() *schema.Resource { Computed: true, }, + "global_delivery_rule": EndpointGlobalDeliveryRule(), + "delivery_rule": EndpointDeliveryRule(), "tags": tags.Schema(), @@ -425,7 +427,10 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting `origin`: %+v", err) } - deliveryRules := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) + globalDeliveryRules, deliveryRules := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) + if err := d.Set("global_delivery_rule", globalDeliveryRules); err != nil { + return fmt.Errorf("Error setting `global_delivery_rule`: %+v", err) + } if err := d.Set("delivery_rule", deliveryRules); err != nil { return fmt.Errorf("Error setting `delivery_rule`: %+v", err) } @@ -611,6 +616,15 @@ func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPr Rules: &deliveryRules, } + globalRules := d.Get("global_delivery_rule").([]interface{}) + if len(globalRules) == 1 { + globRule, err := expandArmCdnEndpointGlobalDeliveryRule(globalRules[0].(map[string]interface{})) + if err != nil { + return nil, err + } + deliveryRules = append(deliveryRules, *globRule) + } + rules := d.Get("delivery_rule").([]interface{}) if len(rules) == 0 { return &deliveryPolicy, nil @@ -627,15 +641,24 @@ func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPr return &deliveryPolicy, nil } -func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) []interface{} { +func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) ([]interface{}, []interface{}) { if deliveryPolicy == nil { - return nil + return nil, nil } - deliveryRules := make([]interface{}, len(*deliveryPolicy.Rules)) - for i, rule := range *deliveryPolicy.Rules { - deliveryRules[i] = flattenArmCdnEndpointDeliveryRule(&rule) + globalDeliveryRules := make([]interface{}, 0) + for _, rule := range *deliveryPolicy.Rules { + if *rule.Order == 0 { + globalDeliveryRules = append(globalDeliveryRules, flattenArmCdnEndpointGlobalDeliveryRule(&rule)) + } + } + + deliveryRules := make([]interface{}, 0) + for _, rule := range *deliveryPolicy.Rules { + if *rule.Order != 0 { + deliveryRules = append(deliveryRules, flattenArmCdnEndpointDeliveryRule(&rule)) + } } - return deliveryRules + return globalDeliveryRules, deliveryRules } From ab89626bbfebc64738156ad38920b749eee8e233 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 11:16:36 +0100 Subject: [PATCH 78/92] add documentation for delivery rule and global delivery rule; fix minor bugs --- azurerm/helpers/validate/cdn.go | 2 +- .../cdn/deliveryruleactions/url_redirect.go | 2 +- website/docs/r/cdn_endpoint.html.markdown | 299 +++++++++++++++++- 3 files changed, 299 insertions(+), 4 deletions(-) diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index be1bfcd5d73f..a8751cd12308 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -57,7 +57,7 @@ func RuleActionUrlRedirectQueryString() schema.SchemaValidateFunc { func RuleActionUrlRedirectFragment() schema.SchemaValidateFunc { return validation.StringMatch( regexp.MustCompile("^([^#].*)?$"), - "The Url Redirect Path must start with a slash.", + "The Url Fragment must not start with a hash.", ) } diff --git a/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go b/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go index 3aec171fd9a6..eaa4593f63f0 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go @@ -47,7 +47,7 @@ func URLRedirect() *schema.Resource { "query_string": { Type: schema.TypeString, Optional: true, - ValidateFunc: validate.RuleActionUrlRedirectPath(), + ValidateFunc: validate.RuleActionUrlRedirectQueryString(), }, "fragment": { diff --git a/website/docs/r/cdn_endpoint.html.markdown b/website/docs/r/cdn_endpoint.html.markdown index 6cb8cac80b78..bf57053671fa 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 @@ -47,7 +46,7 @@ resource "azurerm_cdn_endpoint" "example" { } ``` -## Argument Reference +## Arguments Reference The following arguments are supported: @@ -101,6 +100,302 @@ 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. +* `global_delivery_rule` - (Optional) A `global_delivery_rule` block as defined below. + +* `delivery_rule` - (Optional) 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 TODO. + +* `order` - (Required) TODO. + +* `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: From ea4f77f059c2b90a5fc35ac3d3c6c45f599c7e7c Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 11:40:07 +0100 Subject: [PATCH 79/92] adjust documentation --- website/docs/r/cdn_endpoint.html.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/website/docs/r/cdn_endpoint.html.markdown b/website/docs/r/cdn_endpoint.html.markdown index bf57053671fa..411641751a52 100644 --- a/website/docs/r/cdn_endpoint.html.markdown +++ b/website/docs/r/cdn_endpoint.html.markdown @@ -100,9 +100,11 @@ 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. -* `global_delivery_rule` - (Optional) A `global_delivery_rule` block as defined below. +-> **NOTE:** `global_delivery_rule` and `delivery_rule` are currently only available for `Microsoft_Standard` CDN profiles. -* `delivery_rule` - (Optional) A `delivery_rule` blocks as defined below. +* `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. --- From 4ba005f922e6e6aa16033b0fac9f767f565aefcf Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 13:58:09 +0100 Subject: [PATCH 80/92] prevent user from using delivery_rule oder global_delivery_rule in combination with a CDN profile sku other than Microsoft_Standard --- .../services/cdn/resource_arm_cdn_endpoint.go | 74 ++++++++++++++----- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index 120608142c05..8c1cd7a552ac 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -207,9 +207,9 @@ func resourceArmCdnEndpoint() *schema.Resource { } func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Cdn.EndpointsClient - ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) - defer cancel() + endpointsClient := meta.(*clients.Client).Cdn.EndpointsClient + endpointCreateCtx, endpointCreateCancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer endpointCreateCancel() log.Printf("[INFO] preparing arguments for Azure ARM CDN EndPoint creation.") @@ -218,7 +218,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro profileName := d.Get("profile_name").(string) if features.ShouldResourcesBeImported() && d.IsNewResource() { - existing, err := client.Get(ctx, resourceGroup, profileName, name) + existing, err := endpointsClient.Get(endpointCreateCtx, 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) @@ -247,11 +247,6 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error expanding `geo_filter`: %s", err) } - deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) - if err != nil { - return fmt.Errorf("Error expanding `delivery_policy`: %s", err) - } - endpoint := cdn.Endpoint{ Location: &location, EndpointProperties: &cdn.EndpointProperties{ @@ -262,7 +257,6 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro IsCompressionEnabled: &compressionEnabled, QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), OriginHostHeader: utils.String(originHostHeader), - DeliveryPolicy: deliveryPolicy, }, Tags: tags.Expand(t), } @@ -285,16 +279,40 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro endpoint.EndpointProperties.Origins = &origins } - future, err := client.Create(ctx, resourceGroup, profileName, name, endpoint) + profilesClient := meta.(*clients.Client).Cdn.ProfilesClient + profileGetCtx, profileGetCancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer profileGetCancel() + + profile, err := profilesClient.Get(profileGetCtx, 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 { + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + if err != nil { + return fmt.Errorf("Error expanding `global_delivery_rule` or `delivery_rule`: %s", err) + } + + if profile.Sku.Name == cdn.StandardMicrosoft { + endpoint.DeliveryPolicy = deliveryPolicy + } else { + if len(*deliveryPolicy.Rules) > 0 { + return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Microsoft_Standard` sku is used. Profile sku: %s", profile.Sku.Name) + } + } + } + + future, err := endpointsClient.Create(endpointCreateCtx, 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(endpointCreateCtx, 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(endpointCreateCtx, resourceGroup, profileName, name) if err != nil { return fmt.Errorf("Error retrieving CDN Endpoint %q (Profile %q / Resource Group %q): %+v", name, profileName, resourceGroup, err) } @@ -330,11 +348,6 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro return fmt.Errorf("Error expanding `geo_filter`: %s", err) } - deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) - if err != nil { - return fmt.Errorf("Error expanding `delivery_rule`: %s", err) - } - endpoint := cdn.EndpointUpdateParameters{ EndpointPropertiesUpdateParameters: &cdn.EndpointPropertiesUpdateParameters{ ContentTypesToCompress: &contentTypes, @@ -344,7 +357,6 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro IsCompressionEnabled: utils.Bool(compressionEnabled), QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), OriginHostHeader: utils.String(hostHeader), - DeliveryPolicy: deliveryPolicy, }, Tags: tags.Expand(t), } @@ -359,6 +371,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 { + deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + if err != nil { + return fmt.Errorf("Error expanding `global_delivery_rule` or `delivery_rule`: %s", err) + } + + if profile.Sku.Name == cdn.StandardMicrosoft { + endpoint.DeliveryPolicy = deliveryPolicy + } else { + if len(*deliveryPolicy.Rules) > 0 { + return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Microsoft_Standard` sku is used. Profile sku: %s", profile.Sku.Name) + } + } + } + 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) From 1a280900271cfef81af98a367ba2d93a4448437d Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 14:13:41 +0100 Subject: [PATCH 81/92] fix profile sku naming in error message --- azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index 8c1cd7a552ac..fe238b9ce00e 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -298,7 +298,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro endpoint.DeliveryPolicy = deliveryPolicy } else { if len(*deliveryPolicy.Rules) > 0 { - return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Microsoft_Standard` sku is used. Profile sku: %s", profile.Sku.Name) + return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) } } } @@ -390,7 +390,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro endpoint.DeliveryPolicy = deliveryPolicy } else { if len(*deliveryPolicy.Rules) > 0 { - return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Microsoft_Standard` sku is used. Profile sku: %s", profile.Sku.Name) + return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) } } } From b5fd573501ffa5068a4ea9e033e5089b2caa25c2 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 19:07:38 +0100 Subject: [PATCH 82/92] add test for global_delivery_rule --- .../tests/resource_arm_cdn_endpoint_test.go | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) 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..33d47d78964b 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 @@ -230,6 +230,49 @@ 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 testCheckAzureRMCdnEndpointExists(resourceName string) resource.TestCheckFunc { return func(s *terraform.State) error { conn := acceptance.AzureProvider.Meta().(*clients.Client).Cdn.EndpointsClient @@ -664,3 +707,131 @@ 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) +} From e9894632b86be27b4634665d16b638b3789e93f5 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 19:48:51 +0100 Subject: [PATCH 83/92] add test for delivery_rule --- .../tests/resource_arm_cdn_endpoint_test.go | 272 ++++++++++++++++++ 1 file changed, 272 insertions(+) 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 33d47d78964b..36f96f03a5b0 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 @@ -273,6 +273,76 @@ func TestAccAzureRMCdnEndpoint_globalDeliveryRule(t *testing.T) { }) } +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 @@ -835,3 +905,205 @@ resource "azurerm_cdn_endpoint" "test" { } `, 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) +} From 6007326270f4f7581489a056fcb780153394d694 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 21:51:51 +0100 Subject: [PATCH 84/92] fix linter problems --- azurerm/helpers/validate/cdn.go | 7 ++++--- azurerm/internal/services/cdn/endpoint_delivery_rule.go | 2 +- .../internal/services/cdn/endpoint_global_delivery_rule.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index a8751cd12308..2368cf04ea1c 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -2,10 +2,11 @@ package validate import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "regexp" "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" ) func EndpointDeliveryRuleName() schema.SchemaValidateFunc { @@ -17,7 +18,7 @@ func EndpointDeliveryRuleName() schema.SchemaValidateFunc { 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]$"), + 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.", ) } diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 228ff45864c2..2d402be893d7 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -304,7 +304,7 @@ func expandDeliveryRuleActions(rule map[string]interface{}) ([]cdn.BasicDelivery } func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { - res := make(map[string]interface{}, 0) + res := make(map[string]interface{}) if deliveryRule == nil { return res diff --git a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go index b08363cb2b22..d2c590421220 100644 --- a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go @@ -74,7 +74,7 @@ func expandArmCdnEndpointGlobalDeliveryRule(rule map[string]interface{}) (*cdn.D } func flattenArmCdnEndpointGlobalDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { - res := make(map[string]interface{}, 0) + res := make(map[string]interface{}) if deliveryRule == nil { return res From 65d11d6abca97ca21922960901d70f75803b7750 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 18 Mar 2020 21:53:17 +0100 Subject: [PATCH 85/92] fix tflinter problems --- .../tests/resource_arm_cdn_endpoint_test.go | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) 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 36f96f03a5b0..192dcb6bd24f 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 @@ -812,10 +812,10 @@ resource "azurerm_cdn_endpoint" "test" { } global_delivery_rule { - cache_expiration_action { - behavior = "Override" - duration = "5.04:44:23" - } + cache_expiration_action { + behavior = "Override" + duration = "5.04:44:23" + } } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) @@ -855,16 +855,16 @@ resource "azurerm_cdn_endpoint" "test" { } global_delivery_rule { - cache_expiration_action { - behavior = "SetIfMissing" - duration = "12.04:11:22" - } + cache_expiration_action { + behavior = "SetIfMissing" + duration = "12.04:11:22" + } - modify_response_header_action { - action = "Overwrite" + modify_response_header_action { + action = "Overwrite" name = "Content-Type" - value = "application/json" - } + value = "application/json" + } } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) @@ -943,13 +943,13 @@ resource "azurerm_cdn_endpoint" "test" { name = "http2https" order = 1 - request_scheme_condition { - match_values = ["HTTP"] - } + request_scheme_condition { + match_values = ["HTTP"] + } url_redirect_action { redirect_type = "Found" - protocol = "Https" + protocol = "Https" } } } @@ -993,14 +993,14 @@ resource "azurerm_cdn_endpoint" "test" { name = "http2https" order = 1 - request_scheme_condition { + request_scheme_condition { negate_condition = true - match_values = ["HTTPS"] - } + match_values = ["HTTPS"] + } url_redirect_action { redirect_type = "Found" - protocol = "Https" + protocol = "Https" } } } @@ -1044,14 +1044,14 @@ resource "azurerm_cdn_endpoint" "test" { name = "http2https" order = 1 - request_scheme_condition { + request_scheme_condition { negate_condition = true - match_values = ["HTTPS"] - } + match_values = ["HTTPS"] + } url_redirect_action { redirect_type = "Found" - protocol = "Https" + protocol = "Https" } } @@ -1059,13 +1059,13 @@ resource "azurerm_cdn_endpoint" "test" { name = "test" order = 2 - device_condition { - match_values = ["Mobile"] - } + device_condition { + match_values = ["Mobile"] + } modify_response_header_action { action = "Delete" - name = "Content-Language" + name = "Content-Language" } } } From 1e2756ee9acd46c5be8b00adf016ec5a6368169a Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Tue, 14 Apr 2020 14:02:11 +0200 Subject: [PATCH 86/92] cdn: removing the profile --- .../deliveryruleactions/cache_expiration.go | 2 +- .../profiles/latest/cdn/mgmt/cdn/models.go | 711 ------------------ vendor/modules.txt | 1 - 3 files changed, 1 insertion(+), 713 deletions(-) delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go diff --git a/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go index d0730948d229..e5a5116b4af2 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go @@ -3,7 +3,7 @@ package deliveryruleactions import ( "fmt" - "github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn" + "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" diff --git a/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go b/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go deleted file mode 100644 index efa977211a2a..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn/models.go +++ /dev/null @@ -1,711 +0,0 @@ -// +build go1.9 - -// Copyright 2020 Microsoft Corporation -// -// 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. - -// This code was auto-generated by: -// github.com/Azure/azure-sdk-for-go/tools/profileBuilder - -package cdn - -import ( - "context" - - original "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2019-04-15/cdn" -) - -const ( - DefaultBaseURI = original.DefaultBaseURI -) - -type CacheBehavior = original.CacheBehavior - -const ( - BypassCache CacheBehavior = original.BypassCache - Override CacheBehavior = original.Override - SetIfMissing CacheBehavior = original.SetIfMissing -) - -type CertificateSource = original.CertificateSource - -const ( - CertificateSourceAzureKeyVault CertificateSource = original.CertificateSourceAzureKeyVault - CertificateSourceCdn CertificateSource = original.CertificateSourceCdn - CertificateSourceCustomDomainHTTPSParameters CertificateSource = original.CertificateSourceCustomDomainHTTPSParameters -) - -type CertificateType = original.CertificateType - -const ( - Dedicated CertificateType = original.Dedicated - Shared CertificateType = original.Shared -) - -type CookiesOperator = original.CookiesOperator - -const ( - Any CookiesOperator = original.Any - BeginsWith CookiesOperator = original.BeginsWith - Contains CookiesOperator = original.Contains - EndsWith CookiesOperator = original.EndsWith - Equal CookiesOperator = original.Equal - GreaterThan CookiesOperator = original.GreaterThan - GreaterThanOrEqual CookiesOperator = original.GreaterThanOrEqual - LessThan CookiesOperator = original.LessThan - LessThanOrEqual CookiesOperator = original.LessThanOrEqual -) - -type CustomDomainResourceState = original.CustomDomainResourceState - -const ( - Active CustomDomainResourceState = original.Active - Creating CustomDomainResourceState = original.Creating - Deleting CustomDomainResourceState = original.Deleting -) - -type CustomHTTPSProvisioningState = original.CustomHTTPSProvisioningState - -const ( - Disabled CustomHTTPSProvisioningState = original.Disabled - Disabling CustomHTTPSProvisioningState = original.Disabling - Enabled CustomHTTPSProvisioningState = original.Enabled - Enabling CustomHTTPSProvisioningState = original.Enabling - Failed CustomHTTPSProvisioningState = original.Failed -) - -type CustomHTTPSProvisioningSubstate = original.CustomHTTPSProvisioningSubstate - -const ( - CertificateDeleted CustomHTTPSProvisioningSubstate = original.CertificateDeleted - CertificateDeployed CustomHTTPSProvisioningSubstate = original.CertificateDeployed - DeletingCertificate CustomHTTPSProvisioningSubstate = original.DeletingCertificate - DeployingCertificate CustomHTTPSProvisioningSubstate = original.DeployingCertificate - DomainControlValidationRequestApproved CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestApproved - DomainControlValidationRequestRejected CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestRejected - DomainControlValidationRequestTimedOut CustomHTTPSProvisioningSubstate = original.DomainControlValidationRequestTimedOut - IssuingCertificate CustomHTTPSProvisioningSubstate = original.IssuingCertificate - PendingDomainControlValidationREquestApproval CustomHTTPSProvisioningSubstate = original.PendingDomainControlValidationREquestApproval - SubmittingDomainControlValidationRequest CustomHTTPSProvisioningSubstate = original.SubmittingDomainControlValidationRequest -) - -type DestinationProtocol = original.DestinationProtocol - -const ( - HTTP DestinationProtocol = original.HTTP - HTTPS DestinationProtocol = original.HTTPS - MatchRequest DestinationProtocol = original.MatchRequest -) - -type EndpointResourceState = original.EndpointResourceState - -const ( - EndpointResourceStateCreating EndpointResourceState = original.EndpointResourceStateCreating - EndpointResourceStateDeleting EndpointResourceState = original.EndpointResourceStateDeleting - EndpointResourceStateRunning EndpointResourceState = original.EndpointResourceStateRunning - EndpointResourceStateStarting EndpointResourceState = original.EndpointResourceStateStarting - EndpointResourceStateStopped EndpointResourceState = original.EndpointResourceStateStopped - EndpointResourceStateStopping EndpointResourceState = original.EndpointResourceStateStopping -) - -type GeoFilterActions = original.GeoFilterActions - -const ( - Allow GeoFilterActions = original.Allow - Block GeoFilterActions = original.Block -) - -type HeaderAction = original.HeaderAction - -const ( - Append HeaderAction = original.Append - Delete HeaderAction = original.Delete - Overwrite HeaderAction = original.Overwrite -) - -type MinimumTLSVersion = original.MinimumTLSVersion - -const ( - None MinimumTLSVersion = original.None - TLS10 MinimumTLSVersion = original.TLS10 - TLS12 MinimumTLSVersion = original.TLS12 -) - -type Name = original.Name - -const ( - NameCookies Name = original.NameCookies - NameDeliveryRuleCondition Name = original.NameDeliveryRuleCondition - NameHTTPVersion Name = original.NameHTTPVersion - NameIsDevice Name = original.NameIsDevice - NamePostArgs Name = original.NamePostArgs - NameQueryString Name = original.NameQueryString - NameRemoteAddress Name = original.NameRemoteAddress - NameRequestBody Name = original.NameRequestBody - NameRequestHeader Name = original.NameRequestHeader - NameRequestMethod Name = original.NameRequestMethod - NameRequestScheme Name = original.NameRequestScheme - NameRequestURI Name = original.NameRequestURI - NameURLFileExtension Name = original.NameURLFileExtension - NameURLFileName Name = original.NameURLFileName - NameURLPath Name = original.NameURLPath -) - -type NameBasicDeliveryRuleAction = original.NameBasicDeliveryRuleAction - -const ( - NameCacheExpiration NameBasicDeliveryRuleAction = original.NameCacheExpiration - NameCacheKeyQueryString NameBasicDeliveryRuleAction = original.NameCacheKeyQueryString - NameDeliveryRuleAction NameBasicDeliveryRuleAction = original.NameDeliveryRuleAction - NameModifyRequestHeader NameBasicDeliveryRuleAction = original.NameModifyRequestHeader - NameModifyResponseHeader NameBasicDeliveryRuleAction = original.NameModifyResponseHeader - NameURLRedirect NameBasicDeliveryRuleAction = original.NameURLRedirect - NameURLRewrite NameBasicDeliveryRuleAction = original.NameURLRewrite -) - -type OptimizationType = original.OptimizationType - -const ( - DynamicSiteAcceleration OptimizationType = original.DynamicSiteAcceleration - GeneralMediaStreaming OptimizationType = original.GeneralMediaStreaming - GeneralWebDelivery OptimizationType = original.GeneralWebDelivery - LargeFileDownload OptimizationType = original.LargeFileDownload - VideoOnDemandMediaStreaming OptimizationType = original.VideoOnDemandMediaStreaming -) - -type OriginResourceState = original.OriginResourceState - -const ( - OriginResourceStateActive OriginResourceState = original.OriginResourceStateActive - OriginResourceStateCreating OriginResourceState = original.OriginResourceStateCreating - OriginResourceStateDeleting OriginResourceState = original.OriginResourceStateDeleting -) - -type PostArgsOperator = original.PostArgsOperator - -const ( - PostArgsOperatorAny PostArgsOperator = original.PostArgsOperatorAny - PostArgsOperatorBeginsWith PostArgsOperator = original.PostArgsOperatorBeginsWith - PostArgsOperatorContains PostArgsOperator = original.PostArgsOperatorContains - PostArgsOperatorEndsWith PostArgsOperator = original.PostArgsOperatorEndsWith - PostArgsOperatorEqual PostArgsOperator = original.PostArgsOperatorEqual - PostArgsOperatorGreaterThan PostArgsOperator = original.PostArgsOperatorGreaterThan - PostArgsOperatorGreaterThanOrEqual PostArgsOperator = original.PostArgsOperatorGreaterThanOrEqual - PostArgsOperatorLessThan PostArgsOperator = original.PostArgsOperatorLessThan - PostArgsOperatorLessThanOrEqual PostArgsOperator = original.PostArgsOperatorLessThanOrEqual -) - -type ProfileResourceState = original.ProfileResourceState - -const ( - ProfileResourceStateActive ProfileResourceState = original.ProfileResourceStateActive - ProfileResourceStateCreating ProfileResourceState = original.ProfileResourceStateCreating - ProfileResourceStateDeleting ProfileResourceState = original.ProfileResourceStateDeleting - ProfileResourceStateDisabled ProfileResourceState = original.ProfileResourceStateDisabled -) - -type ProtocolType = original.ProtocolType - -const ( - IPBased ProtocolType = original.IPBased - ServerNameIndication ProtocolType = original.ServerNameIndication -) - -type QueryStringBehavior = original.QueryStringBehavior - -const ( - Exclude QueryStringBehavior = original.Exclude - ExcludeAll QueryStringBehavior = original.ExcludeAll - Include QueryStringBehavior = original.Include - IncludeAll QueryStringBehavior = original.IncludeAll -) - -type QueryStringCachingBehavior = original.QueryStringCachingBehavior - -const ( - BypassCaching QueryStringCachingBehavior = original.BypassCaching - IgnoreQueryString QueryStringCachingBehavior = original.IgnoreQueryString - NotSet QueryStringCachingBehavior = original.NotSet - UseQueryString QueryStringCachingBehavior = original.UseQueryString -) - -type QueryStringOperator = original.QueryStringOperator - -const ( - QueryStringOperatorAny QueryStringOperator = original.QueryStringOperatorAny - QueryStringOperatorBeginsWith QueryStringOperator = original.QueryStringOperatorBeginsWith - QueryStringOperatorContains QueryStringOperator = original.QueryStringOperatorContains - QueryStringOperatorEndsWith QueryStringOperator = original.QueryStringOperatorEndsWith - QueryStringOperatorEqual QueryStringOperator = original.QueryStringOperatorEqual - QueryStringOperatorGreaterThan QueryStringOperator = original.QueryStringOperatorGreaterThan - QueryStringOperatorGreaterThanOrEqual QueryStringOperator = original.QueryStringOperatorGreaterThanOrEqual - QueryStringOperatorLessThan QueryStringOperator = original.QueryStringOperatorLessThan - QueryStringOperatorLessThanOrEqual QueryStringOperator = original.QueryStringOperatorLessThanOrEqual -) - -type RedirectType = original.RedirectType - -const ( - Found RedirectType = original.Found - Moved RedirectType = original.Moved - PermanentRedirect RedirectType = original.PermanentRedirect - TemporaryRedirect RedirectType = original.TemporaryRedirect -) - -type RemoteAddressOperator = original.RemoteAddressOperator - -const ( - RemoteAddressOperatorAny RemoteAddressOperator = original.RemoteAddressOperatorAny - RemoteAddressOperatorGeoMatch RemoteAddressOperator = original.RemoteAddressOperatorGeoMatch - RemoteAddressOperatorIPMatch RemoteAddressOperator = original.RemoteAddressOperatorIPMatch -) - -type RequestBodyOperator = original.RequestBodyOperator - -const ( - RequestBodyOperatorAny RequestBodyOperator = original.RequestBodyOperatorAny - RequestBodyOperatorBeginsWith RequestBodyOperator = original.RequestBodyOperatorBeginsWith - RequestBodyOperatorContains RequestBodyOperator = original.RequestBodyOperatorContains - RequestBodyOperatorEndsWith RequestBodyOperator = original.RequestBodyOperatorEndsWith - RequestBodyOperatorEqual RequestBodyOperator = original.RequestBodyOperatorEqual - RequestBodyOperatorGreaterThan RequestBodyOperator = original.RequestBodyOperatorGreaterThan - RequestBodyOperatorGreaterThanOrEqual RequestBodyOperator = original.RequestBodyOperatorGreaterThanOrEqual - RequestBodyOperatorLessThan RequestBodyOperator = original.RequestBodyOperatorLessThan - RequestBodyOperatorLessThanOrEqual RequestBodyOperator = original.RequestBodyOperatorLessThanOrEqual -) - -type RequestHeaderOperator = original.RequestHeaderOperator - -const ( - RequestHeaderOperatorAny RequestHeaderOperator = original.RequestHeaderOperatorAny - RequestHeaderOperatorBeginsWith RequestHeaderOperator = original.RequestHeaderOperatorBeginsWith - RequestHeaderOperatorContains RequestHeaderOperator = original.RequestHeaderOperatorContains - RequestHeaderOperatorEndsWith RequestHeaderOperator = original.RequestHeaderOperatorEndsWith - RequestHeaderOperatorEqual RequestHeaderOperator = original.RequestHeaderOperatorEqual - RequestHeaderOperatorGreaterThan RequestHeaderOperator = original.RequestHeaderOperatorGreaterThan - RequestHeaderOperatorGreaterThanOrEqual RequestHeaderOperator = original.RequestHeaderOperatorGreaterThanOrEqual - RequestHeaderOperatorLessThan RequestHeaderOperator = original.RequestHeaderOperatorLessThan - RequestHeaderOperatorLessThanOrEqual RequestHeaderOperator = original.RequestHeaderOperatorLessThanOrEqual -) - -type RequestURIOperator = original.RequestURIOperator - -const ( - RequestURIOperatorAny RequestURIOperator = original.RequestURIOperatorAny - RequestURIOperatorBeginsWith RequestURIOperator = original.RequestURIOperatorBeginsWith - RequestURIOperatorContains RequestURIOperator = original.RequestURIOperatorContains - RequestURIOperatorEndsWith RequestURIOperator = original.RequestURIOperatorEndsWith - RequestURIOperatorEqual RequestURIOperator = original.RequestURIOperatorEqual - RequestURIOperatorGreaterThan RequestURIOperator = original.RequestURIOperatorGreaterThan - RequestURIOperatorGreaterThanOrEqual RequestURIOperator = original.RequestURIOperatorGreaterThanOrEqual - RequestURIOperatorLessThan RequestURIOperator = original.RequestURIOperatorLessThan - RequestURIOperatorLessThanOrEqual RequestURIOperator = original.RequestURIOperatorLessThanOrEqual -) - -type ResourceType = original.ResourceType - -const ( - MicrosoftCdnProfilesEndpoints ResourceType = original.MicrosoftCdnProfilesEndpoints -) - -type SkuName = original.SkuName - -const ( - CustomVerizon SkuName = original.CustomVerizon - PremiumChinaCdn SkuName = original.PremiumChinaCdn - PremiumVerizon SkuName = original.PremiumVerizon - StandardAkamai SkuName = original.StandardAkamai - StandardChinaCdn SkuName = original.StandardChinaCdn - StandardMicrosoft SkuName = original.StandardMicrosoft - StandardVerizon SkuName = original.StandardVerizon -) - -type Transform = original.Transform - -const ( - Lowercase Transform = original.Lowercase - Uppercase Transform = original.Uppercase -) - -type URLFileExtensionOperator = original.URLFileExtensionOperator - -const ( - URLFileExtensionOperatorAny URLFileExtensionOperator = original.URLFileExtensionOperatorAny - URLFileExtensionOperatorBeginsWith URLFileExtensionOperator = original.URLFileExtensionOperatorBeginsWith - URLFileExtensionOperatorContains URLFileExtensionOperator = original.URLFileExtensionOperatorContains - URLFileExtensionOperatorEndsWith URLFileExtensionOperator = original.URLFileExtensionOperatorEndsWith - URLFileExtensionOperatorEqual URLFileExtensionOperator = original.URLFileExtensionOperatorEqual - URLFileExtensionOperatorGreaterThan URLFileExtensionOperator = original.URLFileExtensionOperatorGreaterThan - URLFileExtensionOperatorGreaterThanOrEqual URLFileExtensionOperator = original.URLFileExtensionOperatorGreaterThanOrEqual - URLFileExtensionOperatorLessThan URLFileExtensionOperator = original.URLFileExtensionOperatorLessThan - URLFileExtensionOperatorLessThanOrEqual URLFileExtensionOperator = original.URLFileExtensionOperatorLessThanOrEqual -) - -type URLFileNameOperator = original.URLFileNameOperator - -const ( - URLFileNameOperatorAny URLFileNameOperator = original.URLFileNameOperatorAny - URLFileNameOperatorBeginsWith URLFileNameOperator = original.URLFileNameOperatorBeginsWith - URLFileNameOperatorContains URLFileNameOperator = original.URLFileNameOperatorContains - URLFileNameOperatorEndsWith URLFileNameOperator = original.URLFileNameOperatorEndsWith - URLFileNameOperatorEqual URLFileNameOperator = original.URLFileNameOperatorEqual - URLFileNameOperatorGreaterThan URLFileNameOperator = original.URLFileNameOperatorGreaterThan - URLFileNameOperatorGreaterThanOrEqual URLFileNameOperator = original.URLFileNameOperatorGreaterThanOrEqual - URLFileNameOperatorLessThan URLFileNameOperator = original.URLFileNameOperatorLessThan - URLFileNameOperatorLessThanOrEqual URLFileNameOperator = original.URLFileNameOperatorLessThanOrEqual -) - -type URLPathOperator = original.URLPathOperator - -const ( - URLPathOperatorAny URLPathOperator = original.URLPathOperatorAny - URLPathOperatorBeginsWith URLPathOperator = original.URLPathOperatorBeginsWith - URLPathOperatorContains URLPathOperator = original.URLPathOperatorContains - URLPathOperatorEndsWith URLPathOperator = original.URLPathOperatorEndsWith - URLPathOperatorEqual URLPathOperator = original.URLPathOperatorEqual - URLPathOperatorGreaterThan URLPathOperator = original.URLPathOperatorGreaterThan - URLPathOperatorGreaterThanOrEqual URLPathOperator = original.URLPathOperatorGreaterThanOrEqual - URLPathOperatorLessThan URLPathOperator = original.URLPathOperatorLessThan - URLPathOperatorLessThanOrEqual URLPathOperator = original.URLPathOperatorLessThanOrEqual - URLPathOperatorWildcard URLPathOperator = original.URLPathOperatorWildcard -) - -type BaseClient = original.BaseClient -type BasicCustomDomainHTTPSParameters = original.BasicCustomDomainHTTPSParameters -type BasicDeliveryRuleAction = original.BasicDeliveryRuleAction -type BasicDeliveryRuleCondition = original.BasicDeliveryRuleCondition -type CacheExpirationActionParameters = original.CacheExpirationActionParameters -type CacheKeyQueryStringActionParameters = original.CacheKeyQueryStringActionParameters -type CertificateSourceParameters = original.CertificateSourceParameters -type CheckNameAvailabilityInput = original.CheckNameAvailabilityInput -type CheckNameAvailabilityOutput = original.CheckNameAvailabilityOutput -type CidrIPAddress = original.CidrIPAddress -type CookiesMatchConditionParameters = original.CookiesMatchConditionParameters -type CustomDomain = original.CustomDomain -type CustomDomainHTTPSParameters = original.CustomDomainHTTPSParameters -type CustomDomainListResult = original.CustomDomainListResult -type CustomDomainListResultIterator = original.CustomDomainListResultIterator -type CustomDomainListResultPage = original.CustomDomainListResultPage -type CustomDomainParameters = original.CustomDomainParameters -type CustomDomainProperties = original.CustomDomainProperties -type CustomDomainPropertiesParameters = original.CustomDomainPropertiesParameters -type CustomDomainsClient = original.CustomDomainsClient -type CustomDomainsCreateFuture = original.CustomDomainsCreateFuture -type CustomDomainsDeleteFuture = original.CustomDomainsDeleteFuture -type DeepCreatedOrigin = original.DeepCreatedOrigin -type DeepCreatedOriginProperties = original.DeepCreatedOriginProperties -type DeliveryRule = original.DeliveryRule -type DeliveryRuleAction = original.DeliveryRuleAction -type DeliveryRuleCacheExpirationAction = original.DeliveryRuleCacheExpirationAction -type DeliveryRuleCacheKeyQueryStringAction = original.DeliveryRuleCacheKeyQueryStringAction -type DeliveryRuleCondition = original.DeliveryRuleCondition -type DeliveryRuleCookiesCondition = original.DeliveryRuleCookiesCondition -type DeliveryRuleHTTPVersionCondition = original.DeliveryRuleHTTPVersionCondition -type DeliveryRuleIsDeviceCondition = original.DeliveryRuleIsDeviceCondition -type DeliveryRulePostArgsCondition = original.DeliveryRulePostArgsCondition -type DeliveryRuleQueryStringCondition = original.DeliveryRuleQueryStringCondition -type DeliveryRuleRemoteAddressCondition = original.DeliveryRuleRemoteAddressCondition -type DeliveryRuleRequestBodyCondition = original.DeliveryRuleRequestBodyCondition -type DeliveryRuleRequestHeaderAction = original.DeliveryRuleRequestHeaderAction -type DeliveryRuleRequestHeaderCondition = original.DeliveryRuleRequestHeaderCondition -type DeliveryRuleRequestMethodCondition = original.DeliveryRuleRequestMethodCondition -type DeliveryRuleRequestSchemeCondition = original.DeliveryRuleRequestSchemeCondition -type DeliveryRuleRequestURICondition = original.DeliveryRuleRequestURICondition -type DeliveryRuleResponseHeaderAction = original.DeliveryRuleResponseHeaderAction -type DeliveryRuleURLFileExtensionCondition = original.DeliveryRuleURLFileExtensionCondition -type DeliveryRuleURLFileNameCondition = original.DeliveryRuleURLFileNameCondition -type DeliveryRuleURLPathCondition = original.DeliveryRuleURLPathCondition -type EdgeNode = original.EdgeNode -type EdgeNodeProperties = original.EdgeNodeProperties -type EdgeNodesClient = original.EdgeNodesClient -type EdgenodeResult = original.EdgenodeResult -type EdgenodeResultIterator = original.EdgenodeResultIterator -type EdgenodeResultPage = original.EdgenodeResultPage -type Endpoint = original.Endpoint -type EndpointListResult = original.EndpointListResult -type EndpointListResultIterator = original.EndpointListResultIterator -type EndpointListResultPage = original.EndpointListResultPage -type EndpointProperties = original.EndpointProperties -type EndpointPropertiesUpdateParameters = original.EndpointPropertiesUpdateParameters -type EndpointPropertiesUpdateParametersDeliveryPolicy = original.EndpointPropertiesUpdateParametersDeliveryPolicy -type EndpointUpdateParameters = original.EndpointUpdateParameters -type EndpointsClient = original.EndpointsClient -type EndpointsCreateFuture = original.EndpointsCreateFuture -type EndpointsDeleteFuture = original.EndpointsDeleteFuture -type EndpointsLoadContentFuture = original.EndpointsLoadContentFuture -type EndpointsPurgeContentFuture = original.EndpointsPurgeContentFuture -type EndpointsStartFuture = original.EndpointsStartFuture -type EndpointsStopFuture = original.EndpointsStopFuture -type EndpointsUpdateFuture = original.EndpointsUpdateFuture -type ErrorResponse = original.ErrorResponse -type GeoFilter = original.GeoFilter -type HTTPVersionMatchConditionParameters = original.HTTPVersionMatchConditionParameters -type HeaderActionParameters = original.HeaderActionParameters -type IPAddressGroup = original.IPAddressGroup -type IsDeviceMatchConditionParameters = original.IsDeviceMatchConditionParameters -type KeyVaultCertificateSourceParameters = original.KeyVaultCertificateSourceParameters -type LoadParameters = original.LoadParameters -type ManagedHTTPSParameters = original.ManagedHTTPSParameters -type Operation = original.Operation -type OperationDisplay = original.OperationDisplay -type OperationsClient = original.OperationsClient -type OperationsListResult = original.OperationsListResult -type OperationsListResultIterator = original.OperationsListResultIterator -type OperationsListResultPage = original.OperationsListResultPage -type Origin = original.Origin -type OriginListResult = original.OriginListResult -type OriginListResultIterator = original.OriginListResultIterator -type OriginListResultPage = original.OriginListResultPage -type OriginProperties = original.OriginProperties -type OriginPropertiesParameters = original.OriginPropertiesParameters -type OriginUpdateParameters = original.OriginUpdateParameters -type OriginsClient = original.OriginsClient -type OriginsUpdateFuture = original.OriginsUpdateFuture -type PostArgsMatchConditionParameters = original.PostArgsMatchConditionParameters -type Profile = original.Profile -type ProfileListResult = original.ProfileListResult -type ProfileListResultIterator = original.ProfileListResultIterator -type ProfileListResultPage = original.ProfileListResultPage -type ProfileProperties = original.ProfileProperties -type ProfileUpdateParameters = original.ProfileUpdateParameters -type ProfilesClient = original.ProfilesClient -type ProfilesCreateFuture = original.ProfilesCreateFuture -type ProfilesDeleteFuture = original.ProfilesDeleteFuture -type ProfilesUpdateFuture = original.ProfilesUpdateFuture -type ProxyResource = original.ProxyResource -type PurgeParameters = original.PurgeParameters -type QueryStringMatchConditionParameters = original.QueryStringMatchConditionParameters -type RemoteAddressMatchConditionParameters = original.RemoteAddressMatchConditionParameters -type RequestBodyMatchConditionParameters = original.RequestBodyMatchConditionParameters -type RequestHeaderMatchConditionParameters = original.RequestHeaderMatchConditionParameters -type RequestMethodMatchConditionParameters = original.RequestMethodMatchConditionParameters -type RequestSchemeMatchConditionParameters = original.RequestSchemeMatchConditionParameters -type RequestURIMatchConditionParameters = original.RequestURIMatchConditionParameters -type Resource = original.Resource -type ResourceUsage = original.ResourceUsage -type ResourceUsageClient = original.ResourceUsageClient -type ResourceUsageListResult = original.ResourceUsageListResult -type ResourceUsageListResultIterator = original.ResourceUsageListResultIterator -type ResourceUsageListResultPage = original.ResourceUsageListResultPage -type Sku = original.Sku -type SsoURI = original.SsoURI -type SupportedOptimizationTypesListResult = original.SupportedOptimizationTypesListResult -type TrackedResource = original.TrackedResource -type URLFileExtensionMatchConditionParameters = original.URLFileExtensionMatchConditionParameters -type URLFileNameMatchConditionParameters = original.URLFileNameMatchConditionParameters -type URLPathMatchConditionParameters = original.URLPathMatchConditionParameters -type URLRedirectAction = original.URLRedirectAction -type URLRedirectActionParameters = original.URLRedirectActionParameters -type URLRewriteAction = original.URLRewriteAction -type URLRewriteActionParameters = original.URLRewriteActionParameters -type UserManagedHTTPSParameters = original.UserManagedHTTPSParameters -type ValidateCustomDomainInput = original.ValidateCustomDomainInput -type ValidateCustomDomainOutput = original.ValidateCustomDomainOutput -type ValidateProbeInput = original.ValidateProbeInput -type ValidateProbeOutput = original.ValidateProbeOutput - -func New(subscriptionID string) BaseClient { - return original.New(subscriptionID) -} -func NewCustomDomainListResultIterator(page CustomDomainListResultPage) CustomDomainListResultIterator { - return original.NewCustomDomainListResultIterator(page) -} -func NewCustomDomainListResultPage(getNextPage func(context.Context, CustomDomainListResult) (CustomDomainListResult, error)) CustomDomainListResultPage { - return original.NewCustomDomainListResultPage(getNextPage) -} -func NewCustomDomainsClient(subscriptionID string) CustomDomainsClient { - return original.NewCustomDomainsClient(subscriptionID) -} -func NewCustomDomainsClientWithBaseURI(baseURI string, subscriptionID string) CustomDomainsClient { - return original.NewCustomDomainsClientWithBaseURI(baseURI, subscriptionID) -} -func NewEdgeNodesClient(subscriptionID string) EdgeNodesClient { - return original.NewEdgeNodesClient(subscriptionID) -} -func NewEdgeNodesClientWithBaseURI(baseURI string, subscriptionID string) EdgeNodesClient { - return original.NewEdgeNodesClientWithBaseURI(baseURI, subscriptionID) -} -func NewEdgenodeResultIterator(page EdgenodeResultPage) EdgenodeResultIterator { - return original.NewEdgenodeResultIterator(page) -} -func NewEdgenodeResultPage(getNextPage func(context.Context, EdgenodeResult) (EdgenodeResult, error)) EdgenodeResultPage { - return original.NewEdgenodeResultPage(getNextPage) -} -func NewEndpointListResultIterator(page EndpointListResultPage) EndpointListResultIterator { - return original.NewEndpointListResultIterator(page) -} -func NewEndpointListResultPage(getNextPage func(context.Context, EndpointListResult) (EndpointListResult, error)) EndpointListResultPage { - return original.NewEndpointListResultPage(getNextPage) -} -func NewEndpointsClient(subscriptionID string) EndpointsClient { - return original.NewEndpointsClient(subscriptionID) -} -func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient { - return original.NewEndpointsClientWithBaseURI(baseURI, subscriptionID) -} -func NewOperationsClient(subscriptionID string) OperationsClient { - return original.NewOperationsClient(subscriptionID) -} -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) -} -func NewOperationsListResultIterator(page OperationsListResultPage) OperationsListResultIterator { - return original.NewOperationsListResultIterator(page) -} -func NewOperationsListResultPage(getNextPage func(context.Context, OperationsListResult) (OperationsListResult, error)) OperationsListResultPage { - return original.NewOperationsListResultPage(getNextPage) -} -func NewOriginListResultIterator(page OriginListResultPage) OriginListResultIterator { - return original.NewOriginListResultIterator(page) -} -func NewOriginListResultPage(getNextPage func(context.Context, OriginListResult) (OriginListResult, error)) OriginListResultPage { - return original.NewOriginListResultPage(getNextPage) -} -func NewOriginsClient(subscriptionID string) OriginsClient { - return original.NewOriginsClient(subscriptionID) -} -func NewOriginsClientWithBaseURI(baseURI string, subscriptionID string) OriginsClient { - return original.NewOriginsClientWithBaseURI(baseURI, subscriptionID) -} -func NewProfileListResultIterator(page ProfileListResultPage) ProfileListResultIterator { - return original.NewProfileListResultIterator(page) -} -func NewProfileListResultPage(getNextPage func(context.Context, ProfileListResult) (ProfileListResult, error)) ProfileListResultPage { - return original.NewProfileListResultPage(getNextPage) -} -func NewProfilesClient(subscriptionID string) ProfilesClient { - return original.NewProfilesClient(subscriptionID) -} -func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) ProfilesClient { - return original.NewProfilesClientWithBaseURI(baseURI, subscriptionID) -} -func NewResourceUsageClient(subscriptionID string) ResourceUsageClient { - return original.NewResourceUsageClient(subscriptionID) -} -func NewResourceUsageClientWithBaseURI(baseURI string, subscriptionID string) ResourceUsageClient { - return original.NewResourceUsageClientWithBaseURI(baseURI, subscriptionID) -} -func NewResourceUsageListResultIterator(page ResourceUsageListResultPage) ResourceUsageListResultIterator { - return original.NewResourceUsageListResultIterator(page) -} -func NewResourceUsageListResultPage(getNextPage func(context.Context, ResourceUsageListResult) (ResourceUsageListResult, error)) ResourceUsageListResultPage { - return original.NewResourceUsageListResultPage(getNextPage) -} -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return original.NewWithBaseURI(baseURI, subscriptionID) -} -func PossibleCacheBehaviorValues() []CacheBehavior { - return original.PossibleCacheBehaviorValues() -} -func PossibleCertificateSourceValues() []CertificateSource { - return original.PossibleCertificateSourceValues() -} -func PossibleCertificateTypeValues() []CertificateType { - return original.PossibleCertificateTypeValues() -} -func PossibleCookiesOperatorValues() []CookiesOperator { - return original.PossibleCookiesOperatorValues() -} -func PossibleCustomDomainResourceStateValues() []CustomDomainResourceState { - return original.PossibleCustomDomainResourceStateValues() -} -func PossibleCustomHTTPSProvisioningStateValues() []CustomHTTPSProvisioningState { - return original.PossibleCustomHTTPSProvisioningStateValues() -} -func PossibleCustomHTTPSProvisioningSubstateValues() []CustomHTTPSProvisioningSubstate { - return original.PossibleCustomHTTPSProvisioningSubstateValues() -} -func PossibleDestinationProtocolValues() []DestinationProtocol { - return original.PossibleDestinationProtocolValues() -} -func PossibleEndpointResourceStateValues() []EndpointResourceState { - return original.PossibleEndpointResourceStateValues() -} -func PossibleGeoFilterActionsValues() []GeoFilterActions { - return original.PossibleGeoFilterActionsValues() -} -func PossibleHeaderActionValues() []HeaderAction { - return original.PossibleHeaderActionValues() -} -func PossibleMinimumTLSVersionValues() []MinimumTLSVersion { - return original.PossibleMinimumTLSVersionValues() -} -func PossibleNameBasicDeliveryRuleActionValues() []NameBasicDeliveryRuleAction { - return original.PossibleNameBasicDeliveryRuleActionValues() -} -func PossibleNameValues() []Name { - return original.PossibleNameValues() -} -func PossibleOptimizationTypeValues() []OptimizationType { - return original.PossibleOptimizationTypeValues() -} -func PossibleOriginResourceStateValues() []OriginResourceState { - return original.PossibleOriginResourceStateValues() -} -func PossiblePostArgsOperatorValues() []PostArgsOperator { - return original.PossiblePostArgsOperatorValues() -} -func PossibleProfileResourceStateValues() []ProfileResourceState { - return original.PossibleProfileResourceStateValues() -} -func PossibleProtocolTypeValues() []ProtocolType { - return original.PossibleProtocolTypeValues() -} -func PossibleQueryStringBehaviorValues() []QueryStringBehavior { - return original.PossibleQueryStringBehaviorValues() -} -func PossibleQueryStringCachingBehaviorValues() []QueryStringCachingBehavior { - return original.PossibleQueryStringCachingBehaviorValues() -} -func PossibleQueryStringOperatorValues() []QueryStringOperator { - return original.PossibleQueryStringOperatorValues() -} -func PossibleRedirectTypeValues() []RedirectType { - return original.PossibleRedirectTypeValues() -} -func PossibleRemoteAddressOperatorValues() []RemoteAddressOperator { - return original.PossibleRemoteAddressOperatorValues() -} -func PossibleRequestBodyOperatorValues() []RequestBodyOperator { - return original.PossibleRequestBodyOperatorValues() -} -func PossibleRequestHeaderOperatorValues() []RequestHeaderOperator { - return original.PossibleRequestHeaderOperatorValues() -} -func PossibleRequestURIOperatorValues() []RequestURIOperator { - return original.PossibleRequestURIOperatorValues() -} -func PossibleResourceTypeValues() []ResourceType { - return original.PossibleResourceTypeValues() -} -func PossibleSkuNameValues() []SkuName { - return original.PossibleSkuNameValues() -} -func PossibleTransformValues() []Transform { - return original.PossibleTransformValues() -} -func PossibleURLFileExtensionOperatorValues() []URLFileExtensionOperator { - return original.PossibleURLFileExtensionOperatorValues() -} -func PossibleURLFileNameOperatorValues() []URLFileNameOperator { - return original.PossibleURLFileNameOperatorValues() -} -func PossibleURLPathOperatorValues() []URLPathOperator { - return original.PossibleURLPathOperatorValues() -} -func UserAgent() string { - return original.UserAgent() + " profiles/latest" -} -func Version() string { - return original.Version() -} diff --git a/vendor/modules.txt b/vendor/modules.txt index d8a59168c26d..d3a9189e8553 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -8,7 +8,6 @@ cloud.google.com/go/internal/version cloud.google.com/go/storage # github.com/Azure/azure-sdk-for-go v40.3.0+incompatible github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources -github.com/Azure/azure-sdk-for-go/profiles/latest/cdn/mgmt/cdn github.com/Azure/azure-sdk-for-go/services/analysisservices/mgmt/2017-08-01/analysisservices github.com/Azure/azure-sdk-for-go/services/apimanagement/mgmt/2018-01-01/apimanagement github.com/Azure/azure-sdk-for-go/services/appconfiguration/mgmt/2019-10-01/appconfiguration From e8a20165cad77f1fe9512526d18e6d5c9d22b14f Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 15 Apr 2020 10:35:01 +0200 Subject: [PATCH 87/92] r/cdn_endpoint: reusing the same ctx --- .../services/cdn/resource_arm_cdn_endpoint.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index fe238b9ce00e..a05869ce6501 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -208,8 +208,9 @@ func resourceArmCdnEndpoint() *schema.Resource { func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error { endpointsClient := meta.(*clients.Client).Cdn.EndpointsClient - endpointCreateCtx, endpointCreateCancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) - defer endpointCreateCancel() + profilesClient := meta.(*clients.Client).Cdn.ProfilesClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer cancel() log.Printf("[INFO] preparing arguments for Azure ARM CDN EndPoint creation.") @@ -218,7 +219,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro profileName := d.Get("profile_name").(string) if features.ShouldResourcesBeImported() && d.IsNewResource() { - existing, err := endpointsClient.Get(endpointCreateCtx, resourceGroup, profileName, name) + 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) @@ -279,11 +280,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro endpoint.EndpointProperties.Origins = &origins } - profilesClient := meta.(*clients.Client).Cdn.ProfilesClient - profileGetCtx, profileGetCancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) - defer profileGetCancel() - - profile, err := profilesClient.Get(profileGetCtx, resourceGroup, profileName) + 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) } @@ -303,16 +300,16 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro } } - future, err := endpointsClient.Create(endpointCreateCtx, resourceGroup, profileName, name, endpoint) + 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(endpointCreateCtx, endpointsClient.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 := endpointsClient.Get(endpointCreateCtx, 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) } From 80194a95e217624b7e48a44e3fb0d5f522e53628 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 15 Apr 2020 15:34:33 +0200 Subject: [PATCH 88/92] refactoring from PR / ensuring fields are always set --- .../deliveryruleactions/cache_expiration.go | 56 +- .../cache_key_query_string.go | 56 +- .../modify_request_header.go | 61 ++- .../modify_response_header.go | 60 ++- .../cdn/deliveryruleactions/url_redirect.go | 93 ++-- .../cdn/deliveryruleactions/url_rewrite.go | 59 ++- .../cdn/deliveryruleconditions/cookies.go | 75 ++- .../cdn/deliveryruleconditions/device.go | 51 +- .../deliveryruleconditions/http_version.go | 51 +- .../cdn/deliveryruleconditions/post_arg.go | 77 ++- .../deliveryruleconditions/query_string.go | 70 ++- .../deliveryruleconditions/remote_address.go | 52 +- .../deliveryruleconditions/request_body.go | 70 ++- .../deliveryruleconditions/request_header.go | 41 +- .../deliveryruleconditions/request_method.go | 51 +- .../deliveryruleconditions/request_scheme.go | 56 +- .../cdn/deliveryruleconditions/request_uri.go | 69 ++- .../url_file_extension.go | 70 ++- .../deliveryruleconditions/url_file_name.go | 70 ++- .../cdn/deliveryruleconditions/url_path.go | 70 ++- .../services/cdn/endpoint_delivery_rule.go | 497 +++++++++--------- .../cdn/endpoint_global_delivery_rule.go | 13 +- .../services/cdn/resource_arm_cdn_endpoint.go | 121 +++-- 23 files changed, 1143 insertions(+), 746 deletions(-) diff --git a/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go index e5a5116b4af2..247aceef8eaa 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/cache_expiration.go @@ -32,37 +32,53 @@ func CacheExpiration() *schema.Resource { } } -func ExpandArmCdnEndpointActionCacheExpiration(cea map[string]interface{}) (*cdn.DeliveryRuleCacheExpirationAction, error) { - cacheExpirationAction := cdn.DeliveryRuleCacheExpirationAction{ - Name: cdn.NameCacheExpiration, - Parameters: &cdn.CacheExpirationActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters"), - CacheBehavior: cdn.CacheBehavior(cea["behavior"].(string)), - CacheType: utils.String("All"), - }, - } +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 := cea["duration"].(string); duration != "" { - if cacheExpirationAction.Parameters.CacheBehavior == cdn.BypassCache { - return nil, fmt.Errorf("Cache expiration duration must not be set when using behavior `BypassCache`") + 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) } - cacheExpirationAction.Parameters.CacheDuration = utils.String(duration) + output = append(output, cacheExpirationAction) } - return &cacheExpirationAction, nil + return &output, nil } -func FlattenArmCdnEndpointActionCacheExpiration(cea *cdn.DeliveryRuleCacheExpirationAction) map[string]interface{} { - res := make(map[string]interface{}, 1) +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!") + } - if params := cea.Parameters; params != nil { - res["behavior"] = string(params.CacheBehavior) + behaviour := "" + duration := "" + if params := action.Parameters; params != nil { + behaviour = string(params.CacheBehavior) if params.CacheDuration != nil { - res["duration"] = *params.CacheDuration + duration = *params.CacheDuration } } - return res + 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 index db001b9feceb..2c8479559612 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/cache_key_query_string.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/cache_key_query_string.go @@ -31,36 +31,52 @@ func CacheKeyQueryString() *schema.Resource { } } -func ExpandArmCdnEndpointActionCacheKeyQueryString(ckqsa map[string]interface{}) (*cdn.DeliveryRuleCacheKeyQueryStringAction, error) { - cacheKeyQueryStringAction := cdn.DeliveryRuleCacheKeyQueryStringAction{ - Name: cdn.NameCacheKeyQueryString, - Parameters: &cdn.CacheKeyQueryStringActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCacheKeyQueryStringBehaviorActionParameters"), - QueryStringBehavior: cdn.QueryStringBehavior(ckqsa["behavior"].(string)), - }, - } +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 := ckqsa["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.") + 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) } - } else { - cacheKeyQueryStringAction.Parameters.QueryParameters = utils.String(parameters) + + output = append(output, cacheKeyQueryStringAction) } - return &cacheKeyQueryStringAction, nil + return &output, nil } -func FlattenArmCdnEndpointActionCacheKeyQueryString(ckqsa *cdn.DeliveryRuleCacheKeyQueryStringAction) map[string]interface{} { - res := make(map[string]interface{}, 1) +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!") + } - if params := ckqsa.Parameters; params != nil { - res["behavior"] = string(params.QueryStringBehavior) + behaviour := "" + parameters := "" + if params := action.Parameters; params != nil { + behaviour = string(params.QueryStringBehavior) if params.QueryParameters != nil { - res["parameters"] = *params.QueryParameters + parameters = *params.QueryParameters } } - return res + 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 index d8fbbca7a94b..0435c44bcdde 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/modify_request_header.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/modify_request_header.go @@ -1,6 +1,8 @@ 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" @@ -33,34 +35,55 @@ func ModifyRequestHeader() *schema.Resource { } } -func ExpandArmCdnEndpointActionModifyRequestHeader(mrha map[string]interface{}) *cdn.DeliveryRuleRequestHeaderAction { - requestHeaderAction := cdn.DeliveryRuleRequestHeaderAction{ - Name: cdn.NameModifyRequestHeader, - Parameters: &cdn.HeaderActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters"), - HeaderAction: cdn.HeaderAction(mrha["action"].(string)), - HeaderName: utils.String(mrha["name"].(string)), - }, - } +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) + } - if value := mrha["value"].(string); value != "" { - requestHeaderAction.Parameters.Value = utils.String(value) + output = append(output, requestHeaderAction) } - return &requestHeaderAction + return &output, nil } -func FlattenArmCdnEndpointActionModifyRequestHeader(mrha *cdn.DeliveryRuleRequestHeaderAction) map[string]interface{} { - res := make(map[string]interface{}, 1) +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 := mrha.Parameters; params != nil { - res["action"] = string(params.HeaderAction) - res["name"] = *params.HeaderName + if params.HeaderName != nil { + headerName = *params.HeaderName + } if params.Value != nil { - res["value"] = *params.Value + value = *params.Value } } - return res + 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 index f8ed28dee3dd..dc3a4d5754e3 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/modify_response_header.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/modify_response_header.go @@ -1,6 +1,8 @@ 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" @@ -33,34 +35,54 @@ func ModifyResponseHeader() *schema.Resource { } } -func ExpandArmCdnEndpointActionModifyResponseHeader(mrha map[string]interface{}) *cdn.DeliveryRuleResponseHeaderAction { - requestHeaderAction := cdn.DeliveryRuleResponseHeaderAction{ - Name: cdn.NameModifyResponseHeader, - Parameters: &cdn.HeaderActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters"), - HeaderAction: cdn.HeaderAction(mrha["action"].(string)), - HeaderName: utils.String(mrha["name"].(string)), - }, - } +func ExpandArmCdnEndpointActionModifyResponseHeader(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) - if value := mrha["value"].(string); value != "" { - requestHeaderAction.Parameters.Value = utils.String(value) + 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 &requestHeaderAction + return &output, nil } -func FlattenArmCdnEndpointActionModifyResponseHeader(mrha *cdn.DeliveryRuleResponseHeaderAction) map[string]interface{} { - res := make(map[string]interface{}, 1) +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!") + } - if params := mrha.Parameters; params != nil { - res["action"] = string(params.HeaderAction) - res["name"] = *params.HeaderName + headerAction := "" + headerName := "" + value := "" + if params := action.Parameters; params != nil { + headerAction = string(params.HeaderAction) + if params.HeaderName != nil { + headerName = *params.HeaderName + } if params.Value != nil { - res["value"] = *params.Value + value = *params.Value } } - return res + 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 index eaa4593f63f0..9c11a25afbe9 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/url_redirect.go @@ -1,6 +1,8 @@ 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" @@ -59,65 +61,86 @@ func URLRedirect() *schema.Resource { } } -func ExpandArmCdnEndpointActionUrlRedirect(ura map[string]interface{}) *cdn.URLRedirectAction { - urlRedirectAction := cdn.URLRedirectAction{ - Name: cdn.NameURLRedirect, - } +func ExpandArmCdnEndpointActionUrlRedirect(input []interface{}) (*[]cdn.BasicDeliveryRuleAction, error) { + output := make([]cdn.BasicDeliveryRuleAction, 0) - params := cdn.URLRedirectActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRedirectActionParameters"), - RedirectType: cdn.RedirectType(ura["redirect_type"].(string)), - } + for _, v := range input { + item := v.(map[string]interface{}) - if destProt := ura["protocol"]; destProt.(string) != "" { - params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) - } + params := cdn.URLRedirectActionParameters{ + OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRedirectActionParameters"), + RedirectType: cdn.RedirectType(item["redirect_type"].(string)), + } - if hostname := ura["hostname"]; hostname.(string) != "" { - params.CustomHostname = utils.String(hostname.(string)) - } + if destProt := item["protocol"]; destProt.(string) != "" { + params.DestinationProtocol = cdn.DestinationProtocol(destProt.(string)) + } - if path := ura["path"]; path.(string) != "" { - params.CustomPath = utils.String(path.(string)) - } + if hostname := item["hostname"]; hostname.(string) != "" { + params.CustomHostname = utils.String(hostname.(string)) + } - if queryString := ura["query_string"]; queryString.(string) != "" { - params.CustomQueryString = utils.String(queryString.(string)) - } + if path := item["path"]; path.(string) != "" { + params.CustomPath = utils.String(path.(string)) + } - if fragment := ura["fragment"]; fragment.(string) != "" { - params.CustomFragment = utils.String(fragment.(string)) - } + if queryString := item["query_string"]; queryString.(string) != "" { + params.CustomQueryString = utils.String(queryString.(string)) + } - urlRedirectAction.Parameters = ¶ms + if fragment := item["fragment"]; fragment.(string) != "" { + params.CustomFragment = utils.String(fragment.(string)) + } + + output = append(output, cdn.URLRedirectAction{ + Name: cdn.NameURLRedirect, + Parameters: ¶ms, + }) + } - return &urlRedirectAction + return &output, nil } -func FlattenArmCdnEndpointActionUrlRedirect(ura *cdn.URLRedirectAction) map[string]interface{} { - res := make(map[string]interface{}, 1) +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!") + } - if params := ura.Parameters; params != nil { - res["redirect_type"] = string(params.RedirectType) + customHostname := "" + customPath := "" + fragment := "" + queryString := "" + protocol := "" + redirectType := "" - res["protocol"] = string(params.DestinationProtocol) + if params := action.Parameters; params != nil { + redirectType = string(params.RedirectType) + protocol = string(params.DestinationProtocol) if params.CustomHostname != nil { - res["hostname"] = *params.CustomHostname + customHostname = *params.CustomHostname } if params.CustomPath != nil { - res["path"] = *params.CustomPath + customPath = *params.CustomPath } if params.CustomQueryString != nil { - res["query_string"] = *params.CustomQueryString + queryString = *params.CustomQueryString } if params.CustomFragment != nil { - res["fragment"] = *params.CustomFragment + fragment = *params.CustomFragment } } - return res + 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 index f92c87b03a70..73709ffffff2 100644 --- a/azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go +++ b/azurerm/internal/services/cdn/deliveryruleactions/url_rewrite.go @@ -1,6 +1,8 @@ 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" @@ -31,31 +33,52 @@ func URLRewrite() *schema.Resource { } } -func ExpandArmCdnEndpointActionURLRewrite(ura map[string]interface{}) *cdn.URLRewriteAction { - return &cdn.URLRewriteAction{ - Name: cdn.NameURLRewrite, - Parameters: &cdn.URLRewriteActionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlRewriteActionParameters"), - SourcePattern: utils.String(ura["source_pattern"].(string)), - Destination: utils.String(ura["destination"].(string)), - PreserveUnmatchedPath: utils.Bool(ura["preserve_unmatched_path"].(bool)), - }, +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(ura *cdn.URLRewriteAction) map[string]interface{} { - res := make(map[string]interface{}, 1) +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!") + } - if params := ura.Parameters; params != nil { - res["source_pattern"] = *params.SourcePattern - res["destination"] = *params.Destination + 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 { - res["preserve_unmatched_path"] = *params.PreserveUnmatchedPath - } else { - res["preserve_unmatched_path"] = true + preserveUnmatchedPath = *params.PreserveUnmatchedPath } } - return res + 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 index 36b25827d512..ca9f7e3f585b 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/cookies.go @@ -1,6 +1,8 @@ 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" @@ -63,55 +65,74 @@ func Cookies() *schema.Resource { } } -func ExpandArmCdnEndpointConditionCookies(cc map[string]interface{}) *cdn.DeliveryRuleCookiesCondition { - cookiesCondition := cdn.DeliveryRuleCookiesCondition{ - Name: cdn.NameCookies, - Parameters: &cdn.CookiesMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleCookiesConditionParameters"), - Selector: utils.String(cc["selector"].(string)), - Operator: cdn.CookiesOperator(cc["operator"].(string)), - NegateCondition: utils.Bool(cc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(cc["match_values"].(*schema.Set).List()), - }, - } +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 := cc["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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 } - cookiesCondition.Parameters.Transforms = &transforms + + output = append(output, cookiesCondition) } - return &cookiesCondition + return output } -func FlattenArmCdnEndpointConditionCookies(cc *cdn.DeliveryRuleCookiesCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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 := cc.Parameters; params != nil { + if params := condition.Parameters; params != nil { if params.Selector != nil { - res["selector"] = *params.Selector + selector = *params.Selector } - res["operator"] = string(params.Operator) + operator = string(params.Operator) if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index 6d6c5c7f4584..056ba8a9c55a 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/device.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/device.go @@ -1,6 +1,8 @@ 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" @@ -41,34 +43,51 @@ func Device() *schema.Resource { } } -func ExpandArmCdnEndpointConditionDevice(dc map[string]interface{}) *cdn.DeliveryRuleIsDeviceCondition { - return &cdn.DeliveryRuleIsDeviceCondition{ - Name: cdn.NameHTTPVersion, - Parameters: &cdn.IsDeviceMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleIsDeviceConditionParameters"), - Operator: utils.String(dc["operator"].(string)), - NegateCondition: utils.Bool(dc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(dc["match_values"].(*schema.Set).List()), - }, +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(dc *cdn.DeliveryRuleIsDeviceCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := dc.Parameters; params != nil { + operator := "" + matchValues := make([]interface{}, 0) + negateCondition := false + if params := condition.Parameters; params != nil { if params.Operator != nil { - res["operator"] = *params.Operator + operator = *params.Operator } if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = utils.FlattenStringSlice(params.MatchValues) } } - return res + 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 index 4c821e5d354e..34a8ed826dea 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/http_version.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/http_version.go @@ -1,6 +1,8 @@ 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" @@ -43,34 +45,51 @@ func HTTPVersion() *schema.Resource { } } -func ExpandArmCdnEndpointConditionHTTPVersion(hvc map[string]interface{}) *cdn.DeliveryRuleHTTPVersionCondition { - return &cdn.DeliveryRuleHTTPVersionCondition{ - Name: cdn.NameHTTPVersion, - Parameters: &cdn.HTTPVersionMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleHttpVersionConditionParameters"), - Operator: utils.String(hvc["operator"].(string)), - NegateCondition: utils.Bool(hvc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(hvc["match_values"].(*schema.Set).List()), - }, +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(hvc *cdn.DeliveryRuleHTTPVersionCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := hvc.Parameters; params != nil { + operator := "" + matchValues := make([]interface{}, 0) + negateCondition := false + if params := condition.Parameters; params != nil { if params.Operator != nil { - res["operator"] = *params.Operator + operator = *params.Operator } if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = utils.FlattenStringSlice(params.MatchValues) } } - return res + 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 index fe6d903ab79b..8f0d90bed37e 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/post_arg.go @@ -1,6 +1,8 @@ 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" @@ -63,55 +65,76 @@ func PostArg() *schema.Resource { } } -func ExpandArmCdnEndpointConditionPostArg(pac map[string]interface{}) *cdn.DeliveryRulePostArgsCondition { - cookiesCondition := cdn.DeliveryRulePostArgsCondition{ - Name: cdn.NameCookies, - Parameters: &cdn.PostArgsMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRulePostArgsConditionParameters"), - Selector: utils.String(pac["selector"].(string)), - Operator: cdn.PostArgsOperator(pac["operator"].(string)), - NegateCondition: utils.Bool(pac["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(pac["match_values"].(*schema.Set).List()), - }, - } +func ExpandArmCdnEndpointConditionPostArg(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) - if rawTransforms := pac["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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()), + }, } - cookiesCondition.Parameters.Transforms = &transforms + + 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 &cookiesCondition + return output } -func FlattenArmCdnEndpointConditionPostArg(pac *cdn.DeliveryRulePostArgsCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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 := pac.Parameters; params != nil { + if params := condition.Parameters; params != nil { if params.Selector != nil { - res["selector"] = *params.Selector + selector = *params.Selector } - res["operator"] = string(params.Operator) + operator = string(params.Operator) if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index fccb7dc85a2b..af6733a67157 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/query_string.go @@ -1,6 +1,8 @@ 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" @@ -57,50 +59,68 @@ func QueryString() *schema.Resource { } } -func ExpandArmCdnEndpointConditionQueryString(qsc map[string]interface{}) *cdn.DeliveryRuleQueryStringCondition { - queryStringCondition := cdn.DeliveryRuleQueryStringCondition{ - Name: cdn.NameQueryString, - Parameters: &cdn.QueryStringMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleQueryStringConditionParameters"), - Operator: cdn.QueryStringOperator(qsc["operator"].(string)), - NegateCondition: utils.Bool(qsc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(qsc["match_values"].(*schema.Set).List()), - }, - } +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 := qsc["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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 } - queryStringCondition.Parameters.Transforms = &transforms + + output = append(output, queryStringCondition) } - return &queryStringCondition + return output } -func FlattenArmCdnEndpointConditionQueryString(qsc *cdn.DeliveryRuleQueryStringCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := qsc.Parameters; params != nil { - res["operator"] = string(params.Operator) + 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 { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index 7b5277a21f9f..1bd77cc458f2 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/remote_address.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/remote_address.go @@ -1,6 +1,8 @@ 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" @@ -39,34 +41,50 @@ func RemoteAddress() *schema.Resource { } } -func ExpandArmCdnEndpointConditionRemoteAddress(qsc map[string]interface{}) *cdn.DeliveryRuleRemoteAddressCondition { - remoteAddressCondition := cdn.DeliveryRuleRemoteAddressCondition{ - Name: cdn.NameRemoteAddress, - Parameters: &cdn.RemoteAddressMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRemoteAddressConditionParameters"), - Operator: cdn.RemoteAddressOperator(qsc["operator"].(string)), - NegateCondition: utils.Bool(qsc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(qsc["match_values"].(*schema.Set).List()), - }, +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 &remoteAddressCondition + return output } -func FlattenArmCdnEndpointConditionRemoteAddress(qsc *cdn.DeliveryRuleRemoteAddressCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := qsc.Parameters; params != nil { - res["operator"] = string(params.Operator) + operator := "" + negateCondition := false + matchValues := make([]interface{}, 0) + if params := condition.Parameters; params != nil { + operator = string(params.Operator) if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = utils.FlattenStringSlice(params.MatchValues) } } - return res + 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 index f06dde1a64cc..49dfcfabb5ff 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_body.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_body.go @@ -1,6 +1,8 @@ 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" @@ -57,50 +59,68 @@ func RequestBody() *schema.Resource { } } -func ExpandArmCdnEndpointConditionRequestBody(rbc map[string]interface{}) *cdn.DeliveryRuleRequestBodyCondition { - queryStringCondition := cdn.DeliveryRuleRequestBodyCondition{ - Name: cdn.NameRequestBody, - Parameters: &cdn.RequestBodyMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestBodyConditionParameters"), - Operator: cdn.RequestBodyOperator(rbc["operator"].(string)), - NegateCondition: utils.Bool(rbc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(rbc["match_values"].(*schema.Set).List()), - }, - } +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 := rbc["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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 } - queryStringCondition.Parameters.Transforms = &transforms + + output = append(output, queryStringCondition) } - return &queryStringCondition + return output } -func FlattenArmCdnEndpointConditionRequestBody(rbc *cdn.DeliveryRuleRequestBodyCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := rbc.Parameters; params != nil { - res["operator"] = string(params.Operator) + 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 { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index 1adf2fd8e34e..28cf27d1bbf6 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_header.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_header.go @@ -63,27 +63,34 @@ func RequestHeader() *schema.Resource { } } -func ExpandArmCdnEndpointConditionRequestHeader(cc map[string]interface{}) *cdn.DeliveryRuleRequestHeaderCondition { - requestHeaderCondition := cdn.DeliveryRuleRequestHeaderCondition{ - Name: cdn.NameRequestHeader, - Parameters: &cdn.RequestHeaderMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestHeaderConditionParameters"), - Selector: utils.String(cc["selector"].(string)), - Operator: cdn.RequestHeaderOperator(cc["operator"].(string)), - NegateCondition: utils.Bool(cc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(cc["match_values"].(*schema.Set).List()), - }, - } +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 := cc["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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 } - requestHeaderCondition.Parameters.Transforms = &transforms + + output = append(output, requestHeaderCondition) } - return &requestHeaderCondition + return output } func FlattenArmCdnEndpointConditionRequestHeader(cc *cdn.DeliveryRuleRequestHeaderCondition) map[string]interface{} { diff --git a/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go b/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go index ceebb8bae824..991e2cee379e 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_method.go @@ -1,6 +1,8 @@ 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" @@ -45,34 +47,51 @@ func RequestMethod() *schema.Resource { } } -func ExpandArmCdnEndpointConditionRequestMethod(rmc map[string]interface{}) *cdn.DeliveryRuleRequestMethodCondition { - return &cdn.DeliveryRuleRequestMethodCondition{ - Name: cdn.NameRequestMethod, - Parameters: &cdn.RequestMethodMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestMethodConditionParameters"), - Operator: utils.String(rmc["operator"].(string)), - NegateCondition: utils.Bool(rmc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(rmc["match_values"].(*schema.Set).List()), - }, +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(rmc *cdn.DeliveryRuleRequestMethodCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := rmc.Parameters; params != nil { + operator := "" + negateCondition := false + matchValues := make([]interface{}, 0) + if params := condition.Parameters; params != nil { if params.Operator != nil { - res["operator"] = *params.Operator + operator = *params.Operator } if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = utils.FlattenStringSlice(params.MatchValues) } } - return res + 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 index 0ec91021621b..7dd20ebcb3f1 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_scheme.go @@ -1,6 +1,8 @@ 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" @@ -41,39 +43,57 @@ func RequestScheme() *schema.Resource { } } -func ExpandArmCdnEndpointConditionRequestScheme(rsc map[string]interface{}) *cdn.DeliveryRuleRequestSchemeCondition { - requestSchemeCondition := cdn.DeliveryRuleRequestSchemeCondition{ - Name: cdn.NameRequestScheme, - Parameters: &cdn.RequestSchemeMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestSchemeConditionParameters"), - NegateCondition: utils.Bool(rsc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(rsc["match_values"].(*schema.Set).List()), - }, - } +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 := rsc["operator"]; operator.(string) != "" { - requestSchemeCondition.Parameters.Operator = utils.String(operator.(string)) + if operator := item["operator"]; operator.(string) != "" { + requestSchemeCondition.Parameters.Operator = utils.String(operator.(string)) + } + + output = append(output, requestSchemeCondition) } - return &requestSchemeCondition + return output } -func FlattenArmCdnEndpointConditionRequestScheme(condition *cdn.DeliveryRuleRequestSchemeCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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 { - res["operator"] = *params.Operator + operator = *params.Operator } if params.NegateCondition != nil { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = utils.FlattenStringSlice(params.MatchValues) } } - return res + 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 index d647403011c0..2bcc17f7ad26 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/request_uri.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/request_uri.go @@ -1,6 +1,8 @@ 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" @@ -57,50 +59,67 @@ func RequestURI() *schema.Resource { } } -func ExpandArmCdnEndpointConditionRequestURI(ruc map[string]interface{}) *cdn.DeliveryRuleRequestURICondition { - requestURICondition := cdn.DeliveryRuleRequestURICondition{ - Name: cdn.NameRequestURI, - Parameters: &cdn.RequestURIMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleRequestUriConditionParameters"), - Operator: cdn.RequestURIOperator(ruc["operator"].(string)), - NegateCondition: utils.Bool(ruc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(ruc["match_values"].(*schema.Set).List()), - }, - } +func ExpandArmCdnEndpointConditionRequestURI(input []interface{}) []cdn.BasicDeliveryRuleCondition { + output := make([]cdn.BasicDeliveryRuleCondition, 0) - if rawTransforms := ruc["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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()), + }, } - requestURICondition.Parameters.Transforms = &transforms + + 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 &requestURICondition + return output } -func FlattenArmCdnEndpointConditionRequestURI(ruc *cdn.DeliveryRuleRequestURICondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := ruc.Parameters; params != nil { - res["operator"] = string(params.Operator) + 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 { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index 830073ed5f54..99e811f472e6 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/url_file_extension.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_extension.go @@ -1,6 +1,8 @@ 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" @@ -57,50 +59,68 @@ func URLFileExtension() *schema.Resource { } } -func ExpandArmCdnEndpointConditionURLFileExtension(ufec map[string]interface{}) *cdn.DeliveryRuleURLFileExtensionCondition { - requestURICondition := cdn.DeliveryRuleURLFileExtensionCondition{ - Name: cdn.NameURLFileExtension, - Parameters: &cdn.URLFileExtensionMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlFileExtensionMatchConditionParameters"), - Operator: cdn.URLFileExtensionOperator(ufec["operator"].(string)), - NegateCondition: utils.Bool(ufec["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(ufec["match_values"].(*schema.Set).List()), - }, - } +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 := ufec["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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 } - requestURICondition.Parameters.Transforms = &transforms + + output = append(output, requestURICondition) } - return &requestURICondition + return output } -func FlattenArmCdnEndpointConditionURLFileExtension(ufec *cdn.DeliveryRuleURLFileExtensionCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := ufec.Parameters; params != nil { - res["operator"] = string(params.Operator) + 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 { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index 78b3d1d43610..ca4cd257b55f 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/url_file_name.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_file_name.go @@ -1,6 +1,8 @@ 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" @@ -57,50 +59,68 @@ func URLFileName() *schema.Resource { } } -func ExpandArmCdnEndpointConditionURLFileName(ufnc map[string]interface{}) *cdn.DeliveryRuleURLFileNameCondition { - requestURICondition := cdn.DeliveryRuleURLFileNameCondition{ - Name: cdn.NameURLFileName, - Parameters: &cdn.URLFileNameMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlFilenameConditionParameters"), - Operator: cdn.URLFileNameOperator(ufnc["operator"].(string)), - NegateCondition: utils.Bool(ufnc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(ufnc["match_values"].(*schema.Set).List()), - }, - } +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 := ufnc["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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 } - requestURICondition.Parameters.Transforms = &transforms + + output = append(output, requestURICondition) } - return &requestURICondition + return output } -func FlattenArmCdnEndpointConditionURLFileName(ufnc *cdn.DeliveryRuleURLFileNameCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := ufnc.Parameters; params != nil { - res["operator"] = string(params.Operator) + 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 { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index 69d6da966368..cfd1cab88f17 100644 --- a/azurerm/internal/services/cdn/deliveryruleconditions/url_path.go +++ b/azurerm/internal/services/cdn/deliveryruleconditions/url_path.go @@ -1,6 +1,8 @@ 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" @@ -57,50 +59,68 @@ func URLPath() *schema.Resource { } } -func ExpandArmCdnEndpointConditionURLPath(upc map[string]interface{}) *cdn.DeliveryRuleURLPathCondition { - requestURICondition := cdn.DeliveryRuleURLPathCondition{ - Name: cdn.NameURLPath, - Parameters: &cdn.URLPathMatchConditionParameters{ - OdataType: utils.String("Microsoft.Azure.Cdn.Models.DeliveryRuleUrlPathMatchConditionParameters"), - Operator: cdn.URLPathOperator(upc["operator"].(string)), - NegateCondition: utils.Bool(upc["negate_condition"].(bool)), - MatchValues: utils.ExpandStringSlice(upc["match_values"].(*schema.Set).List()), - }, - } +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 := upc["transforms"].([]interface{}); len(rawTransforms) != 0 { - transforms := make([]cdn.Transform, 0) - for _, t := range rawTransforms { - transforms = append(transforms, cdn.Transform(t.(string))) + 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 } - requestURICondition.Parameters.Transforms = &transforms + + output = append(output, requestURICondition) } - return &requestURICondition + return output } -func FlattenArmCdnEndpointConditionURLPath(upc *cdn.DeliveryRuleURLPathCondition) map[string]interface{} { - res := make(map[string]interface{}, 1) +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") + } - if params := upc.Parameters; params != nil { - res["operator"] = string(params.Operator) + 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 { - res["negate_condition"] = *params.NegateCondition + negateCondition = *params.NegateCondition } if params.MatchValues != nil { - res["match_values"] = schema.NewSet(schema.HashString, utils.FlattenStringSlice(params.MatchValues)) + matchValues = 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 + 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 index 2d402be893d7..628ecc801abe 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -165,8 +165,7 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver Order: utils.Int32(int32(rule["order"].(int))), } - conditions := expandDeliveryRuleConditions(rule) - deliveryRule.Conditions = &conditions + deliveryRule.Conditions = expandDeliveryRuleConditions(rule) actions, err := expandDeliveryRuleActions(rule) if err != nil { @@ -177,301 +176,309 @@ func expandArmCdnEndpointDeliveryRule(rule map[string]interface{}) (*cdn.Deliver return &deliveryRule, nil } -func expandDeliveryRuleConditions(rule map[string]interface{}) []cdn.BasicDeliveryRuleCondition { +func expandDeliveryRuleConditions(input map[string]interface{}) *[]cdn.BasicDeliveryRuleCondition { conditions := make([]cdn.BasicDeliveryRuleCondition, 0) - if ccs := rule["cookies_condition"].([]interface{}); len(ccs) > 0 { - for _, cc := range ccs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionCookies(cc.(map[string]interface{}))) - } - } - - if hvcs := rule["http_version_condition"].([]interface{}); len(hvcs) > 0 { - for _, hvc := range hvcs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionHTTPVersion(hvc.(map[string]interface{}))) - } - } - - if rsc := rule["device_condition"].([]interface{}); len(rsc) > 0 { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionDevice(rsc[0].(map[string]interface{}))) + // @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, } - if pacs := rule["post_arg_condition"].([]interface{}); len(pacs) > 0 { - for _, pac := range pacs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionPostArg(pac.(map[string]interface{}))) - } - } - - if qscs := rule["query_string_condition"].([]interface{}); len(qscs) > 0 { - for _, qsc := range qscs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionQueryString(qsc.(map[string]interface{}))) - } - } - - if racs := rule["remote_address_condition"].([]interface{}); len(racs) > 0 { - for _, rac := range racs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRemoteAddress(rac.(map[string]interface{}))) - } - } - - if rbcs := rule["request_body_condition"].([]interface{}); len(rbcs) > 0 { - for _, rbc := range rbcs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestBody(rbc.(map[string]interface{}))) - } - } - - if rhcs := rule["request_header_condition"].([]interface{}); len(rhcs) > 0 { - for _, rhc := range rhcs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestHeader(rhc.(map[string]interface{}))) - } + for schemaKey, expandFunc := range conditionTypes { + raw := input[schemaKey].([]interface{}) + expanded := expandFunc(raw) + conditions = append(conditions, expanded...) } - if rsc := rule["request_method_condition"].([]interface{}); len(rsc) > 0 { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestMethod(rsc[0].(map[string]interface{}))) - } - - if rsc := rule["request_scheme_condition"].([]interface{}); len(rsc) > 0 { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestScheme(rsc[0].(map[string]interface{}))) - } - - if rucs := rule["request_uri_condition"].([]interface{}); len(rucs) > 0 { - for _, ruc := range rucs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionRequestURI(ruc.(map[string]interface{}))) - } - } - - if ufecs := rule["url_file_extension_condition"].([]interface{}); len(ufecs) > 0 { - for _, ufec := range ufecs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionURLFileExtension(ufec.(map[string]interface{}))) - } - } - - if ufncs := rule["url_file_name_condition"].([]interface{}); len(ufncs) > 0 { - for _, ufnc := range ufncs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionURLFileName(ufnc.(map[string]interface{}))) - } - } - - if upcs := rule["url_path_condition"].([]interface{}); len(upcs) > 0 { - for _, upc := range upcs { - conditions = append(conditions, *deliveryruleconditions.ExpandArmCdnEndpointConditionURLPath(upc.(map[string]interface{}))) - } - } - - return conditions + return &conditions } -func expandDeliveryRuleActions(rule map[string]interface{}) ([]cdn.BasicDeliveryRuleAction, error) { +func expandDeliveryRuleActions(input map[string]interface{}) ([]cdn.BasicDeliveryRuleAction, error) { actions := make([]cdn.BasicDeliveryRuleAction, 0) - if cea := rule["cache_expiration_action"].([]interface{}); len(cea) > 0 { - action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheExpiration(cea[0].(map[string]interface{})) - if err != nil { - return nil, err - } - actions = append(actions, *action) + 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, } - if ckqsa := rule["cache_key_query_string_action"].([]interface{}); len(ckqsa) > 0 { - action, err := deliveryruleactions.ExpandArmCdnEndpointActionCacheKeyQueryString(ckqsa[0].(map[string]interface{})) + for schemaKey, expandFunc := range actionTypes { + raw := input[schemaKey].([]interface{}) + expanded, err := expandFunc(raw) if err != nil { return nil, err } - actions = append(actions, *action) - } - - if mrha := rule["modify_request_header_action"].([]interface{}); len(mrha) > 0 { - for _, rawAction := range mrha { - actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionModifyRequestHeader(rawAction.(map[string]interface{}))) - } - } - - if mrha := rule["modify_response_header_action"].([]interface{}); len(mrha) > 0 { - for _, rawAction := range mrha { - actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionModifyResponseHeader(rawAction.(map[string]interface{}))) - } - } - - if ura := rule["url_redirect_action"].([]interface{}); len(ura) > 0 { - actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionUrlRedirect(ura[0].(map[string]interface{}))) - } - if ura := rule["url_rewrite_action"].([]interface{}); len(ura) > 0 { - actions = append(actions, *deliveryruleactions.ExpandArmCdnEndpointActionURLRewrite(ura[0].(map[string]interface{}))) + actions = append(actions, *expanded...) } return actions, nil } -func flattenArmCdnEndpointDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { - res := make(map[string]interface{}) - - if deliveryRule == nil { - return res - } - +func flattenArmCdnEndpointDeliveryRule(deliveryRule cdn.DeliveryRule) (*map[string]interface{}, error) { + name := "" if deliveryRule.Name != nil { - res["name"] = *deliveryRule.Name + name = *deliveryRule.Name } + order := -1 if deliveryRule.Order != nil { - res["order"] = *deliveryRule.Order + order = int(*deliveryRule.Order) } - flattenDeliveryRuleConditions(deliveryRule.Conditions, &res) - - flattenDeliveryRuleActions(deliveryRule.Actions, &res) - - return res -} - -func flattenDeliveryRuleActions(actions *[]cdn.BasicDeliveryRuleAction, res *map[string]interface{}) { - if actions == nil { - return + output := map[string]interface{}{ + "name": name, + "order": order, } - for _, basicDeliveryRuleAction := range *actions { - if action, isCacheExpirationAction := basicDeliveryRuleAction.AsDeliveryRuleCacheExpirationAction(); isCacheExpirationAction { - (*res)["cache_expiration_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheExpiration(action)} - continue - } - - if action, isCacheKeyQueryStringAction := basicDeliveryRuleAction.AsDeliveryRuleCacheKeyQueryStringAction(); isCacheKeyQueryStringAction { - (*res)["cache_key_query_string_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionCacheKeyQueryString(action)} - continue - } - - if action, isModifyRequestHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleRequestHeaderAction(); isModifyRequestHeaderAction { - (*res)["modify_request_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyRequestHeader(action)} - continue - } - - if action, isModifyResponseHeaderAction := basicDeliveryRuleAction.AsDeliveryRuleResponseHeaderAction(); isModifyResponseHeaderAction { - (*res)["modify_response_header_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionModifyResponseHeader(action)} - continue - } - - if action, isURLRedirectAction := basicDeliveryRuleAction.AsURLRedirectAction(); isURLRedirectAction { - (*res)["url_redirect_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionUrlRedirect(action)} - continue - } - - if action, isURLRewriteAction := basicDeliveryRuleAction.AsURLRewriteAction(); isURLRewriteAction { - (*res)["url_rewrite_action"] = []interface{}{deliveryruleactions.FlattenArmCdnEndpointActionURLRewrite(action)} - continue - } + conditions, err := flattenDeliveryRuleConditions(deliveryRule.Conditions) + if err != nil { + return nil, err } -} -func flattenDeliveryRuleConditions(conditions *[]cdn.BasicDeliveryRuleCondition, res *map[string]interface{}) { - if conditions == nil { - return + for key, value := range *conditions { + output[key] = value } - for _, basicDeliveryRuleCondition := range *conditions { - if condition, isCookiesCondition := basicDeliveryRuleCondition.AsDeliveryRuleCookiesCondition(); isCookiesCondition { - if _, ok := (*res)["cookies_condition"]; !ok { - (*res)["cookies_condition"] = []map[string]interface{}{} - } - - (*res)["cookies_condition"] = append((*res)["cookies_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionCookies(condition)) - continue - } - - if condition, isHTTPVersionCondition := basicDeliveryRuleCondition.AsDeliveryRuleHTTPVersionCondition(); isHTTPVersionCondition { - if _, ok := (*res)["http_version_condition"]; !ok { - (*res)["http_version_condition"] = []map[string]interface{}{} - } - - (*res)["http_version_condition"] = append((*res)["http_version_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionHTTPVersion(condition)) - continue - } - - if condition, isDeviceCondition := basicDeliveryRuleCondition.AsDeliveryRuleIsDeviceCondition(); isDeviceCondition { - (*res)["device_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionDevice(condition)} - continue - } + actions, err := flattenDeliveryRuleActions(deliveryRule.Actions) + for key, value := range *actions { + output[key] = value + } - if condition, isPostArgCondition := basicDeliveryRuleCondition.AsDeliveryRulePostArgsCondition(); isPostArgCondition { - if _, ok := (*res)["post_arg_condition"]; !ok { - (*res)["post_arg_condition"] = []map[string]interface{}{} - } + return &output, nil +} - (*res)["post_arg_condition"] = append((*res)["post_arg_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionPostArg(condition)) - continue - } +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 + }, + }, + } - if condition, isQueryStringCondition := basicDeliveryRuleCondition.AsDeliveryRuleQueryStringCondition(); isQueryStringCondition { - if _, ok := (*res)["query_string_condition"]; !ok { - (*res)["query_string_condition"] = []map[string]interface{}{} - } + // 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) + } - (*res)["query_string_condition"] = append((*res)["query_string_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionQueryString(condition)) - continue - } + // intentionally bail here now we have defaults populated + if actions == nil { + return &output, nil + } - if condition, isRemoteAddressCondition := basicDeliveryRuleCondition.AsDeliveryRuleRemoteAddressCondition(); isRemoteAddressCondition { - if _, ok := (*res)["remote_address_condition"]; !ok { - (*res)["remote_address_condition"] = []map[string]interface{}{} + // 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 } - (*res)["remote_address_condition"] = append((*res)["remote_address_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRemoteAddress(condition)) - continue - } - - if condition, isRequestBodyCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestBodyCondition(); isRequestBodyCondition { - if _, ok := (*res)["request_body_condition"]; !ok { - (*res)["request_body_condition"] = []map[string]interface{}{} + mapped, err := actionType.flattenFunc(action) + if err != nil { + return nil, err } - (*res)["request_body_condition"] = append((*res)["request_body_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestBody(condition)) - continue - } - - if condition, isRequestMethodCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestMethodCondition(); isRequestMethodCondition { - (*res)["request_method_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestMethod(condition)} - continue - } - - if condition, isRequestSchemeCondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestSchemeCondition(); isRequestSchemeCondition { - (*res)["request_scheme_condition"] = []interface{}{deliveryruleconditions.FlattenArmCdnEndpointConditionRequestScheme(condition)} - continue + output[schemaKey] = append(output[schemaKey], mapped) + break } + } - if condition, isRequestURICondition := basicDeliveryRuleCondition.AsDeliveryRuleRequestURICondition(); isRequestURICondition { - if _, ok := (*res)["request_uri_condition"]; !ok { - (*res)["request_uri_condition"] = []map[string]interface{}{} - } + return &output, nil +} - (*res)["request_uri_condition"] = append((*res)["request_uri_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionRequestURI(condition)) - continue - } +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 + }, + }, + } - if condition, isURLFileExtensionCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLFileExtensionCondition(); isURLFileExtensionCondition { - if _, ok := (*res)["url_file_extension_condition"]; !ok { - (*res)["url_file_extension_condition"] = []map[string]interface{}{} - } + // 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) + } - (*res)["url_file_extension_condition"] = append((*res)["url_file_extension_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileExtension(condition)) - continue - } + // intentionally bail here now we have defaults populated + if conditions == nil { + return &output, nil + } - if condition, isURLFileNameExtension := basicDeliveryRuleCondition.AsDeliveryRuleURLFileNameCondition(); isURLFileNameExtension { - if _, ok := (*res)["url_file_name_condition"]; !ok { - (*res)["url_file_name_condition"] = []map[string]interface{}{} + // 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 } - (*res)["url_file_name_condition"] = append((*res)["url_file_name_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLFileName(condition)) - continue - } - - if condition, isURLPathCondition := basicDeliveryRuleCondition.AsDeliveryRuleURLPathCondition(); isURLPathCondition { - if _, ok := (*res)["url_path_condition"]; !ok { - (*res)["url_path_condition"] = []map[string]interface{}{} + mapped, err := conditionType.flattenFunc(condition) + if err != nil { + return nil, err } - (*res)["url_path_condition"] = append((*res)["url_path_condition"].([]map[string]interface{}), deliveryruleconditions.FlattenArmCdnEndpointConditionURLPath(condition)) - continue + 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 index d2c590421220..a481d4db9bbd 100644 --- a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go @@ -73,14 +73,7 @@ func expandArmCdnEndpointGlobalDeliveryRule(rule map[string]interface{}) (*cdn.D return &deliveryRule, nil } -func flattenArmCdnEndpointGlobalDeliveryRule(deliveryRule *cdn.DeliveryRule) map[string]interface{} { - res := make(map[string]interface{}) - - if deliveryRule == nil { - return res - } - - flattenDeliveryRuleActions(deliveryRule.Actions, &res) - - return res +func flattenArmCdnEndpointGlobalDeliveryRule(deliveryRule cdn.DeliveryRule) (*map[string]interface{}, error) { + // intentionally wrapping this incase this expands + return flattenDeliveryRuleActions(deliveryRule.Actions) } diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index a05869ce6501..5311bae9fd14 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -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" @@ -218,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 := 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) - } + 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)) @@ -243,7 +240,7 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro contentTypes := expandArmCdnEndpointContentTypesToCompress(d) t := d.Get("tags").(map[string]interface{}) - geoFilters, err := expandArmCdnEndpointGeoFilters(d) + geoFilters, err := expandCdnEndpointGeoFilters(d) if err != nil { return fmt.Errorf("Error expanding `geo_filter`: %s", err) } @@ -286,18 +283,18 @@ func resourceArmCdnEndpointCreate(d *schema.ResourceData, meta interface{}) erro } if profile.Sku != nil { - deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + 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 { - endpoint.DeliveryPolicy = deliveryPolicy - } else { - if 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) - } + 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) @@ -340,7 +337,7 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro contentTypes := expandArmCdnEndpointContentTypesToCompress(d) t := d.Get("tags").(map[string]interface{}) - geoFilters, err := expandArmCdnEndpointGeoFilters(d) + geoFilters, err := expandCdnEndpointGeoFilters(d) if err != nil { return fmt.Errorf("Error expanding `geo_filter`: %s", err) } @@ -378,18 +375,18 @@ func resourceArmCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) erro } if profile.Sku != nil { - deliveryPolicy, err := expandArmCdnEndpointDeliveryPolicy(d) + 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 { - endpoint.DeliveryPolicy = deliveryPolicy - } else { - if 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) - } + 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) @@ -460,11 +457,14 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting `origin`: %+v", err) } - globalDeliveryRules, deliveryRules := flattenArmCdnEndpointDeliveryPolicy(props.DeliveryPolicy) - if err := d.Set("global_delivery_rule", globalDeliveryRules); err != nil { + 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", deliveryRules); err != nil { + if err := d.Set("delivery_rule", flattenedDeliveryPolicies.deliveryRules); err != nil { return fmt.Errorf("Error setting `delivery_rule`: %+v", err) } } @@ -500,7 +500,7 @@ func resourceArmCdnEndpointDelete(d *schema.ResourceData, meta interface{}) erro return nil } -func expandArmCdnEndpointGeoFilters(d *schema.ResourceData) (*[]cdn.GeoFilter, error) { +func expandCdnEndpointGeoFilters(d *schema.ResourceData) (*[]cdn.GeoFilter, error) { filters := make([]cdn.GeoFilter, 0) inputFilters := d.Get("geo_filter").([]interface{}) @@ -642,56 +642,65 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface return results } -func expandArmCdnEndpointDeliveryPolicy(d *schema.ResourceData) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { +func expandArmCdnEndpointDeliveryPolicy(globalRulesRaw []interface{}, deliveryRulesRaw []interface{}) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { deliveryRules := make([]cdn.DeliveryRule, 0) deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{ Description: utils.String(""), Rules: &deliveryRules, } - globalRules := d.Get("global_delivery_rule").([]interface{}) - if len(globalRules) == 1 { - globRule, err := expandArmCdnEndpointGlobalDeliveryRule(globalRules[0].(map[string]interface{})) + if len(globalRulesRaw) > 0 { + ruleRaw := globalRulesRaw[0].(map[string]interface{}) + rule, err := expandArmCdnEndpointGlobalDeliveryRule(ruleRaw) if err != nil { return nil, err } - deliveryRules = append(deliveryRules, *globRule) + deliveryRules = append(deliveryRules, *rule) } - rules := d.Get("delivery_rule").([]interface{}) - if len(rules) == 0 { - return &deliveryPolicy, nil - } - - for _, rule := range rules { - delRule, err := expandArmCdnEndpointDeliveryRule(rule.(map[string]interface{})) + for _, ruleV := range deliveryRulesRaw { + ruleRaw := ruleV.(map[string]interface{}) + rule, err := expandArmCdnEndpointDeliveryRule(ruleRaw) if err != nil { return nil, err } - deliveryRules = append(deliveryRules, *delRule) + deliveryRules = append(deliveryRules, *rule) } return &deliveryPolicy, nil } -func flattenArmCdnEndpointDeliveryPolicy(deliveryPolicy *cdn.EndpointPropertiesUpdateParametersDeliveryPolicy) ([]interface{}, []interface{}) { - if deliveryPolicy == nil { - return nil, 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 } - globalDeliveryRules := make([]interface{}, 0) - for _, rule := range *deliveryPolicy.Rules { - if *rule.Order == 0 { - globalDeliveryRules = append(globalDeliveryRules, flattenArmCdnEndpointGlobalDeliveryRule(&rule)) + for _, rule := range *input.Rules { + if rule.Order == nil { + continue } - } - deliveryRules := make([]interface{}, 0) - for _, rule := range *deliveryPolicy.Rules { - if *rule.Order != 0 { - deliveryRules = append(deliveryRules, flattenArmCdnEndpointDeliveryRule(&rule)) + flattenedRule, err := flattenArmCdnEndpointGlobalDeliveryRule(rule) + if err != nil { + return nil, err } + + if int(*rule.Order) == 0 { + output.globalDeliveryRules = append(output.globalDeliveryRules, flattenedRule) + continue + } + + output.deliveryRules = append(output.deliveryRules, flattenedRule) } - return globalDeliveryRules, deliveryRules + return &output, nil } From dac90afab8075690bb51a229531b2b568bdd7dd6 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 15 Apr 2020 15:47:02 +0200 Subject: [PATCH 89/92] r/cdn_endpoint: ensuring the nested blocks are always set --- .../services/cdn/resource_arm_cdn_endpoint.go | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index 5311bae9fd14..2a88f16d4816 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -533,11 +533,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) @@ -546,9 +544,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, + }) } } @@ -617,25 +618,32 @@ 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, + }) } } @@ -689,16 +697,21 @@ func flattenArmCdnEndpointDeliveryPolicy(input *cdn.EndpointPropertiesUpdatePara continue } - flattenedRule, err := flattenArmCdnEndpointGlobalDeliveryRule(rule) - if err != nil { - return nil, err - } - 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) } From 759f1997583b9ed68fe2c36f8bdedea595898798 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 15 Apr 2020 15:52:28 +0200 Subject: [PATCH 90/92] r/cdn_endpoint: making the schema internal --- .../services/cdn/endpoint_delivery_rule.go | 2 +- .../services/cdn/endpoint_global_delivery_rule.go | 14 +++++++++++--- .../services/cdn/resource_arm_cdn_endpoint.go | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 628ecc801abe..679f44933e90 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -10,7 +10,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func EndpointDeliveryRule() *schema.Schema { +func endpointDeliveryRule() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Optional: true, diff --git a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go index a481d4db9bbd..30f51d545344 100644 --- a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go @@ -7,7 +7,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func EndpointGlobalDeliveryRule() *schema.Schema { +func endpointGlobalDeliveryRule() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -74,6 +74,14 @@ func expandArmCdnEndpointGlobalDeliveryRule(rule map[string]interface{}) (*cdn.D } func flattenArmCdnEndpointGlobalDeliveryRule(deliveryRule cdn.DeliveryRule) (*map[string]interface{}, error) { - // intentionally wrapping this incase this expands - return flattenDeliveryRuleActions(deliveryRule.Actions) + actions, err := flattenDeliveryRuleActions(deliveryRule.Actions) + if err != nil { + return nil, err + } + + output := make(map[string]interface{}, 0) + 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 2a88f16d4816..d6ecd0b5d555 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -196,9 +196,9 @@ func resourceArmCdnEndpoint() *schema.Resource { Computed: true, }, - "global_delivery_rule": EndpointGlobalDeliveryRule(), + "global_delivery_rule": endpointGlobalDeliveryRule(), - "delivery_rule": EndpointDeliveryRule(), + "delivery_rule": endpointDeliveryRule(), "tags": tags.Schema(), }, From 4a7d1ce1d7c01efe3db5f18157653f81de0ce3e8 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 15 Apr 2020 16:04:21 +0200 Subject: [PATCH 91/92] r/cdn_endpoint: fixing up the docs --- .../tests/resource_arm_cdn_endpoint_test.go | 1 + website/docs/r/cdn_endpoint.html.markdown | 22 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) 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 192dcb6bd24f..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") diff --git a/website/docs/r/cdn_endpoint.html.markdown b/website/docs/r/cdn_endpoint.html.markdown index 411641751a52..b5d82da80461 100644 --- a/website/docs/r/cdn_endpoint.html.markdown +++ b/website/docs/r/cdn_endpoint.html.markdown @@ -13,34 +13,26 @@ 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" } } @@ -126,9 +118,9 @@ A `global_delivery_rule` block supports the following: A `delivery_rule` block supports the following: -* `name` - (Required) The Name which should be used for this TODO. +* `name` - (Required) The Name which should be used for this Delivery Rule. -* `order` - (Required) TODO. +* `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. From 94a8759cc1873358ba4447b3f29279929fd375df Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 15 Apr 2020 21:45:53 +0200 Subject: [PATCH 92/92] fix lintrest problems --- azurerm/helpers/validate/cdn.go | 4 ++-- .../services/cdn/endpoint_delivery_rule.go | 4 ++++ .../cdn/endpoint_global_delivery_rule.go | 2 +- .../services/cdn/resource_arm_cdn_endpoint.go | 16 ++++------------ 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/azurerm/helpers/validate/cdn.go b/azurerm/helpers/validate/cdn.go index 2368cf04ea1c..1581cdfe39bd 100644 --- a/azurerm/helpers/validate/cdn.go +++ b/azurerm/helpers/validate/cdn.go @@ -38,12 +38,12 @@ func RuleActionUrlRedirectQueryString() schema.SchemaValidateFunc { return nil, []error{fmt.Errorf("The Url Query String's max length is 100.")} } - re, _ := regexp.Compile("^[?&]") + 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.Compile("^[^?&]+=[^?&]+$") + kvre := regexp.MustCompile("^[^?&]+=[^?&]+$") kvs := strings.Split(querystring, "&") for _, kv := range kvs { if len(kv) > 0 && !kvre.MatchString(kv) { diff --git a/azurerm/internal/services/cdn/endpoint_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_delivery_rule.go index 679f44933e90..b0229be493cd 100644 --- a/azurerm/internal/services/cdn/endpoint_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_delivery_rule.go @@ -259,6 +259,10 @@ func flattenArmCdnEndpointDeliveryRule(deliveryRule cdn.DeliveryRule) (*map[stri } actions, err := flattenDeliveryRuleActions(deliveryRule.Actions) + if err != nil { + return nil, err + } + for key, value := range *actions { output[key] = value } diff --git a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go index 30f51d545344..3bd4c741e08b 100644 --- a/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go +++ b/azurerm/internal/services/cdn/endpoint_global_delivery_rule.go @@ -79,7 +79,7 @@ func flattenArmCdnEndpointGlobalDeliveryRule(deliveryRule cdn.DeliveryRule) (*ma return nil, err } - output := make(map[string]interface{}, 0) + output := make(map[string]interface{}) for key, value := range *actions { output[key] = value } diff --git a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go index 3883df78e7af..2572d5fe4412 100644 --- a/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go +++ b/azurerm/internal/services/cdn/resource_arm_cdn_endpoint.go @@ -238,13 +238,9 @@ 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{}) - geoFilters, err := expandCdnEndpointGeoFilters(d) - if err != nil { - return fmt.Errorf("Error expanding `geo_filter`: %s", err) - } - endpoint := cdn.Endpoint{ Location: &location, EndpointProperties: &cdn.EndpointProperties{ @@ -332,13 +328,9 @@ 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{}) - geoFilters, err := expandCdnEndpointGeoFilters(d) - if err != nil { - return fmt.Errorf("Error expanding `geo_filter`: %s", err) - } - endpoint := cdn.EndpointUpdateParameters{ EndpointPropertiesUpdateParameters: &cdn.EndpointPropertiesUpdateParameters{ ContentTypesToCompress: &contentTypes, @@ -497,7 +489,7 @@ func resourceArmCdnEndpointDelete(d *schema.ResourceData, meta interface{}) erro return nil } -func expandCdnEndpointGeoFilters(d *schema.ResourceData) (*[]cdn.GeoFilter, error) { +func expandCdnEndpointGeoFilters(d *schema.ResourceData) *[]cdn.GeoFilter { filters := make([]cdn.GeoFilter, 0) inputFilters := d.Get("geo_filter").([]interface{}) @@ -522,7 +514,7 @@ func expandCdnEndpointGeoFilters(d *schema.ResourceData) (*[]cdn.GeoFilter, erro filters = append(filters, filter) } - return &filters, nil + return &filters } func flattenCdnEndpointGeoFilters(input *[]cdn.GeoFilter) []interface{} {