diff --git a/profiles/preview/preview/frontdoor/mgmt/frontdoor/models.go b/profiles/preview/preview/frontdoor/mgmt/frontdoor/models.go new file mode 100644 index 000000000000..cbb0eaf33f5d --- /dev/null +++ b/profiles/preview/preview/frontdoor/mgmt/frontdoor/models.go @@ -0,0 +1,458 @@ +// +build go1.9 + +// Copyright 2018 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 frontdoor + +import original "github.com/Azure/azure-sdk-for-go/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor" + +type BackendPoolsClient = original.BackendPoolsClient + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type BaseClient = original.BaseClient +type EndpointsClient = original.EndpointsClient +type FrontDoorsClient = original.FrontDoorsClient +type FrontendEndpointsClient = original.FrontendEndpointsClient +type HealthProbeSettingsClient = original.HealthProbeSettingsClient +type LoadBalancingSettingsClient = original.LoadBalancingSettingsClient +type Action = original.Action + +const ( + Allow Action = original.Allow + Block Action = original.Block + Log Action = original.Log +) + +type Availability = original.Availability + +const ( + Available Availability = original.Available + Unavailable Availability = original.Unavailable +) + +type CertificateSource = original.CertificateSource + +const ( + CertificateSourceAzureKeyVault CertificateSource = original.CertificateSourceAzureKeyVault + CertificateSourceFrontDoor CertificateSource = original.CertificateSourceFrontDoor +) + +type CertificateType = original.CertificateType + +const ( + Dedicated CertificateType = original.Dedicated +) + +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 DynamicCompressionEnabled = original.DynamicCompressionEnabled + +const ( + DynamicCompressionEnabledDisabled DynamicCompressionEnabled = original.DynamicCompressionEnabledDisabled + DynamicCompressionEnabledEnabled DynamicCompressionEnabled = original.DynamicCompressionEnabledEnabled +) + +type EnabledState = original.EnabledState + +const ( + EnabledStateDisabled EnabledState = original.EnabledStateDisabled + EnabledStateEnabled EnabledState = original.EnabledStateEnabled +) + +type EnabledStateEnum = original.EnabledStateEnum + +const ( + EnabledStateEnumDisabled EnabledStateEnum = original.EnabledStateEnumDisabled + EnabledStateEnumEnabled EnabledStateEnum = original.EnabledStateEnumEnabled +) + +type ForwardingProtocol = original.ForwardingProtocol + +const ( + HTTPOnly ForwardingProtocol = original.HTTPOnly + HTTPSOnly ForwardingProtocol = original.HTTPSOnly + MatchRequest ForwardingProtocol = original.MatchRequest +) + +type MatchCondition = original.MatchCondition + +const ( + PostArgs MatchCondition = original.PostArgs + QueryString MatchCondition = original.QueryString + RemoteAddr MatchCondition = original.RemoteAddr + RequestBody MatchCondition = original.RequestBody + RequestHeader MatchCondition = original.RequestHeader + RequestMethod MatchCondition = original.RequestMethod + RequestURI MatchCondition = original.RequestURI +) + +type Mode = original.Mode + +const ( + Detection Mode = original.Detection + Prevention Mode = original.Prevention +) + +type NetworkOperationStatus = original.NetworkOperationStatus + +const ( + NetworkOperationStatusFailed NetworkOperationStatus = original.NetworkOperationStatusFailed + NetworkOperationStatusInProgress NetworkOperationStatus = original.NetworkOperationStatusInProgress + NetworkOperationStatusSucceeded NetworkOperationStatus = original.NetworkOperationStatusSucceeded +) + +type Operator = original.Operator + +const ( + Any Operator = original.Any + BeginsWith Operator = original.BeginsWith + Contains Operator = original.Contains + EndsWith Operator = original.EndsWith + Equal Operator = original.Equal + GeoMatch Operator = original.GeoMatch + GreaterThan Operator = original.GreaterThan + GreaterThanOrEqual Operator = original.GreaterThanOrEqual + IPMatch Operator = original.IPMatch + LessThan Operator = original.LessThan + LessThanOrEqual Operator = original.LessThanOrEqual +) + +type Protocol = original.Protocol + +const ( + HTTP Protocol = original.HTTP + HTTPS Protocol = original.HTTPS +) + +type Query = original.Query + +const ( + StripAll Query = original.StripAll + StripNone Query = original.StripNone +) + +type ResourceState = original.ResourceState + +const ( + ResourceStateCreating ResourceState = original.ResourceStateCreating + ResourceStateDeleting ResourceState = original.ResourceStateDeleting + ResourceStateDisabled ResourceState = original.ResourceStateDisabled + ResourceStateDisabling ResourceState = original.ResourceStateDisabling + ResourceStateEnabled ResourceState = original.ResourceStateEnabled + ResourceStateEnabling ResourceState = original.ResourceStateEnabling +) + +type ResourceType = original.ResourceType + +const ( + MicrosoftNetworkfrontDoors ResourceType = original.MicrosoftNetworkfrontDoors + MicrosoftNetworkfrontDoorsfrontendEndpoints ResourceType = original.MicrosoftNetworkfrontDoorsfrontendEndpoints +) + +type RuleGroupOverride = original.RuleGroupOverride + +const ( + SQLInjection RuleGroupOverride = original.SQLInjection + XSS RuleGroupOverride = original.XSS +) + +type RuleSetType = original.RuleSetType + +const ( + RuleSetTypeAzureManagedRuleSet RuleSetType = original.RuleSetTypeAzureManagedRuleSet + RuleSetTypeUnknown RuleSetType = original.RuleSetTypeUnknown +) + +type RuleType = original.RuleType + +const ( + MatchRule RuleType = original.MatchRule + RateLimitRule RuleType = original.RateLimitRule +) + +type SessionAffinityEnabledState = original.SessionAffinityEnabledState + +const ( + SessionAffinityEnabledStateDisabled SessionAffinityEnabledState = original.SessionAffinityEnabledStateDisabled + SessionAffinityEnabledStateEnabled SessionAffinityEnabledState = original.SessionAffinityEnabledStateEnabled +) + +type TLSProtocolType = original.TLSProtocolType + +const ( + ServerNameIndication TLSProtocolType = original.ServerNameIndication +) + +type Transform = original.Transform + +const ( + HTMLEntityDecode Transform = original.HTMLEntityDecode + Lowercase Transform = original.Lowercase + RemoveNulls Transform = original.RemoveNulls + Trim Transform = original.Trim + Uppercase Transform = original.Uppercase + URLDecode Transform = original.URLDecode + URLEncode Transform = original.URLEncode +) + +type AzureAsyncOperationResult = original.AzureAsyncOperationResult +type AzureManagedOverrideRuleGroup = original.AzureManagedOverrideRuleGroup +type AzureManagedRuleSet = original.AzureManagedRuleSet +type Backend = original.Backend +type BackendPool = original.BackendPool +type BackendPoolListResult = original.BackendPoolListResult +type BackendPoolListResultIterator = original.BackendPoolListResultIterator +type BackendPoolListResultPage = original.BackendPoolListResultPage +type BackendPoolProperties = original.BackendPoolProperties +type BackendPoolsCreateOrUpdateFuture = original.BackendPoolsCreateOrUpdateFuture +type BackendPoolsDeleteFuture = original.BackendPoolsDeleteFuture +type BackendPoolUpdateParameters = original.BackendPoolUpdateParameters +type CacheConfiguration = original.CacheConfiguration +type CertificateSourceParameters = original.CertificateSourceParameters +type CheckNameAvailabilityInput = original.CheckNameAvailabilityInput +type CheckNameAvailabilityOutput = original.CheckNameAvailabilityOutput +type CustomHTTPSConfiguration = original.CustomHTTPSConfiguration +type CustomRule = original.CustomRule +type CustomRules = original.CustomRules +type EndpointsPurgeContentFuture = original.EndpointsPurgeContentFuture +type Error = original.Error +type ErrorDetails = original.ErrorDetails +type ErrorResponse = original.ErrorResponse +type FrontDoor = original.FrontDoor +type FrontDoorsCreateOrUpdateFutureType = original.FrontDoorsCreateOrUpdateFutureType +type FrontDoorsDeleteFutureType = original.FrontDoorsDeleteFutureType +type FrontendEndpoint = original.FrontendEndpoint +type FrontendEndpointProperties = original.FrontendEndpointProperties +type FrontendEndpointsCreateOrUpdateFuture = original.FrontendEndpointsCreateOrUpdateFuture +type FrontendEndpointsDeleteFuture = original.FrontendEndpointsDeleteFuture +type FrontendEndpointsDisableHTTPSFuture = original.FrontendEndpointsDisableHTTPSFuture +type FrontendEndpointsEnableHTTPSFuture = original.FrontendEndpointsEnableHTTPSFuture +type FrontendEndpointsListResult = original.FrontendEndpointsListResult +type FrontendEndpointsListResultIterator = original.FrontendEndpointsListResultIterator +type FrontendEndpointsListResultPage = original.FrontendEndpointsListResultPage +type FrontendEndpointUpdateParameters = original.FrontendEndpointUpdateParameters +type FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink = original.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink +type HealthProbeSettingsCreateOrUpdateFuture = original.HealthProbeSettingsCreateOrUpdateFuture +type HealthProbeSettingsDeleteFuture = original.HealthProbeSettingsDeleteFuture +type HealthProbeSettingsListResult = original.HealthProbeSettingsListResult +type HealthProbeSettingsListResultIterator = original.HealthProbeSettingsListResultIterator +type HealthProbeSettingsListResultPage = original.HealthProbeSettingsListResultPage +type HealthProbeSettingsModel = original.HealthProbeSettingsModel +type HealthProbeSettingsProperties = original.HealthProbeSettingsProperties +type HealthProbeSettingsUpdateParameters = original.HealthProbeSettingsUpdateParameters +type KeyVaultCertificateSourceParameters = original.KeyVaultCertificateSourceParameters +type KeyVaultCertificateSourceParametersVault = original.KeyVaultCertificateSourceParametersVault +type ListResult = original.ListResult +type ListResultIterator = original.ListResultIterator +type ListResultPage = original.ListResultPage +type LoadBalancingSettingsCreateOrUpdateFuture = original.LoadBalancingSettingsCreateOrUpdateFuture +type LoadBalancingSettingsDeleteFuture = original.LoadBalancingSettingsDeleteFuture +type LoadBalancingSettingsListResult = original.LoadBalancingSettingsListResult +type LoadBalancingSettingsListResultIterator = original.LoadBalancingSettingsListResultIterator +type LoadBalancingSettingsListResultPage = original.LoadBalancingSettingsListResultPage +type LoadBalancingSettingsModel = original.LoadBalancingSettingsModel +type LoadBalancingSettingsProperties = original.LoadBalancingSettingsProperties +type LoadBalancingSettingsUpdateParameters = original.LoadBalancingSettingsUpdateParameters +type BasicManagedRuleSet = original.BasicManagedRuleSet +type ManagedRuleSet = original.ManagedRuleSet +type ManagedRuleSets = original.ManagedRuleSets +type MatchCondition1 = original.MatchCondition1 +type PoliciesDeleteFuture = original.PoliciesDeleteFuture +type PolicySettings = original.PolicySettings +type Properties = original.Properties +type PurgeParameters = original.PurgeParameters +type Resource = original.Resource +type RoutingRule = original.RoutingRule +type RoutingRuleListResult = original.RoutingRuleListResult +type RoutingRuleListResultIterator = original.RoutingRuleListResultIterator +type RoutingRuleListResultPage = original.RoutingRuleListResultPage +type RoutingRuleProperties = original.RoutingRuleProperties +type RoutingRulesCreateOrUpdateFuture = original.RoutingRulesCreateOrUpdateFuture +type RoutingRulesDeleteFuture = original.RoutingRulesDeleteFuture +type RoutingRuleUpdateParameters = original.RoutingRuleUpdateParameters +type SubResource = original.SubResource +type TagsObject = original.TagsObject +type UpdateParameters = original.UpdateParameters +type ValidateCustomDomainInput = original.ValidateCustomDomainInput +type ValidateCustomDomainOutput = original.ValidateCustomDomainOutput +type WebApplicationFirewallPolicy = original.WebApplicationFirewallPolicy +type WebApplicationFirewallPolicyListResult = original.WebApplicationFirewallPolicyListResult +type WebApplicationFirewallPolicyListResultIterator = original.WebApplicationFirewallPolicyListResultIterator +type WebApplicationFirewallPolicyListResultPage = original.WebApplicationFirewallPolicyListResultPage +type WebApplicationFirewallPolicyPropertiesFormat = original.WebApplicationFirewallPolicyPropertiesFormat +type PoliciesClient = original.PoliciesClient +type RoutingRulesClient = original.RoutingRulesClient + +func NewBackendPoolsClient(subscriptionID string) BackendPoolsClient { + return original.NewBackendPoolsClient(subscriptionID) +} +func NewBackendPoolsClientWithBaseURI(baseURI string, subscriptionID string) BackendPoolsClient { + return original.NewBackendPoolsClientWithBaseURI(baseURI, subscriptionID) +} +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func NewEndpointsClient(subscriptionID string) EndpointsClient { + return original.NewEndpointsClient(subscriptionID) +} +func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient { + return original.NewEndpointsClientWithBaseURI(baseURI, subscriptionID) +} +func NewFrontDoorsClient(subscriptionID string) FrontDoorsClient { + return original.NewFrontDoorsClient(subscriptionID) +} +func NewFrontDoorsClientWithBaseURI(baseURI string, subscriptionID string) FrontDoorsClient { + return original.NewFrontDoorsClientWithBaseURI(baseURI, subscriptionID) +} +func NewFrontendEndpointsClient(subscriptionID string) FrontendEndpointsClient { + return original.NewFrontendEndpointsClient(subscriptionID) +} +func NewFrontendEndpointsClientWithBaseURI(baseURI string, subscriptionID string) FrontendEndpointsClient { + return original.NewFrontendEndpointsClientWithBaseURI(baseURI, subscriptionID) +} +func NewHealthProbeSettingsClient(subscriptionID string) HealthProbeSettingsClient { + return original.NewHealthProbeSettingsClient(subscriptionID) +} +func NewHealthProbeSettingsClientWithBaseURI(baseURI string, subscriptionID string) HealthProbeSettingsClient { + return original.NewHealthProbeSettingsClientWithBaseURI(baseURI, subscriptionID) +} +func NewLoadBalancingSettingsClient(subscriptionID string) LoadBalancingSettingsClient { + return original.NewLoadBalancingSettingsClient(subscriptionID) +} +func NewLoadBalancingSettingsClientWithBaseURI(baseURI string, subscriptionID string) LoadBalancingSettingsClient { + return original.NewLoadBalancingSettingsClientWithBaseURI(baseURI, subscriptionID) +} +func PossibleActionValues() []Action { + return original.PossibleActionValues() +} +func PossibleAvailabilityValues() []Availability { + return original.PossibleAvailabilityValues() +} +func PossibleCertificateSourceValues() []CertificateSource { + return original.PossibleCertificateSourceValues() +} +func PossibleCertificateTypeValues() []CertificateType { + return original.PossibleCertificateTypeValues() +} +func PossibleCustomHTTPSProvisioningStateValues() []CustomHTTPSProvisioningState { + return original.PossibleCustomHTTPSProvisioningStateValues() +} +func PossibleCustomHTTPSProvisioningSubstateValues() []CustomHTTPSProvisioningSubstate { + return original.PossibleCustomHTTPSProvisioningSubstateValues() +} +func PossibleDynamicCompressionEnabledValues() []DynamicCompressionEnabled { + return original.PossibleDynamicCompressionEnabledValues() +} +func PossibleEnabledStateValues() []EnabledState { + return original.PossibleEnabledStateValues() +} +func PossibleEnabledStateEnumValues() []EnabledStateEnum { + return original.PossibleEnabledStateEnumValues() +} +func PossibleForwardingProtocolValues() []ForwardingProtocol { + return original.PossibleForwardingProtocolValues() +} +func PossibleMatchConditionValues() []MatchCondition { + return original.PossibleMatchConditionValues() +} +func PossibleModeValues() []Mode { + return original.PossibleModeValues() +} +func PossibleNetworkOperationStatusValues() []NetworkOperationStatus { + return original.PossibleNetworkOperationStatusValues() +} +func PossibleOperatorValues() []Operator { + return original.PossibleOperatorValues() +} +func PossibleProtocolValues() []Protocol { + return original.PossibleProtocolValues() +} +func PossibleQueryValues() []Query { + return original.PossibleQueryValues() +} +func PossibleResourceStateValues() []ResourceState { + return original.PossibleResourceStateValues() +} +func PossibleResourceTypeValues() []ResourceType { + return original.PossibleResourceTypeValues() +} +func PossibleRuleGroupOverrideValues() []RuleGroupOverride { + return original.PossibleRuleGroupOverrideValues() +} +func PossibleRuleSetTypeValues() []RuleSetType { + return original.PossibleRuleSetTypeValues() +} +func PossibleRuleTypeValues() []RuleType { + return original.PossibleRuleTypeValues() +} +func PossibleSessionAffinityEnabledStateValues() []SessionAffinityEnabledState { + return original.PossibleSessionAffinityEnabledStateValues() +} +func PossibleTLSProtocolTypeValues() []TLSProtocolType { + return original.PossibleTLSProtocolTypeValues() +} +func PossibleTransformValues() []Transform { + return original.PossibleTransformValues() +} +func NewPoliciesClient(subscriptionID string) PoliciesClient { + return original.NewPoliciesClient(subscriptionID) +} +func NewPoliciesClientWithBaseURI(baseURI string, subscriptionID string) PoliciesClient { + return original.NewPoliciesClientWithBaseURI(baseURI, subscriptionID) +} +func NewRoutingRulesClient(subscriptionID string) RoutingRulesClient { + return original.NewRoutingRulesClient(subscriptionID) +} +func NewRoutingRulesClientWithBaseURI(baseURI string, subscriptionID string) RoutingRulesClient { + return original.NewRoutingRulesClientWithBaseURI(baseURI, subscriptionID) +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/backendpools.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/backendpools.go new file mode 100644 index 000000000000..64d2f9df24f9 --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/backendpools.go @@ -0,0 +1,413 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackendPoolsClient is the frontdoor Client +type BackendPoolsClient struct { + BaseClient +} + +// NewBackendPoolsClient creates an instance of the BackendPoolsClient client. +func NewBackendPoolsClient(subscriptionID string) BackendPoolsClient { + return NewBackendPoolsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackendPoolsClientWithBaseURI creates an instance of the BackendPoolsClient client. +func NewBackendPoolsClientWithBaseURI(baseURI string, subscriptionID string) BackendPoolsClient { + return BackendPoolsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Backend Pool with the specified Pool name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// backendPoolName - name of the Backend Pool which is unique within the Front Door. +// backendPoolParameters - backend Pool properties needed to create a new Pool. +func (client BackendPoolsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, backendPoolName string, backendPoolParameters BackendPool) (result BackendPoolsCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: backendPoolName, + Constraints: []validation.Constraint{{Target: "backendPoolName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "backendPoolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "backendPoolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.BackendPoolsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, frontDoorName, backendPoolName, backendPoolParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackendPoolsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, backendPoolName string, backendPoolParameters BackendPool) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendPoolName": autorest.Encode("path", backendPoolName), + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/backendPools/{backendPoolName}", pathParameters), + autorest.WithJSON(backendPoolParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client BackendPoolsClient) CreateOrUpdateSender(req *http.Request) (future BackendPoolsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackendPoolsClient) CreateOrUpdateResponder(resp *http.Response) (result BackendPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing Backend Pool with the specified parameters. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// backendPoolName - name of the Backend Pool which is unique within the Front Door. +func (client BackendPoolsClient) Delete(ctx context.Context, resourceGroupName string, frontDoorName string, backendPoolName string) (result BackendPoolsDeleteFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: backendPoolName, + Constraints: []validation.Constraint{{Target: "backendPoolName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "backendPoolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "backendPoolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.BackendPoolsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, frontDoorName, backendPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client BackendPoolsClient) DeletePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, backendPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendPoolName": autorest.Encode("path", backendPoolName), + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/backendPools/{backendPoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BackendPoolsClient) DeleteSender(req *http.Request) (future BackendPoolsDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BackendPoolsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a Backend Pool with the specified Pool name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// backendPoolName - name of the Backend Pool which is unique within the Front Door. +func (client BackendPoolsClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, backendPoolName string) (result BackendPool, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: backendPoolName, + Constraints: []validation.Constraint{{Target: "backendPoolName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "backendPoolName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "backendPoolName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.BackendPoolsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, frontDoorName, backendPoolName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackendPoolsClient) GetPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, backendPoolName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backendPoolName": autorest.Encode("path", backendPoolName), + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/backendPools/{backendPoolName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BackendPoolsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackendPoolsClient) GetResponder(resp *http.Response) (result BackendPool, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByFrontDoor lists all of the Backend Pools within a Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +func (client BackendPoolsClient) ListByFrontDoor(ctx context.Context, resourceGroupName string, frontDoorName string) (result BackendPoolListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.BackendPoolsClient", "ListByFrontDoor", err.Error()) + } + + result.fn = client.listByFrontDoorNextResults + req, err := client.ListByFrontDoorPreparer(ctx, resourceGroupName, frontDoorName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "ListByFrontDoor", nil, "Failure preparing request") + return + } + + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.bplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "ListByFrontDoor", resp, "Failure sending request") + return + } + + result.bplr, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "ListByFrontDoor", resp, "Failure responding to request") + } + + return +} + +// ListByFrontDoorPreparer prepares the ListByFrontDoor request. +func (client BackendPoolsClient) ListByFrontDoorPreparer(ctx context.Context, resourceGroupName string, frontDoorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/backendPools", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByFrontDoorSender sends the ListByFrontDoor request. The method will close the +// http.Response Body if it receives an error. +func (client BackendPoolsClient) ListByFrontDoorSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByFrontDoorResponder handles the response to the ListByFrontDoor request. The method always +// closes the http.Response Body. +func (client BackendPoolsClient) ListByFrontDoorResponder(resp *http.Response) (result BackendPoolListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByFrontDoorNextResults retrieves the next set of results, if any. +func (client BackendPoolsClient) listByFrontDoorNextResults(lastResults BackendPoolListResult) (result BackendPoolListResult, err error) { + req, err := lastResults.backendPoolListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "listByFrontDoorNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "listByFrontDoorNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsClient", "listByFrontDoorNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByFrontDoorComplete enumerates all values, automatically crossing page boundaries as required. +func (client BackendPoolsClient) ListByFrontDoorComplete(ctx context.Context, resourceGroupName string, frontDoorName string) (result BackendPoolListResultIterator, err error) { + result.page, err = client.ListByFrontDoor(ctx, resourceGroupName, frontDoorName) + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/client.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/client.go new file mode 100644 index 000000000000..a88bd7455b40 --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/client.go @@ -0,0 +1,195 @@ +// Package frontdoor implements the Azure ARM Frontdoor service API version . +// +// Frontdoor Client +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +const ( + // DefaultBaseURI is the default URI used for the service Frontdoor + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Frontdoor. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// CheckFrontDoorNameAvailability check the availability of a Front Door resource name. +// Parameters: +// checkFrontDoorNameAvailabilityInput - input to check. +func (client BaseClient) CheckFrontDoorNameAvailability(ctx context.Context, checkFrontDoorNameAvailabilityInput CheckNameAvailabilityInput) (result CheckNameAvailabilityOutput, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: checkFrontDoorNameAvailabilityInput, + Constraints: []validation.Constraint{{Target: "checkFrontDoorNameAvailabilityInput.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.BaseClient", "CheckFrontDoorNameAvailability", err.Error()) + } + + req, err := client.CheckFrontDoorNameAvailabilityPreparer(ctx, checkFrontDoorNameAvailabilityInput) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BaseClient", "CheckFrontDoorNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckFrontDoorNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.BaseClient", "CheckFrontDoorNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckFrontDoorNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BaseClient", "CheckFrontDoorNameAvailability", resp, "Failure responding to request") + } + + return +} + +// CheckFrontDoorNameAvailabilityPreparer prepares the CheckFrontDoorNameAvailability request. +func (client BaseClient) CheckFrontDoorNameAvailabilityPreparer(ctx context.Context, checkFrontDoorNameAvailabilityInput CheckNameAvailabilityInput) (*http.Request, error) { + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Network/checkFrontDoorNameAvailability"), + autorest.WithJSON(checkFrontDoorNameAvailabilityInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckFrontDoorNameAvailabilitySender sends the CheckFrontDoorNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) CheckFrontDoorNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CheckFrontDoorNameAvailabilityResponder handles the response to the CheckFrontDoorNameAvailability request. The method always +// closes the http.Response Body. +func (client BaseClient) CheckFrontDoorNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityOutput, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CheckFrontDoorNameAvailabilityWithSubscription check the availability of a Front Door subdomain. +// Parameters: +// checkFrontDoorNameAvailabilityInput - input to check. +func (client BaseClient) CheckFrontDoorNameAvailabilityWithSubscription(ctx context.Context, checkFrontDoorNameAvailabilityInput CheckNameAvailabilityInput) (result CheckNameAvailabilityOutput, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: checkFrontDoorNameAvailabilityInput, + Constraints: []validation.Constraint{{Target: "checkFrontDoorNameAvailabilityInput.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.BaseClient", "CheckFrontDoorNameAvailabilityWithSubscription", err.Error()) + } + + req, err := client.CheckFrontDoorNameAvailabilityWithSubscriptionPreparer(ctx, checkFrontDoorNameAvailabilityInput) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BaseClient", "CheckFrontDoorNameAvailabilityWithSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.CheckFrontDoorNameAvailabilityWithSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.BaseClient", "CheckFrontDoorNameAvailabilityWithSubscription", resp, "Failure sending request") + return + } + + result, err = client.CheckFrontDoorNameAvailabilityWithSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BaseClient", "CheckFrontDoorNameAvailabilityWithSubscription", resp, "Failure responding to request") + } + + return +} + +// CheckFrontDoorNameAvailabilityWithSubscriptionPreparer prepares the CheckFrontDoorNameAvailabilityWithSubscription request. +func (client BaseClient) CheckFrontDoorNameAvailabilityWithSubscriptionPreparer(ctx context.Context, checkFrontDoorNameAvailabilityInput CheckNameAvailabilityInput) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/checkFrontDoorNameAvailability", pathParameters), + autorest.WithJSON(checkFrontDoorNameAvailabilityInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckFrontDoorNameAvailabilityWithSubscriptionSender sends the CheckFrontDoorNameAvailabilityWithSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) CheckFrontDoorNameAvailabilityWithSubscriptionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CheckFrontDoorNameAvailabilityWithSubscriptionResponder handles the response to the CheckFrontDoorNameAvailabilityWithSubscription request. The method always +// closes the http.Response Body. +func (client BaseClient) CheckFrontDoorNameAvailabilityWithSubscriptionResponder(resp *http.Response) (result CheckNameAvailabilityOutput, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/endpoints.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/endpoints.go new file mode 100644 index 000000000000..8c18f41cb533 --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/endpoints.go @@ -0,0 +1,130 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// EndpointsClient is the frontdoor Client +type EndpointsClient struct { + BaseClient +} + +// NewEndpointsClient creates an instance of the EndpointsClient client. +func NewEndpointsClient(subscriptionID string) EndpointsClient { + return NewEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEndpointsClientWithBaseURI creates an instance of the EndpointsClient client. +func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient { + return EndpointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// PurgeContent removes a content from Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// contentFilePaths - the path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' +// which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders +// and files in the directory. +func (client EndpointsClient) PurgeContent(ctx context.Context, resourceGroupName string, frontDoorName string, contentFilePaths PurgeParameters) (result EndpointsPurgeContentFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: contentFilePaths, + Constraints: []validation.Constraint{{Target: "contentFilePaths.ContentPaths", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.EndpointsClient", "PurgeContent", err.Error()) + } + + req, err := client.PurgeContentPreparer(ctx, resourceGroupName, frontDoorName, contentFilePaths) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.EndpointsClient", "PurgeContent", nil, "Failure preparing request") + return + } + + result, err = client.PurgeContentSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.EndpointsClient", "PurgeContent", result.Response(), "Failure sending request") + return + } + + return +} + +// PurgeContentPreparer prepares the PurgeContent request. +func (client EndpointsClient) PurgeContentPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, contentFilePaths PurgeParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge", pathParameters), + autorest.WithJSON(contentFilePaths), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PurgeContentSender sends the PurgeContent request. The method will close the +// http.Response Body if it receives an error. +func (client EndpointsClient) PurgeContentSender(req *http.Request) (future EndpointsPurgeContentFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// PurgeContentResponder handles the response to the PurgeContent request. The method always +// closes the http.Response Body. +func (client EndpointsClient) PurgeContentResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/frontdoors.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/frontdoors.go new file mode 100644 index 000000000000..4d266046fbc8 --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/frontdoors.go @@ -0,0 +1,564 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FrontDoorsClient is the frontdoor Client +type FrontDoorsClient struct { + BaseClient +} + +// NewFrontDoorsClient creates an instance of the FrontDoorsClient client. +func NewFrontDoorsClient(subscriptionID string) FrontDoorsClient { + return NewFrontDoorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFrontDoorsClientWithBaseURI creates an instance of the FrontDoorsClient client. +func NewFrontDoorsClientWithBaseURI(baseURI string, subscriptionID string) FrontDoorsClient { + return FrontDoorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Front Door with a Front Door name under the specified subscription and resource group. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// frontDoorParameters - front Door properties needed to create a new Front Door. +func (client FrontDoorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, frontDoorParameters FrontDoor) (result FrontDoorsCreateOrUpdateFutureType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontDoorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, frontDoorName, frontDoorParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FrontDoorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, frontDoorParameters FrontDoor) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}", pathParameters), + autorest.WithJSON(frontDoorParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FrontDoorsClient) CreateOrUpdateSender(req *http.Request) (future FrontDoorsCreateOrUpdateFutureType, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FrontDoorsClient) CreateOrUpdateResponder(resp *http.Response) (result FrontDoor, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing Front Door with the specified parameters. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +func (client FrontDoorsClient) Delete(ctx context.Context, resourceGroupName string, frontDoorName string) (result FrontDoorsDeleteFutureType, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontDoorsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, frontDoorName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FrontDoorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, frontDoorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FrontDoorsClient) DeleteSender(req *http.Request) (future FrontDoorsDeleteFutureType, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FrontDoorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a Front Door with the specified Front Door name under the specified subscription and resource group. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +func (client FrontDoorsClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string) (result FrontDoor, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontDoorsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, frontDoorName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FrontDoorsClient) GetPreparer(ctx context.Context, resourceGroupName string, frontDoorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FrontDoorsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FrontDoorsClient) GetResponder(resp *http.Response) (result FrontDoor, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all of the Front Doors within an Azure subscription. +func (client FrontDoorsClient) List(ctx context.Context) (result ListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.lr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "List", resp, "Failure sending request") + return + } + + result.lr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client FrontDoorsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/frontDoors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client FrontDoorsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client FrontDoorsClient) ListResponder(resp *http.Response) (result ListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client FrontDoorsClient) listNextResults(lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client FrontDoorsClient) ListComplete(ctx context.Context) (result ListResultIterator, err error) { + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup lists all of the Front Doors within a resource group under a subscription. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +func (client FrontDoorsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontDoorsClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.lr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.lr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client FrontDoorsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client FrontDoorsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client FrontDoorsClient) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client FrontDoorsClient) listByResourceGroupNextResults(lastResults ListResult) (result ListResult, err error) { + req, err := lastResults.listResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client FrontDoorsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ListResultIterator, err error) { + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ValidateCustomDomain validates the custom domain mapping to ensure it maps to the correct Front Door endpoint in +// DNS. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// customDomainProperties - custom domain to be validated. +func (client FrontDoorsClient) ValidateCustomDomain(ctx context.Context, resourceGroupName string, frontDoorName string, customDomainProperties ValidateCustomDomainInput) (result ValidateCustomDomainOutput, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: customDomainProperties, + Constraints: []validation.Constraint{{Target: "customDomainProperties.HostName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontDoorsClient", "ValidateCustomDomain", err.Error()) + } + + req, err := client.ValidateCustomDomainPreparer(ctx, resourceGroupName, frontDoorName, customDomainProperties) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "ValidateCustomDomain", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateCustomDomainSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "ValidateCustomDomain", resp, "Failure sending request") + return + } + + result, err = client.ValidateCustomDomainResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsClient", "ValidateCustomDomain", resp, "Failure responding to request") + } + + return +} + +// ValidateCustomDomainPreparer prepares the ValidateCustomDomain request. +func (client FrontDoorsClient) ValidateCustomDomainPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, customDomainProperties ValidateCustomDomainInput) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/validateCustomDomain", pathParameters), + autorest.WithJSON(customDomainProperties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateCustomDomainSender sends the ValidateCustomDomain request. The method will close the +// http.Response Body if it receives an error. +func (client FrontDoorsClient) ValidateCustomDomainSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ValidateCustomDomainResponder handles the response to the ValidateCustomDomain request. The method always +// closes the http.Response Body. +func (client FrontDoorsClient) ValidateCustomDomainResponder(resp *http.Response) (result ValidateCustomDomainOutput, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/frontendendpoints.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/frontendendpoints.go new file mode 100644 index 000000000000..9b35c790286a --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/frontendendpoints.go @@ -0,0 +1,592 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// FrontendEndpointsClient is the frontdoor Client +type FrontendEndpointsClient struct { + BaseClient +} + +// NewFrontendEndpointsClient creates an instance of the FrontendEndpointsClient client. +func NewFrontendEndpointsClient(subscriptionID string) FrontendEndpointsClient { + return NewFrontendEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFrontendEndpointsClientWithBaseURI creates an instance of the FrontendEndpointsClient client. +func NewFrontendEndpointsClientWithBaseURI(baseURI string, subscriptionID string) FrontendEndpointsClient { + return FrontendEndpointsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new frontend endpoint with the specified host name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// frontendEndpointName - name of the Frontend endpoint which is unique within the Front Door. +// frontendEndpointParameters - frontend endpoint properties needed to create a new endpoint. +func (client FrontendEndpointsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, frontendEndpointParameters FrontendEndpoint) (result FrontendEndpointsCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: frontendEndpointName, + Constraints: []validation.Constraint{{Target: "frontendEndpointName", Name: validation.MaxLength, Rule: 255, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontendEndpointsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, frontDoorName, frontendEndpointName, frontendEndpointParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FrontendEndpointsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, frontendEndpointParameters FrontendEndpoint) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "frontendEndpointName": autorest.Encode("path", frontendEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/provider/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}", pathParameters), + autorest.WithJSON(frontendEndpointParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FrontendEndpointsClient) CreateOrUpdateSender(req *http.Request) (future FrontendEndpointsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FrontendEndpointsClient) CreateOrUpdateResponder(resp *http.Response) (result FrontendEndpoint, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing frontend endpoint with the specified parameters. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// frontendEndpointName - name of the Frontend endpoint which is unique within the Front Door. +func (client FrontendEndpointsClient) Delete(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string) (result FrontendEndpointsDeleteFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: frontendEndpointName, + Constraints: []validation.Constraint{{Target: "frontendEndpointName", Name: validation.MaxLength, Rule: 255, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontendEndpointsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, frontDoorName, frontendEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FrontendEndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "frontendEndpointName": autorest.Encode("path", frontendEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/provider/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FrontendEndpointsClient) DeleteSender(req *http.Request) (future FrontendEndpointsDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FrontendEndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DisableHTTPS disables a frontendEndpoint for HTTPS traffic +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// frontendEndpointName - name of the Frontend endpoint which is unique within the Front Door. +func (client FrontendEndpointsClient) DisableHTTPS(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string) (result FrontendEndpointsDisableHTTPSFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: frontendEndpointName, + Constraints: []validation.Constraint{{Target: "frontendEndpointName", Name: validation.MaxLength, Rule: 255, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontendEndpointsClient", "DisableHTTPS", err.Error()) + } + + req, err := client.DisableHTTPSPreparer(ctx, resourceGroupName, frontDoorName, frontendEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "DisableHTTPS", nil, "Failure preparing request") + return + } + + result, err = client.DisableHTTPSSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "DisableHTTPS", result.Response(), "Failure sending request") + return + } + + return +} + +// DisableHTTPSPreparer prepares the DisableHTTPS request. +func (client FrontendEndpointsClient) DisableHTTPSPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "frontendEndpointName": autorest.Encode("path", frontendEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/provider/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/disableHttps", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DisableHTTPSSender sends the DisableHTTPS request. The method will close the +// http.Response Body if it receives an error. +func (client FrontendEndpointsClient) DisableHTTPSSender(req *http.Request) (future FrontendEndpointsDisableHTTPSFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DisableHTTPSResponder handles the response to the DisableHTTPS request. The method always +// closes the http.Response Body. +func (client FrontendEndpointsClient) DisableHTTPSResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// EnableHTTPS enables a frontendEndpoint for HTTPS traffic +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// frontendEndpointName - name of the Frontend endpoint which is unique within the Front Door. +// customHTTPSConfiguration - the configuration specifying how to enable HTTPS +func (client FrontendEndpointsClient) EnableHTTPS(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, customHTTPSConfiguration CustomHTTPSConfiguration) (result FrontendEndpointsEnableHTTPSFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: frontendEndpointName, + Constraints: []validation.Constraint{{Target: "frontendEndpointName", Name: validation.MaxLength, Rule: 255, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontendEndpointsClient", "EnableHTTPS", err.Error()) + } + + req, err := client.EnableHTTPSPreparer(ctx, resourceGroupName, frontDoorName, frontendEndpointName, customHTTPSConfiguration) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "EnableHTTPS", nil, "Failure preparing request") + return + } + + result, err = client.EnableHTTPSSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "EnableHTTPS", result.Response(), "Failure sending request") + return + } + + return +} + +// EnableHTTPSPreparer prepares the EnableHTTPS request. +func (client FrontendEndpointsClient) EnableHTTPSPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, customHTTPSConfiguration CustomHTTPSConfiguration) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "frontendEndpointName": autorest.Encode("path", frontendEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/provider/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/enableHttps", pathParameters), + autorest.WithJSON(customHTTPSConfiguration), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// EnableHTTPSSender sends the EnableHTTPS request. The method will close the +// http.Response Body if it receives an error. +func (client FrontendEndpointsClient) EnableHTTPSSender(req *http.Request) (future FrontendEndpointsEnableHTTPSFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// EnableHTTPSResponder handles the response to the EnableHTTPS request. The method always +// closes the http.Response Body. +func (client FrontendEndpointsClient) EnableHTTPSResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a Frontend endpoint with the specified name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// frontendEndpointName - name of the Frontend endpoint which is unique within the Front Door. +func (client FrontendEndpointsClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string) (result FrontendEndpoint, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: frontendEndpointName, + Constraints: []validation.Constraint{{Target: "frontendEndpointName", Name: validation.MaxLength, Rule: 255, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "frontendEndpointName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontendEndpointsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, frontDoorName, frontendEndpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FrontendEndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "frontendEndpointName": autorest.Encode("path", frontendEndpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/provider/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FrontendEndpointsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FrontendEndpointsClient) GetResponder(resp *http.Response) (result FrontendEndpoint, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByFrontDoor lists all of the frontend endpoints within a Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +func (client FrontendEndpointsClient) ListByFrontDoor(ctx context.Context, resourceGroupName string, frontDoorName string) (result FrontendEndpointsListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.FrontendEndpointsClient", "ListByFrontDoor", err.Error()) + } + + result.fn = client.listByFrontDoorNextResults + req, err := client.ListByFrontDoorPreparer(ctx, resourceGroupName, frontDoorName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "ListByFrontDoor", nil, "Failure preparing request") + return + } + + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.felr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "ListByFrontDoor", resp, "Failure sending request") + return + } + + result.felr, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "ListByFrontDoor", resp, "Failure responding to request") + } + + return +} + +// ListByFrontDoorPreparer prepares the ListByFrontDoor request. +func (client FrontendEndpointsClient) ListByFrontDoorPreparer(ctx context.Context, resourceGroupName string, frontDoorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByFrontDoorSender sends the ListByFrontDoor request. The method will close the +// http.Response Body if it receives an error. +func (client FrontendEndpointsClient) ListByFrontDoorSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByFrontDoorResponder handles the response to the ListByFrontDoor request. The method always +// closes the http.Response Body. +func (client FrontendEndpointsClient) ListByFrontDoorResponder(resp *http.Response) (result FrontendEndpointsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByFrontDoorNextResults retrieves the next set of results, if any. +func (client FrontendEndpointsClient) listByFrontDoorNextResults(lastResults FrontendEndpointsListResult) (result FrontendEndpointsListResult, err error) { + req, err := lastResults.frontendEndpointsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "listByFrontDoorNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "listByFrontDoorNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsClient", "listByFrontDoorNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByFrontDoorComplete enumerates all values, automatically crossing page boundaries as required. +func (client FrontendEndpointsClient) ListByFrontDoorComplete(ctx context.Context, resourceGroupName string, frontDoorName string) (result FrontendEndpointsListResultIterator, err error) { + result.page, err = client.ListByFrontDoor(ctx, resourceGroupName, frontDoorName) + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/healthprobesettings.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/healthprobesettings.go new file mode 100644 index 000000000000..498987ce2eca --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/healthprobesettings.go @@ -0,0 +1,413 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// HealthProbeSettingsClient is the frontdoor Client +type HealthProbeSettingsClient struct { + BaseClient +} + +// NewHealthProbeSettingsClient creates an instance of the HealthProbeSettingsClient client. +func NewHealthProbeSettingsClient(subscriptionID string) HealthProbeSettingsClient { + return NewHealthProbeSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHealthProbeSettingsClientWithBaseURI creates an instance of the HealthProbeSettingsClient client. +func NewHealthProbeSettingsClientWithBaseURI(baseURI string, subscriptionID string) HealthProbeSettingsClient { + return HealthProbeSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new HealthProbeSettings with the specified Rule name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// healthProbeSettingsName - name of the health probe settings which is unique within the Front Door. +// healthProbeSettingsParameters - healthProbeSettings properties needed to create a new Front Door. +func (client HealthProbeSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, healthProbeSettingsName string, healthProbeSettingsParameters HealthProbeSettingsModel) (result HealthProbeSettingsCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: healthProbeSettingsName, + Constraints: []validation.Constraint{{Target: "healthProbeSettingsName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "healthProbeSettingsName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "healthProbeSettingsName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.HealthProbeSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, frontDoorName, healthProbeSettingsName, healthProbeSettingsParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client HealthProbeSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, healthProbeSettingsName string, healthProbeSettingsParameters HealthProbeSettingsModel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "healthProbeSettingsName": autorest.Encode("path", healthProbeSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/healthProbeSettings/{healthProbeSettingsName}", pathParameters), + autorest.WithJSON(healthProbeSettingsParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client HealthProbeSettingsClient) CreateOrUpdateSender(req *http.Request) (future HealthProbeSettingsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client HealthProbeSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result HealthProbeSettingsModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing HealthProbeSettings with the specified parameters. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// healthProbeSettingsName - name of the health probe settings which is unique within the Front Door. +func (client HealthProbeSettingsClient) Delete(ctx context.Context, resourceGroupName string, frontDoorName string, healthProbeSettingsName string) (result HealthProbeSettingsDeleteFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: healthProbeSettingsName, + Constraints: []validation.Constraint{{Target: "healthProbeSettingsName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "healthProbeSettingsName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "healthProbeSettingsName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.HealthProbeSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, frontDoorName, healthProbeSettingsName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client HealthProbeSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, healthProbeSettingsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "healthProbeSettingsName": autorest.Encode("path", healthProbeSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/healthProbeSettings/{healthProbeSettingsName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client HealthProbeSettingsClient) DeleteSender(req *http.Request) (future HealthProbeSettingsDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client HealthProbeSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a HealthProbeSettings with the specified Rule name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// healthProbeSettingsName - name of the health probe settings which is unique within the Front Door. +func (client HealthProbeSettingsClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, healthProbeSettingsName string) (result HealthProbeSettingsModel, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: healthProbeSettingsName, + Constraints: []validation.Constraint{{Target: "healthProbeSettingsName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "healthProbeSettingsName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "healthProbeSettingsName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.HealthProbeSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, frontDoorName, healthProbeSettingsName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client HealthProbeSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, healthProbeSettingsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "healthProbeSettingsName": autorest.Encode("path", healthProbeSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/healthProbeSettings/{healthProbeSettingsName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client HealthProbeSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client HealthProbeSettingsClient) GetResponder(resp *http.Response) (result HealthProbeSettingsModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByFrontDoor lists all of the HealthProbeSettings within a Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +func (client HealthProbeSettingsClient) ListByFrontDoor(ctx context.Context, resourceGroupName string, frontDoorName string) (result HealthProbeSettingsListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.HealthProbeSettingsClient", "ListByFrontDoor", err.Error()) + } + + result.fn = client.listByFrontDoorNextResults + req, err := client.ListByFrontDoorPreparer(ctx, resourceGroupName, frontDoorName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "ListByFrontDoor", nil, "Failure preparing request") + return + } + + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.hpslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "ListByFrontDoor", resp, "Failure sending request") + return + } + + result.hpslr, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "ListByFrontDoor", resp, "Failure responding to request") + } + + return +} + +// ListByFrontDoorPreparer prepares the ListByFrontDoor request. +func (client HealthProbeSettingsClient) ListByFrontDoorPreparer(ctx context.Context, resourceGroupName string, frontDoorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/healthProbeSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByFrontDoorSender sends the ListByFrontDoor request. The method will close the +// http.Response Body if it receives an error. +func (client HealthProbeSettingsClient) ListByFrontDoorSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByFrontDoorResponder handles the response to the ListByFrontDoor request. The method always +// closes the http.Response Body. +func (client HealthProbeSettingsClient) ListByFrontDoorResponder(resp *http.Response) (result HealthProbeSettingsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByFrontDoorNextResults retrieves the next set of results, if any. +func (client HealthProbeSettingsClient) listByFrontDoorNextResults(lastResults HealthProbeSettingsListResult) (result HealthProbeSettingsListResult, err error) { + req, err := lastResults.healthProbeSettingsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "listByFrontDoorNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "listByFrontDoorNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsClient", "listByFrontDoorNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByFrontDoorComplete enumerates all values, automatically crossing page boundaries as required. +func (client HealthProbeSettingsClient) ListByFrontDoorComplete(ctx context.Context, resourceGroupName string, frontDoorName string) (result HealthProbeSettingsListResultIterator, err error) { + result.page, err = client.ListByFrontDoor(ctx, resourceGroupName, frontDoorName) + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/loadbalancingsettings.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/loadbalancingsettings.go new file mode 100644 index 000000000000..fe1c175a6bef --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/loadbalancingsettings.go @@ -0,0 +1,413 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// LoadBalancingSettingsClient is the frontdoor Client +type LoadBalancingSettingsClient struct { + BaseClient +} + +// NewLoadBalancingSettingsClient creates an instance of the LoadBalancingSettingsClient client. +func NewLoadBalancingSettingsClient(subscriptionID string) LoadBalancingSettingsClient { + return NewLoadBalancingSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLoadBalancingSettingsClientWithBaseURI creates an instance of the LoadBalancingSettingsClient client. +func NewLoadBalancingSettingsClientWithBaseURI(baseURI string, subscriptionID string) LoadBalancingSettingsClient { + return LoadBalancingSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new LoadBalancingSettings with the specified Rule name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// loadBalancingSettingsName - name of the load balancing settings which is unique within the Front Door. +// loadBalancingSettingsParameters - loadBalancingSettings properties needed to create a new Front Door. +func (client LoadBalancingSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, loadBalancingSettingsName string, loadBalancingSettingsParameters LoadBalancingSettingsModel) (result LoadBalancingSettingsCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: loadBalancingSettingsName, + Constraints: []validation.Constraint{{Target: "loadBalancingSettingsName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "loadBalancingSettingsName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "loadBalancingSettingsName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.LoadBalancingSettingsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, frontDoorName, loadBalancingSettingsName, loadBalancingSettingsParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client LoadBalancingSettingsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, loadBalancingSettingsName string, loadBalancingSettingsParameters LoadBalancingSettingsModel) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "loadBalancingSettingsName": autorest.Encode("path", loadBalancingSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/loadBalancingSettings/{loadBalancingSettingsName}", pathParameters), + autorest.WithJSON(loadBalancingSettingsParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client LoadBalancingSettingsClient) CreateOrUpdateSender(req *http.Request) (future LoadBalancingSettingsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client LoadBalancingSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result LoadBalancingSettingsModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing LoadBalancingSettings with the specified parameters. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// loadBalancingSettingsName - name of the load balancing settings which is unique within the Front Door. +func (client LoadBalancingSettingsClient) Delete(ctx context.Context, resourceGroupName string, frontDoorName string, loadBalancingSettingsName string) (result LoadBalancingSettingsDeleteFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: loadBalancingSettingsName, + Constraints: []validation.Constraint{{Target: "loadBalancingSettingsName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "loadBalancingSettingsName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "loadBalancingSettingsName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.LoadBalancingSettingsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, frontDoorName, loadBalancingSettingsName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client LoadBalancingSettingsClient) DeletePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, loadBalancingSettingsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "loadBalancingSettingsName": autorest.Encode("path", loadBalancingSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/loadBalancingSettings/{loadBalancingSettingsName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client LoadBalancingSettingsClient) DeleteSender(req *http.Request) (future LoadBalancingSettingsDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client LoadBalancingSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a LoadBalancingSettings with the specified Rule name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// loadBalancingSettingsName - name of the load balancing settings which is unique within the Front Door. +func (client LoadBalancingSettingsClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, loadBalancingSettingsName string) (result LoadBalancingSettingsModel, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: loadBalancingSettingsName, + Constraints: []validation.Constraint{{Target: "loadBalancingSettingsName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "loadBalancingSettingsName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "loadBalancingSettingsName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.LoadBalancingSettingsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, frontDoorName, loadBalancingSettingsName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client LoadBalancingSettingsClient) GetPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, loadBalancingSettingsName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "loadBalancingSettingsName": autorest.Encode("path", loadBalancingSettingsName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/loadBalancingSettings/{loadBalancingSettingsName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client LoadBalancingSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client LoadBalancingSettingsClient) GetResponder(resp *http.Response) (result LoadBalancingSettingsModel, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByFrontDoor lists all of the LoadBalancingSettings within a Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +func (client LoadBalancingSettingsClient) ListByFrontDoor(ctx context.Context, resourceGroupName string, frontDoorName string) (result LoadBalancingSettingsListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.LoadBalancingSettingsClient", "ListByFrontDoor", err.Error()) + } + + result.fn = client.listByFrontDoorNextResults + req, err := client.ListByFrontDoorPreparer(ctx, resourceGroupName, frontDoorName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "ListByFrontDoor", nil, "Failure preparing request") + return + } + + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.lbslr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "ListByFrontDoor", resp, "Failure sending request") + return + } + + result.lbslr, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "ListByFrontDoor", resp, "Failure responding to request") + } + + return +} + +// ListByFrontDoorPreparer prepares the ListByFrontDoor request. +func (client LoadBalancingSettingsClient) ListByFrontDoorPreparer(ctx context.Context, resourceGroupName string, frontDoorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/loadBalancingSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByFrontDoorSender sends the ListByFrontDoor request. The method will close the +// http.Response Body if it receives an error. +func (client LoadBalancingSettingsClient) ListByFrontDoorSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByFrontDoorResponder handles the response to the ListByFrontDoor request. The method always +// closes the http.Response Body. +func (client LoadBalancingSettingsClient) ListByFrontDoorResponder(resp *http.Response) (result LoadBalancingSettingsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByFrontDoorNextResults retrieves the next set of results, if any. +func (client LoadBalancingSettingsClient) listByFrontDoorNextResults(lastResults LoadBalancingSettingsListResult) (result LoadBalancingSettingsListResult, err error) { + req, err := lastResults.loadBalancingSettingsListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "listByFrontDoorNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "listByFrontDoorNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsClient", "listByFrontDoorNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByFrontDoorComplete enumerates all values, automatically crossing page boundaries as required. +func (client LoadBalancingSettingsClient) ListByFrontDoorComplete(ctx context.Context, resourceGroupName string, frontDoorName string) (result LoadBalancingSettingsListResultIterator, err error) { + result.page, err = client.ListByFrontDoor(ctx, resourceGroupName, frontDoorName) + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/models.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/models.go new file mode 100644 index 000000000000..77e292cf21f1 --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/models.go @@ -0,0 +1,2910 @@ +package frontdoor + +// 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 ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// Action enumerates the values for action. +type Action string + +const ( + // Allow ... + Allow Action = "Allow" + // Block ... + Block Action = "Block" + // Log ... + Log Action = "Log" +) + +// PossibleActionValues returns an array of possible values for the Action const type. +func PossibleActionValues() []Action { + return []Action{Allow, Block, Log} +} + +// Availability enumerates the values for availability. +type Availability string + +const ( + // Available ... + Available Availability = "Available" + // Unavailable ... + Unavailable Availability = "Unavailable" +) + +// PossibleAvailabilityValues returns an array of possible values for the Availability const type. +func PossibleAvailabilityValues() []Availability { + return []Availability{Available, Unavailable} +} + +// CertificateSource enumerates the values for certificate source. +type CertificateSource string + +const ( + // CertificateSourceAzureKeyVault ... + CertificateSourceAzureKeyVault CertificateSource = "AzureKeyVault" + // CertificateSourceFrontDoor ... + CertificateSourceFrontDoor CertificateSource = "FrontDoor" +) + +// PossibleCertificateSourceValues returns an array of possible values for the CertificateSource const type. +func PossibleCertificateSourceValues() []CertificateSource { + return []CertificateSource{CertificateSourceAzureKeyVault, CertificateSourceFrontDoor} +} + +// CertificateType enumerates the values for certificate type. +type CertificateType string + +const ( + // Dedicated ... + Dedicated CertificateType = "Dedicated" +) + +// PossibleCertificateTypeValues returns an array of possible values for the CertificateType const type. +func PossibleCertificateTypeValues() []CertificateType { + return []CertificateType{Dedicated} +} + +// 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} +} + +// DynamicCompressionEnabled enumerates the values for dynamic compression enabled. +type DynamicCompressionEnabled string + +const ( + // DynamicCompressionEnabledDisabled ... + DynamicCompressionEnabledDisabled DynamicCompressionEnabled = "Disabled" + // DynamicCompressionEnabledEnabled ... + DynamicCompressionEnabledEnabled DynamicCompressionEnabled = "Enabled" +) + +// PossibleDynamicCompressionEnabledValues returns an array of possible values for the DynamicCompressionEnabled const type. +func PossibleDynamicCompressionEnabledValues() []DynamicCompressionEnabled { + return []DynamicCompressionEnabled{DynamicCompressionEnabledDisabled, DynamicCompressionEnabledEnabled} +} + +// EnabledState enumerates the values for enabled state. +type EnabledState string + +const ( + // EnabledStateDisabled ... + EnabledStateDisabled EnabledState = "Disabled" + // EnabledStateEnabled ... + EnabledStateEnabled EnabledState = "Enabled" +) + +// PossibleEnabledStateValues returns an array of possible values for the EnabledState const type. +func PossibleEnabledStateValues() []EnabledState { + return []EnabledState{EnabledStateDisabled, EnabledStateEnabled} +} + +// EnabledStateEnum enumerates the values for enabled state enum. +type EnabledStateEnum string + +const ( + // EnabledStateEnumDisabled ... + EnabledStateEnumDisabled EnabledStateEnum = "Disabled" + // EnabledStateEnumEnabled ... + EnabledStateEnumEnabled EnabledStateEnum = "Enabled" +) + +// PossibleEnabledStateEnumValues returns an array of possible values for the EnabledStateEnum const type. +func PossibleEnabledStateEnumValues() []EnabledStateEnum { + return []EnabledStateEnum{EnabledStateEnumDisabled, EnabledStateEnumEnabled} +} + +// ForwardingProtocol enumerates the values for forwarding protocol. +type ForwardingProtocol string + +const ( + // HTTPOnly ... + HTTPOnly ForwardingProtocol = "HttpOnly" + // HTTPSOnly ... + HTTPSOnly ForwardingProtocol = "HttpsOnly" + // MatchRequest ... + MatchRequest ForwardingProtocol = "MatchRequest" +) + +// PossibleForwardingProtocolValues returns an array of possible values for the ForwardingProtocol const type. +func PossibleForwardingProtocolValues() []ForwardingProtocol { + return []ForwardingProtocol{HTTPOnly, HTTPSOnly, MatchRequest} +} + +// MatchCondition enumerates the values for match condition. +type MatchCondition string + +const ( + // PostArgs ... + PostArgs MatchCondition = "PostArgs" + // QueryString ... + QueryString MatchCondition = "QueryString" + // RemoteAddr ... + RemoteAddr MatchCondition = "RemoteAddr" + // RequestBody ... + RequestBody MatchCondition = "RequestBody" + // RequestHeader ... + RequestHeader MatchCondition = "RequestHeader" + // RequestMethod ... + RequestMethod MatchCondition = "RequestMethod" + // RequestURI ... + RequestURI MatchCondition = "RequestUri" +) + +// PossibleMatchConditionValues returns an array of possible values for the MatchCondition const type. +func PossibleMatchConditionValues() []MatchCondition { + return []MatchCondition{PostArgs, QueryString, RemoteAddr, RequestBody, RequestHeader, RequestMethod, RequestURI} +} + +// Mode enumerates the values for mode. +type Mode string + +const ( + // Detection ... + Detection Mode = "Detection" + // Prevention ... + Prevention Mode = "Prevention" +) + +// PossibleModeValues returns an array of possible values for the Mode const type. +func PossibleModeValues() []Mode { + return []Mode{Detection, Prevention} +} + +// NetworkOperationStatus enumerates the values for network operation status. +type NetworkOperationStatus string + +const ( + // NetworkOperationStatusFailed ... + NetworkOperationStatusFailed NetworkOperationStatus = "Failed" + // NetworkOperationStatusInProgress ... + NetworkOperationStatusInProgress NetworkOperationStatus = "InProgress" + // NetworkOperationStatusSucceeded ... + NetworkOperationStatusSucceeded NetworkOperationStatus = "Succeeded" +) + +// PossibleNetworkOperationStatusValues returns an array of possible values for the NetworkOperationStatus const type. +func PossibleNetworkOperationStatusValues() []NetworkOperationStatus { + return []NetworkOperationStatus{NetworkOperationStatusFailed, NetworkOperationStatusInProgress, NetworkOperationStatusSucceeded} +} + +// Operator enumerates the values for operator. +type Operator string + +const ( + // Any ... + Any Operator = "Any" + // BeginsWith ... + BeginsWith Operator = "BeginsWith" + // Contains ... + Contains Operator = "Contains" + // EndsWith ... + EndsWith Operator = "EndsWith" + // Equal ... + Equal Operator = "Equal" + // GeoMatch ... + GeoMatch Operator = "GeoMatch" + // GreaterThan ... + GreaterThan Operator = "GreaterThan" + // GreaterThanOrEqual ... + GreaterThanOrEqual Operator = "GreaterThanOrEqual" + // IPMatch ... + IPMatch Operator = "IPMatch" + // LessThan ... + LessThan Operator = "LessThan" + // LessThanOrEqual ... + LessThanOrEqual Operator = "LessThanOrEqual" +) + +// PossibleOperatorValues returns an array of possible values for the Operator const type. +func PossibleOperatorValues() []Operator { + return []Operator{Any, BeginsWith, Contains, EndsWith, Equal, GeoMatch, GreaterThan, GreaterThanOrEqual, IPMatch, LessThan, LessThanOrEqual} +} + +// Protocol enumerates the values for protocol. +type Protocol string + +const ( + // HTTP ... + HTTP Protocol = "Http" + // HTTPS ... + HTTPS Protocol = "Https" +) + +// PossibleProtocolValues returns an array of possible values for the Protocol const type. +func PossibleProtocolValues() []Protocol { + return []Protocol{HTTP, HTTPS} +} + +// Query enumerates the values for query. +type Query string + +const ( + // StripAll ... + StripAll Query = "StripAll" + // StripNone ... + StripNone Query = "StripNone" +) + +// PossibleQueryValues returns an array of possible values for the Query const type. +func PossibleQueryValues() []Query { + return []Query{StripAll, StripNone} +} + +// ResourceState enumerates the values for resource state. +type ResourceState string + +const ( + // ResourceStateCreating ... + ResourceStateCreating ResourceState = "Creating" + // ResourceStateDeleting ... + ResourceStateDeleting ResourceState = "Deleting" + // ResourceStateDisabled ... + ResourceStateDisabled ResourceState = "Disabled" + // ResourceStateDisabling ... + ResourceStateDisabling ResourceState = "Disabling" + // ResourceStateEnabled ... + ResourceStateEnabled ResourceState = "Enabled" + // ResourceStateEnabling ... + ResourceStateEnabling ResourceState = "Enabling" +) + +// PossibleResourceStateValues returns an array of possible values for the ResourceState const type. +func PossibleResourceStateValues() []ResourceState { + return []ResourceState{ResourceStateCreating, ResourceStateDeleting, ResourceStateDisabled, ResourceStateDisabling, ResourceStateEnabled, ResourceStateEnabling} +} + +// ResourceType enumerates the values for resource type. +type ResourceType string + +const ( + // MicrosoftNetworkfrontDoors ... + MicrosoftNetworkfrontDoors ResourceType = "Microsoft.Network/frontDoors" + // MicrosoftNetworkfrontDoorsfrontendEndpoints ... + MicrosoftNetworkfrontDoorsfrontendEndpoints ResourceType = "Microsoft.Network/frontDoors/frontendEndpoints" +) + +// PossibleResourceTypeValues returns an array of possible values for the ResourceType const type. +func PossibleResourceTypeValues() []ResourceType { + return []ResourceType{MicrosoftNetworkfrontDoors, MicrosoftNetworkfrontDoorsfrontendEndpoints} +} + +// RuleGroupOverride enumerates the values for rule group override. +type RuleGroupOverride string + +const ( + // SQLInjection ... + SQLInjection RuleGroupOverride = "SqlInjection" + // XSS ... + XSS RuleGroupOverride = "XSS" +) + +// PossibleRuleGroupOverrideValues returns an array of possible values for the RuleGroupOverride const type. +func PossibleRuleGroupOverrideValues() []RuleGroupOverride { + return []RuleGroupOverride{SQLInjection, XSS} +} + +// RuleSetType enumerates the values for rule set type. +type RuleSetType string + +const ( + // RuleSetTypeAzureManagedRuleSet ... + RuleSetTypeAzureManagedRuleSet RuleSetType = "AzureManagedRuleSet" + // RuleSetTypeUnknown ... + RuleSetTypeUnknown RuleSetType = "Unknown" +) + +// PossibleRuleSetTypeValues returns an array of possible values for the RuleSetType const type. +func PossibleRuleSetTypeValues() []RuleSetType { + return []RuleSetType{RuleSetTypeAzureManagedRuleSet, RuleSetTypeUnknown} +} + +// RuleType enumerates the values for rule type. +type RuleType string + +const ( + // MatchRule ... + MatchRule RuleType = "MatchRule" + // RateLimitRule ... + RateLimitRule RuleType = "RateLimitRule" +) + +// PossibleRuleTypeValues returns an array of possible values for the RuleType const type. +func PossibleRuleTypeValues() []RuleType { + return []RuleType{MatchRule, RateLimitRule} +} + +// SessionAffinityEnabledState enumerates the values for session affinity enabled state. +type SessionAffinityEnabledState string + +const ( + // SessionAffinityEnabledStateDisabled ... + SessionAffinityEnabledStateDisabled SessionAffinityEnabledState = "Disabled" + // SessionAffinityEnabledStateEnabled ... + SessionAffinityEnabledStateEnabled SessionAffinityEnabledState = "Enabled" +) + +// PossibleSessionAffinityEnabledStateValues returns an array of possible values for the SessionAffinityEnabledState const type. +func PossibleSessionAffinityEnabledStateValues() []SessionAffinityEnabledState { + return []SessionAffinityEnabledState{SessionAffinityEnabledStateDisabled, SessionAffinityEnabledStateEnabled} +} + +// TLSProtocolType enumerates the values for tls protocol type. +type TLSProtocolType string + +const ( + // ServerNameIndication ... + ServerNameIndication TLSProtocolType = "ServerNameIndication" +) + +// PossibleTLSProtocolTypeValues returns an array of possible values for the TLSProtocolType const type. +func PossibleTLSProtocolTypeValues() []TLSProtocolType { + return []TLSProtocolType{ServerNameIndication} +} + +// Transform enumerates the values for transform. +type Transform string + +const ( + // HTMLEntityDecode ... + HTMLEntityDecode Transform = "HtmlEntityDecode" + // Lowercase ... + Lowercase Transform = "Lowercase" + // RemoveNulls ... + RemoveNulls Transform = "RemoveNulls" + // Trim ... + Trim Transform = "Trim" + // Uppercase ... + Uppercase Transform = "Uppercase" + // URLDecode ... + URLDecode Transform = "UrlDecode" + // URLEncode ... + URLEncode Transform = "UrlEncode" +) + +// PossibleTransformValues returns an array of possible values for the Transform const type. +func PossibleTransformValues() []Transform { + return []Transform{HTMLEntityDecode, Lowercase, RemoveNulls, Trim, Uppercase, URLDecode, URLEncode} +} + +// AzureAsyncOperationResult the response body contains the status of the specified asynchronous operation, +// indicating whether it has succeeded, is in progress, or has failed. Note that this status is distinct from the +// HTTP status code returned for the Get Operation Status operation itself. If the asynchronous operation +// succeeded, the response body includes the HTTP status code for the successful request. If the asynchronous +// operation failed, the response body includes the HTTP status code for the failed request and error information +// regarding the failure. +type AzureAsyncOperationResult struct { + // Status - Status of the Azure async operation. Possible values are: 'InProgress', 'Succeeded', and 'Failed'. Possible values include: 'NetworkOperationStatusInProgress', 'NetworkOperationStatusSucceeded', 'NetworkOperationStatusFailed' + Status NetworkOperationStatus `json:"status,omitempty"` + Error *Error `json:"error,omitempty"` +} + +// AzureManagedOverrideRuleGroup defines contents of a web application rule +type AzureManagedOverrideRuleGroup struct { + // RuleGroupOverride - Describes overrideruleGroup. Possible values include: 'SQLInjection', 'XSS' + RuleGroupOverride RuleGroupOverride `json:"ruleGroupOverride,omitempty"` + // Action - Type of Actions. Possible values include: 'Allow', 'Block', 'Log' + Action Action `json:"action,omitempty"` +} + +// AzureManagedRuleSet describes azure managed provider. +type AzureManagedRuleSet struct { + // RuleGroupOverrides - List of azure managed provider override configuration (optional) + RuleGroupOverrides *[]AzureManagedOverrideRuleGroup `json:"ruleGroupOverrides,omitempty"` + // Priority - Describes priority of the rule + Priority *int32 `json:"priority,omitempty"` + // Version - defines version of the ruleset + Version *int32 `json:"version,omitempty"` + // RuleSetType - Possible values include: 'RuleSetTypeUnknown', 'RuleSetTypeAzureManagedRuleSet' + RuleSetType RuleSetType `json:"ruleSetType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureManagedRuleSet. +func (amrs AzureManagedRuleSet) MarshalJSON() ([]byte, error) { + amrs.RuleSetType = RuleSetTypeAzureManagedRuleSet + objectMap := make(map[string]interface{}) + if amrs.RuleGroupOverrides != nil { + objectMap["ruleGroupOverrides"] = amrs.RuleGroupOverrides + } + if amrs.Priority != nil { + objectMap["priority"] = amrs.Priority + } + if amrs.Version != nil { + objectMap["version"] = amrs.Version + } + if amrs.RuleSetType != "" { + objectMap["ruleSetType"] = amrs.RuleSetType + } + return json.Marshal(objectMap) +} + +// AsAzureManagedRuleSet is the BasicManagedRuleSet implementation for AzureManagedRuleSet. +func (amrs AzureManagedRuleSet) AsAzureManagedRuleSet() (*AzureManagedRuleSet, bool) { + return &amrs, true +} + +// AsManagedRuleSet is the BasicManagedRuleSet implementation for AzureManagedRuleSet. +func (amrs AzureManagedRuleSet) AsManagedRuleSet() (*ManagedRuleSet, bool) { + return nil, false +} + +// AsBasicManagedRuleSet is the BasicManagedRuleSet implementation for AzureManagedRuleSet. +func (amrs AzureManagedRuleSet) AsBasicManagedRuleSet() (BasicManagedRuleSet, bool) { + return &amrs, true +} + +// Backend backend address of a frontDoor load balancer. +type Backend struct { + // Address - Location of the backend (IP address or FQDN) + Address *string `json:"address,omitempty"` + // HTTPPort - The HTTP TCP port number. Must be between 1 and 65535. + HTTPPort *int32 `json:"httpPort,omitempty"` + // HTTPSPort - The HTTPS TCP port number. Must be between 1 and 65535. + HTTPSPort *int32 `json:"httpsPort,omitempty"` + // EnabledState - Whether to enable use of this backend. Permitted values are 'Enabled' or 'Disabled'. Possible values include: 'EnabledStateEnumEnabled', 'EnabledStateEnumDisabled' + EnabledState EnabledStateEnum `json:"enabledState,omitempty"` + // Priority - Priority to use for load balancing. Higher priorities will not be used for load balancing if any lower priority backend is healthy. + Priority *int32 `json:"priority,omitempty"` + // Weight - Weight of this endpoint for load balancing purposes. + Weight *int32 `json:"weight,omitempty"` + // BackendHostHeader - The value to use as the host header sent to the backend. If blank or unspecified, this defaults to the incoming host. + BackendHostHeader *string `json:"backendHostHeader,omitempty"` +} + +// BackendPool a backend pool is a collection of backends that can be routed to. +type BackendPool struct { + autorest.Response `json:"-"` + // BackendPoolProperties - Properties of the Front Door Backend Pool + *BackendPoolProperties `json:"properties,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for BackendPool. +func (bp BackendPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if bp.BackendPoolProperties != nil { + objectMap["properties"] = bp.BackendPoolProperties + } + if bp.Name != nil { + objectMap["name"] = bp.Name + } + if bp.Type != nil { + objectMap["type"] = bp.Type + } + if bp.ID != nil { + objectMap["id"] = bp.ID + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for BackendPool struct. +func (bp *BackendPool) 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 backendPoolProperties BackendPoolProperties + err = json.Unmarshal(*v, &backendPoolProperties) + if err != nil { + return err + } + bp.BackendPoolProperties = &backendPoolProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + bp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + bp.Type = &typeVar + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + bp.ID = &ID + } + } + } + + return nil +} + +// BackendPoolListResult result of the request to list Backend Pools. It contains a list of Backend Pools objects +// and a URL link to get the the next set of results. +type BackendPoolListResult struct { + autorest.Response `json:"-"` + // Value - List of Backend Pools within a Front Door. + Value *[]BackendPool `json:"value,omitempty"` + // NextLink - URL to get the next set of BackendPool objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// BackendPoolListResultIterator provides access to a complete listing of BackendPool values. +type BackendPoolListResultIterator struct { + i int + page BackendPoolListResultPage +} + +// Next 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 *BackendPoolListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter BackendPoolListResultIterator) 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 BackendPoolListResultIterator) Response() BackendPoolListResult { + 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 BackendPoolListResultIterator) Value() BackendPool { + if !iter.page.NotDone() { + return BackendPool{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (bplr BackendPoolListResult) IsEmpty() bool { + return bplr.Value == nil || len(*bplr.Value) == 0 +} + +// backendPoolListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (bplr BackendPoolListResult) backendPoolListResultPreparer() (*http.Request, error) { + if bplr.NextLink == nil || len(to.String(bplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(bplr.NextLink))) +} + +// BackendPoolListResultPage contains a page of BackendPool values. +type BackendPoolListResultPage struct { + fn func(BackendPoolListResult) (BackendPoolListResult, error) + bplr BackendPoolListResult +} + +// 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. +func (page *BackendPoolListResultPage) Next() error { + next, err := page.fn(page.bplr) + if err != nil { + return err + } + page.bplr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page BackendPoolListResultPage) NotDone() bool { + return !page.bplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page BackendPoolListResultPage) Response() BackendPoolListResult { + return page.bplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page BackendPoolListResultPage) Values() []BackendPool { + if page.bplr.IsEmpty() { + return nil + } + return *page.bplr.Value +} + +// BackendPoolProperties the JSON object that contains the properties required to create a routing rule. +type BackendPoolProperties struct { + // ResourceState - Resource status. Possible values include: 'ResourceStateCreating', 'ResourceStateEnabling', 'ResourceStateEnabled', 'ResourceStateDisabling', 'ResourceStateDisabled', 'ResourceStateDeleting' + ResourceState ResourceState `json:"resourceState,omitempty"` + // Backends - The set of backends for this pool + Backends *[]Backend `json:"backends,omitempty"` + // LoadBalancingSettings - Load balancing settings for a backend pool + LoadBalancingSettings *SubResource `json:"loadBalancingSettings,omitempty"` + // HealthProbeSettings - L7 health probe settings for a backend pool + HealthProbeSettings *SubResource `json:"healthProbeSettings,omitempty"` +} + +// BackendPoolsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type BackendPoolsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *BackendPoolsCreateOrUpdateFuture) Result(client BackendPoolsClient) (bp BackendPool, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.BackendPoolsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if bp.Response.Response, err = future.GetResult(sender); err == nil && bp.Response.Response.StatusCode != http.StatusNoContent { + bp, err = client.CreateOrUpdateResponder(bp.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsCreateOrUpdateFuture", "Result", bp.Response.Response, "Failure responding to request") + } + } + return +} + +// BackendPoolsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type BackendPoolsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *BackendPoolsDeleteFuture) Result(client BackendPoolsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.BackendPoolsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.BackendPoolsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// BackendPoolUpdateParameters a collection of backends that can be routed to. +type BackendPoolUpdateParameters struct { + // Backends - The set of backends for this pool + Backends *[]Backend `json:"backends,omitempty"` + // LoadBalancingSettings - Load balancing settings for a backend pool + LoadBalancingSettings *SubResource `json:"loadBalancingSettings,omitempty"` + // HealthProbeSettings - L7 health probe settings for a backend pool + HealthProbeSettings *SubResource `json:"healthProbeSettings,omitempty"` +} + +// CacheConfiguration caching settings for a caching-type route. To disable caching, do not provide a +// cacheConfiguration object. +type CacheConfiguration struct { + // QueryParameterStripDirective - Treatment of URL query terms when forming the cache key. Possible values include: 'StripNone', 'StripAll' + QueryParameterStripDirective Query `json:"queryParameterStripDirective,omitempty"` + // DynamicCompression - Whether to use dynamic compression for cached content. Possible values include: 'DynamicCompressionEnabledEnabled', 'DynamicCompressionEnabledDisabled' + DynamicCompression DynamicCompressionEnabled `json:"dynamicCompression,omitempty"` +} + +// CertificateSourceParameters parameters required for enabling SSL with Front Door-managed certificates +type CertificateSourceParameters struct { + // CertificateType - Defines the type of the certificate used for secure connections to a frontendEndpoint. Possible values include: '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. Possible values include: 'MicrosoftNetworkfrontDoors', 'MicrosoftNetworkfrontDoorsfrontendEndpoints' + Type ResourceType `json:"type,omitempty"` +} + +// CheckNameAvailabilityOutput output of check name availability API. +type CheckNameAvailabilityOutput struct { + autorest.Response `json:"-"` + // NameAvailability - Indicates whether the name is available. Possible values include: 'Available', 'Unavailable' + NameAvailability Availability `json:"nameAvailability,omitempty"` + // Reason - The reason why the name is not available. + Reason *string `json:"reason,omitempty"` + // Message - The detailed error message describing why the name is not available. + Message *string `json:"message,omitempty"` +} + +// CustomHTTPSConfiguration https settings for a domain +type CustomHTTPSConfiguration struct { + // CertificateSource - Defines the source of the SSL certificate. Possible values include: 'CertificateSourceAzureKeyVault', 'CertificateSourceFrontDoor' + CertificateSource CertificateSource `json:"certificateSource,omitempty"` + // ProtocolType - Defines the TLS extension protocol that is used for secure delivery. Possible values include: 'ServerNameIndication' + ProtocolType TLSProtocolType `json:"protocolType,omitempty"` + // KeyVaultCertificateSourceParameters - KeyVault certificate source parameters (if certificateSource=AzureKeyVault) + *KeyVaultCertificateSourceParameters `json:"keyVaultCertificateSourceParameters,omitempty"` + // CertificateSourceParameters - Parameters required for enabling SSL with Front Door-managed certificates (if certificateSource=FrontDoor) + *CertificateSourceParameters `json:"frontDoorCertificateSourceParameters,omitempty"` +} + +// MarshalJSON is the custom marshaler for CustomHTTPSConfiguration. +func (chc CustomHTTPSConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if chc.CertificateSource != "" { + objectMap["certificateSource"] = chc.CertificateSource + } + if chc.ProtocolType != "" { + objectMap["protocolType"] = chc.ProtocolType + } + if chc.KeyVaultCertificateSourceParameters != nil { + objectMap["keyVaultCertificateSourceParameters"] = chc.KeyVaultCertificateSourceParameters + } + if chc.CertificateSourceParameters != nil { + objectMap["frontDoorCertificateSourceParameters"] = chc.CertificateSourceParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CustomHTTPSConfiguration struct. +func (chc *CustomHTTPSConfiguration) 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 "certificateSource": + if v != nil { + var certificateSource CertificateSource + err = json.Unmarshal(*v, &certificateSource) + if err != nil { + return err + } + chc.CertificateSource = certificateSource + } + case "protocolType": + if v != nil { + var protocolType TLSProtocolType + err = json.Unmarshal(*v, &protocolType) + if err != nil { + return err + } + chc.ProtocolType = protocolType + } + case "keyVaultCertificateSourceParameters": + if v != nil { + var keyVaultCertificateSourceParameters KeyVaultCertificateSourceParameters + err = json.Unmarshal(*v, &keyVaultCertificateSourceParameters) + if err != nil { + return err + } + chc.KeyVaultCertificateSourceParameters = &keyVaultCertificateSourceParameters + } + case "frontDoorCertificateSourceParameters": + if v != nil { + var certificateSourceParameters CertificateSourceParameters + err = json.Unmarshal(*v, &certificateSourceParameters) + if err != nil { + return err + } + chc.CertificateSourceParameters = &certificateSourceParameters + } + } + } + + return nil +} + +// CustomRule defines contents of a web application rule +type CustomRule struct { + // Name - Gets name of the resource that is unique within a policy. This name can be used to access the resource. + Name *string `json:"name,omitempty"` + // Etag - Gets a unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` + // Priority - Describes priority of the rule. Rules with a lower value will be evaluated before rules with a higher value + Priority *int32 `json:"priority,omitempty"` + // RuleType - Describes type of rule. Possible values include: 'MatchRule', 'RateLimitRule' + RuleType RuleType `json:"ruleType,omitempty"` + // RateLimitDurationInMinutes - Defines rate limit duration. Default - 1 minute + RateLimitDurationInMinutes *int32 `json:"rateLimitDurationInMinutes,omitempty"` + // RateLimitThreshold - Defines rate limit thresold + RateLimitThreshold *int32 `json:"rateLimitThreshold,omitempty"` + // MatchConditions - List of match conditions + MatchConditions *[]MatchCondition1 `json:"matchConditions,omitempty"` + // Action - Type of Actions. Possible values include: 'Allow', 'Block', 'Log' + Action Action `json:"action,omitempty"` + // Transforms - List of transforms + Transforms *[]Transform `json:"transforms,omitempty"` +} + +// CustomRules defines contents of custom rules +type CustomRules struct { + // Rules - List of rules + Rules *[]CustomRule `json:"rules,omitempty"` +} + +// 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.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.EndpointsPurgeContentFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.EndpointsPurgeContentFuture") + return + } + ar.Response = future.Response() + return +} + +// Error ... +type Error struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` + Details *[]ErrorDetails `json:"details,omitempty"` + InnerError *string `json:"innerError,omitempty"` +} + +// ErrorDetails ... +type ErrorDetails struct { + Code *string `json:"code,omitempty"` + Target *string `json:"target,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ErrorResponse error reponse indicates Front Door service is not able to process the incoming request. The reason +// is provided in the error message. +type ErrorResponse struct { + // Code - Error code. + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// FrontDoor front Door represents a collection of backend endpoints to route traffic to along with rules that +// specify how traffic is sent there. +type FrontDoor struct { + autorest.Response `json:"-"` + // Properties - Properties of the Front Door Load Balancer + *Properties `json:"properties,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for FrontDoor. +func (fd FrontDoor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fd.Properties != nil { + objectMap["properties"] = fd.Properties + } + if fd.ID != nil { + objectMap["id"] = fd.ID + } + if fd.Name != nil { + objectMap["name"] = fd.Name + } + if fd.Type != nil { + objectMap["type"] = fd.Type + } + if fd.Location != nil { + objectMap["location"] = fd.Location + } + if fd.Tags != nil { + objectMap["tags"] = fd.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FrontDoor struct. +func (fd *FrontDoor) 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 properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + fd.Properties = &properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fd.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + fd.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fd.Tags = tags + } + } + } + + return nil +} + +// FrontDoorsCreateOrUpdateFutureType an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FrontDoorsCreateOrUpdateFutureType struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FrontDoorsCreateOrUpdateFutureType) Result(client FrontDoorsClient) (fd FrontDoor, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsCreateOrUpdateFutureType", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.FrontDoorsCreateOrUpdateFutureType") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fd.Response.Response, err = future.GetResult(sender); err == nil && fd.Response.Response.StatusCode != http.StatusNoContent { + fd, err = client.CreateOrUpdateResponder(fd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsCreateOrUpdateFutureType", "Result", fd.Response.Response, "Failure responding to request") + } + } + return +} + +// FrontDoorsDeleteFutureType an abstraction for monitoring and retrieving the results of a long-running operation. +type FrontDoorsDeleteFutureType struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FrontDoorsDeleteFutureType) Result(client FrontDoorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontDoorsDeleteFutureType", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.FrontDoorsDeleteFutureType") + return + } + ar.Response = future.Response() + return +} + +// FrontendEndpoint a frontend endpoint used for routing. +type FrontendEndpoint struct { + autorest.Response `json:"-"` + // FrontendEndpointProperties - Properties of the Frontend endpoint + *FrontendEndpointProperties `json:"properties,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for FrontendEndpoint. +func (fe FrontendEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fe.FrontendEndpointProperties != nil { + objectMap["properties"] = fe.FrontendEndpointProperties + } + if fe.Name != nil { + objectMap["name"] = fe.Name + } + if fe.Type != nil { + objectMap["type"] = fe.Type + } + if fe.ID != nil { + objectMap["id"] = fe.ID + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FrontendEndpoint struct. +func (fe *FrontendEndpoint) 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 frontendEndpointProperties FrontendEndpointProperties + err = json.Unmarshal(*v, &frontendEndpointProperties) + if err != nil { + return err + } + fe.FrontendEndpointProperties = &frontendEndpointProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + fe.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + fe.Type = &typeVar + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + fe.ID = &ID + } + } + } + + return nil +} + +// FrontendEndpointProperties the JSON object that contains the properties required to create a frontend endpoint. +type FrontendEndpointProperties struct { + // ResourceState - Resource status. Possible values include: 'ResourceStateCreating', 'ResourceStateEnabling', 'ResourceStateEnabled', 'ResourceStateDisabling', 'ResourceStateDisabled', 'ResourceStateDeleting' + ResourceState ResourceState `json:"resourceState,omitempty"` + // CustomHTTPSProvisioningState - Provisioning status of Custom Https of the frontendEndpoint. Possible values include: 'Enabling', 'Enabled', 'Disabling', 'Disabled', 'Failed' + CustomHTTPSProvisioningState CustomHTTPSProvisioningState `json:"customHttpsProvisioningState,omitempty"` + // CustomHTTPSProvisioningSubstate - 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"` + // CustomHTTPSConfiguration - The configuration specifying how to enable HTTPS + CustomHTTPSConfiguration *CustomHTTPSConfiguration `json:"customHttpsConfiguration,omitempty"` + // HostName - The host name of the frontendEndpoint. Must be a domain name. + HostName *string `json:"hostName,omitempty"` + // SessionAffinityEnabledState - Whether to allow session affinity on this host. Valid options are 'Enabled' or 'Disabled'. Possible values include: 'SessionAffinityEnabledStateEnabled', 'SessionAffinityEnabledStateDisabled' + SessionAffinityEnabledState SessionAffinityEnabledState `json:"sessionAffinityEnabledState,omitempty"` + // SessionAffinityTTLSeconds - UNUSED. This field will be ignored. The TTL to use in seconds for session affinity, if applicable. + SessionAffinityTTLSeconds *int32 `json:"sessionAffinityTtlSeconds,omitempty"` + // WebApplicationFirewallPolicyLink - Defines the Web Application Firewall policy for each host (if applicable) + WebApplicationFirewallPolicyLink *FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink `json:"webApplicationFirewallPolicyLink,omitempty"` +} + +// FrontendEndpointsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FrontendEndpointsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FrontendEndpointsCreateOrUpdateFuture) Result(client FrontendEndpointsClient) (fe FrontendEndpoint, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.FrontendEndpointsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fe.Response.Response, err = future.GetResult(sender); err == nil && fe.Response.Response.StatusCode != http.StatusNoContent { + fe, err = client.CreateOrUpdateResponder(fe.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsCreateOrUpdateFuture", "Result", fe.Response.Response, "Failure responding to request") + } + } + return +} + +// FrontendEndpointsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FrontendEndpointsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FrontendEndpointsDeleteFuture) Result(client FrontendEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.FrontendEndpointsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FrontendEndpointsDisableHTTPSFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FrontendEndpointsDisableHTTPSFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FrontendEndpointsDisableHTTPSFuture) Result(client FrontendEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsDisableHTTPSFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.FrontendEndpointsDisableHTTPSFuture") + return + } + ar.Response = future.Response() + return +} + +// FrontendEndpointsEnableHTTPSFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FrontendEndpointsEnableHTTPSFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *FrontendEndpointsEnableHTTPSFuture) Result(client FrontendEndpointsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.FrontendEndpointsEnableHTTPSFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.FrontendEndpointsEnableHTTPSFuture") + return + } + ar.Response = future.Response() + return +} + +// FrontendEndpointsListResult result of the request to list frontend endpoints. It contains a list of Frontend +// endpoint objects and a URL link to get the the next set of results. +type FrontendEndpointsListResult struct { + autorest.Response `json:"-"` + // Value - List of Frontend endpoints within a Front Door. + Value *[]FrontendEndpoint `json:"value,omitempty"` + // NextLink - URL to get the next set of frontend endpoints if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// FrontendEndpointsListResultIterator provides access to a complete listing of FrontendEndpoint values. +type FrontendEndpointsListResultIterator struct { + i int + page FrontendEndpointsListResultPage +} + +// Next 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 *FrontendEndpointsListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FrontendEndpointsListResultIterator) 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 FrontendEndpointsListResultIterator) Response() FrontendEndpointsListResult { + 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 FrontendEndpointsListResultIterator) Value() FrontendEndpoint { + if !iter.page.NotDone() { + return FrontendEndpoint{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (felr FrontendEndpointsListResult) IsEmpty() bool { + return felr.Value == nil || len(*felr.Value) == 0 +} + +// frontendEndpointsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (felr FrontendEndpointsListResult) frontendEndpointsListResultPreparer() (*http.Request, error) { + if felr.NextLink == nil || len(to.String(felr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(felr.NextLink))) +} + +// FrontendEndpointsListResultPage contains a page of FrontendEndpoint values. +type FrontendEndpointsListResultPage struct { + fn func(FrontendEndpointsListResult) (FrontendEndpointsListResult, error) + felr FrontendEndpointsListResult +} + +// 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. +func (page *FrontendEndpointsListResultPage) Next() error { + next, err := page.fn(page.felr) + if err != nil { + return err + } + page.felr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FrontendEndpointsListResultPage) NotDone() bool { + return !page.felr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FrontendEndpointsListResultPage) Response() FrontendEndpointsListResult { + return page.felr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FrontendEndpointsListResultPage) Values() []FrontendEndpoint { + if page.felr.IsEmpty() { + return nil + } + return *page.felr.Value +} + +// FrontendEndpointUpdateParameters frontend endpoint used in routing rule +type FrontendEndpointUpdateParameters struct { + // HostName - The host name of the frontendEndpoint. Must be a domain name. + HostName *string `json:"hostName,omitempty"` + // SessionAffinityEnabledState - Whether to allow session affinity on this host. Valid options are 'Enabled' or 'Disabled'. Possible values include: 'SessionAffinityEnabledStateEnabled', 'SessionAffinityEnabledStateDisabled' + SessionAffinityEnabledState SessionAffinityEnabledState `json:"sessionAffinityEnabledState,omitempty"` + // SessionAffinityTTLSeconds - UNUSED. This field will be ignored. The TTL to use in seconds for session affinity, if applicable. + SessionAffinityTTLSeconds *int32 `json:"sessionAffinityTtlSeconds,omitempty"` + // WebApplicationFirewallPolicyLink - Defines the Web Application Firewall policy for each host (if applicable) + WebApplicationFirewallPolicyLink *FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink `json:"webApplicationFirewallPolicyLink,omitempty"` +} + +// FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink defines the Web Application Firewall policy for +// each host (if applicable) +type FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// HealthProbeSettingsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type HealthProbeSettingsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *HealthProbeSettingsCreateOrUpdateFuture) Result(client HealthProbeSettingsClient) (hpsm HealthProbeSettingsModel, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.HealthProbeSettingsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if hpsm.Response.Response, err = future.GetResult(sender); err == nil && hpsm.Response.Response.StatusCode != http.StatusNoContent { + hpsm, err = client.CreateOrUpdateResponder(hpsm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsCreateOrUpdateFuture", "Result", hpsm.Response.Response, "Failure responding to request") + } + } + return +} + +// HealthProbeSettingsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type HealthProbeSettingsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *HealthProbeSettingsDeleteFuture) Result(client HealthProbeSettingsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.HealthProbeSettingsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.HealthProbeSettingsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// HealthProbeSettingsListResult result of the request to list HealthProbeSettings. It contains a list of +// HealthProbeSettings objects and a URL link to get the the next set of results. +type HealthProbeSettingsListResult struct { + autorest.Response `json:"-"` + // Value - List of HealthProbeSettings within a Front Door. + Value *[]HealthProbeSettingsModel `json:"value,omitempty"` + // NextLink - URL to get the next set of HealthProbeSettings objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// HealthProbeSettingsListResultIterator provides access to a complete listing of HealthProbeSettingsModel values. +type HealthProbeSettingsListResultIterator struct { + i int + page HealthProbeSettingsListResultPage +} + +// Next 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 *HealthProbeSettingsListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HealthProbeSettingsListResultIterator) 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 HealthProbeSettingsListResultIterator) Response() HealthProbeSettingsListResult { + 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 HealthProbeSettingsListResultIterator) Value() HealthProbeSettingsModel { + if !iter.page.NotDone() { + return HealthProbeSettingsModel{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (hpslr HealthProbeSettingsListResult) IsEmpty() bool { + return hpslr.Value == nil || len(*hpslr.Value) == 0 +} + +// healthProbeSettingsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hpslr HealthProbeSettingsListResult) healthProbeSettingsListResultPreparer() (*http.Request, error) { + if hpslr.NextLink == nil || len(to.String(hpslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hpslr.NextLink))) +} + +// HealthProbeSettingsListResultPage contains a page of HealthProbeSettingsModel values. +type HealthProbeSettingsListResultPage struct { + fn func(HealthProbeSettingsListResult) (HealthProbeSettingsListResult, error) + hpslr HealthProbeSettingsListResult +} + +// 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. +func (page *HealthProbeSettingsListResultPage) Next() error { + next, err := page.fn(page.hpslr) + if err != nil { + return err + } + page.hpslr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HealthProbeSettingsListResultPage) NotDone() bool { + return !page.hpslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HealthProbeSettingsListResultPage) Response() HealthProbeSettingsListResult { + return page.hpslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HealthProbeSettingsListResultPage) Values() []HealthProbeSettingsModel { + if page.hpslr.IsEmpty() { + return nil + } + return *page.hpslr.Value +} + +// HealthProbeSettingsModel load balancing settings for a backend pool +type HealthProbeSettingsModel struct { + autorest.Response `json:"-"` + // HealthProbeSettingsProperties - Properties of the health probe settings + *HealthProbeSettingsProperties `json:"properties,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for HealthProbeSettingsModel. +func (hpsm HealthProbeSettingsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if hpsm.HealthProbeSettingsProperties != nil { + objectMap["properties"] = hpsm.HealthProbeSettingsProperties + } + if hpsm.Name != nil { + objectMap["name"] = hpsm.Name + } + if hpsm.Type != nil { + objectMap["type"] = hpsm.Type + } + if hpsm.ID != nil { + objectMap["id"] = hpsm.ID + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for HealthProbeSettingsModel struct. +func (hpsm *HealthProbeSettingsModel) 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 healthProbeSettingsProperties HealthProbeSettingsProperties + err = json.Unmarshal(*v, &healthProbeSettingsProperties) + if err != nil { + return err + } + hpsm.HealthProbeSettingsProperties = &healthProbeSettingsProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + hpsm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + hpsm.Type = &typeVar + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + hpsm.ID = &ID + } + } + } + + return nil +} + +// HealthProbeSettingsProperties the JSON object that contains the properties required to create a health probe +// settings. +type HealthProbeSettingsProperties struct { + // ResourceState - Resource status. Possible values include: 'ResourceStateCreating', 'ResourceStateEnabling', 'ResourceStateEnabled', 'ResourceStateDisabling', 'ResourceStateDisabled', 'ResourceStateDeleting' + ResourceState ResourceState `json:"resourceState,omitempty"` + // Path - The path to use for the health probe. Default is / + Path *string `json:"path,omitempty"` + // Protocol - Protocol scheme to use for this probe. Possible values include: 'HTTP', 'HTTPS' + Protocol Protocol `json:"protocol,omitempty"` + // IntervalInSeconds - The number of seconds between health probes. + IntervalInSeconds *int32 `json:"intervalInSeconds,omitempty"` +} + +// HealthProbeSettingsUpdateParameters l7 health probe settings for a backend pool +type HealthProbeSettingsUpdateParameters struct { + // Path - The path to use for the health probe. Default is / + Path *string `json:"path,omitempty"` + // Protocol - Protocol scheme to use for this probe. Possible values include: 'HTTP', 'HTTPS' + Protocol Protocol `json:"protocol,omitempty"` + // IntervalInSeconds - The number of seconds between health probes. + IntervalInSeconds *int32 `json:"intervalInSeconds,omitempty"` +} + +// KeyVaultCertificateSourceParameters parameters required for bring-your-own-certification via Key Vault +type KeyVaultCertificateSourceParameters struct { + // Vault - The Key Vault containing the SSL certificate + Vault *KeyVaultCertificateSourceParametersVault `json:"vault,omitempty"` + // SecretName - The name of the Key Vault secret representing the full certificate PFX + SecretName *string `json:"secretName,omitempty"` + // SecretVersion - The version of the Key Vault secret representing the full certificate PFX + SecretVersion *string `json:"secretVersion,omitempty"` +} + +// KeyVaultCertificateSourceParametersVault the Key Vault containing the SSL certificate +type KeyVaultCertificateSourceParametersVault struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// ListResult result of the request to list Front Doors. It contains a list of Front Door objects and a URL link to +// get the the next set of results. +type ListResult struct { + autorest.Response `json:"-"` + // Value - List of Front Doors within a resource group. + Value *[]FrontDoor `json:"value,omitempty"` + // NextLink - URL to get the next set of Front Door objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// ListResultIterator provides access to a complete listing of FrontDoor values. +type ListResultIterator struct { + i int + page ListResultPage +} + +// Next 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 *ListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListResultIterator) 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 ListResultIterator) Response() ListResult { + 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 ListResultIterator) Value() FrontDoor { + if !iter.page.NotDone() { + return FrontDoor{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (lr ListResult) IsEmpty() bool { + return lr.Value == nil || len(*lr.Value) == 0 +} + +// listResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lr ListResult) listResultPreparer() (*http.Request, error) { + if lr.NextLink == nil || len(to.String(lr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lr.NextLink))) +} + +// ListResultPage contains a page of FrontDoor values. +type ListResultPage struct { + fn func(ListResult) (ListResult, error) + lr ListResult +} + +// 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. +func (page *ListResultPage) Next() error { + next, err := page.fn(page.lr) + if err != nil { + return err + } + page.lr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListResultPage) NotDone() bool { + return !page.lr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListResultPage) Response() ListResult { + return page.lr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ListResultPage) Values() []FrontDoor { + if page.lr.IsEmpty() { + return nil + } + return *page.lr.Value +} + +// LoadBalancingSettingsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type LoadBalancingSettingsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *LoadBalancingSettingsCreateOrUpdateFuture) Result(client LoadBalancingSettingsClient) (lbsm LoadBalancingSettingsModel, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.LoadBalancingSettingsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if lbsm.Response.Response, err = future.GetResult(sender); err == nil && lbsm.Response.Response.StatusCode != http.StatusNoContent { + lbsm, err = client.CreateOrUpdateResponder(lbsm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsCreateOrUpdateFuture", "Result", lbsm.Response.Response, "Failure responding to request") + } + } + return +} + +// LoadBalancingSettingsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type LoadBalancingSettingsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *LoadBalancingSettingsDeleteFuture) Result(client LoadBalancingSettingsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.LoadBalancingSettingsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.LoadBalancingSettingsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// LoadBalancingSettingsListResult result of the request to list load balancing settings. It contains a list of +// load balancing settings objects and a URL link to get the the next set of results. +type LoadBalancingSettingsListResult struct { + autorest.Response `json:"-"` + // Value - List of Backend Pools within a Front Door. + Value *[]LoadBalancingSettingsModel `json:"value,omitempty"` + // NextLink - URL to get the next set of LoadBalancingSettings objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// LoadBalancingSettingsListResultIterator provides access to a complete listing of LoadBalancingSettingsModel +// values. +type LoadBalancingSettingsListResultIterator struct { + i int + page LoadBalancingSettingsListResultPage +} + +// Next 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 *LoadBalancingSettingsListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LoadBalancingSettingsListResultIterator) 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 LoadBalancingSettingsListResultIterator) Response() LoadBalancingSettingsListResult { + 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 LoadBalancingSettingsListResultIterator) Value() LoadBalancingSettingsModel { + if !iter.page.NotDone() { + return LoadBalancingSettingsModel{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (lbslr LoadBalancingSettingsListResult) IsEmpty() bool { + return lbslr.Value == nil || len(*lbslr.Value) == 0 +} + +// loadBalancingSettingsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lbslr LoadBalancingSettingsListResult) loadBalancingSettingsListResultPreparer() (*http.Request, error) { + if lbslr.NextLink == nil || len(to.String(lbslr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lbslr.NextLink))) +} + +// LoadBalancingSettingsListResultPage contains a page of LoadBalancingSettingsModel values. +type LoadBalancingSettingsListResultPage struct { + fn func(LoadBalancingSettingsListResult) (LoadBalancingSettingsListResult, error) + lbslr LoadBalancingSettingsListResult +} + +// 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. +func (page *LoadBalancingSettingsListResultPage) Next() error { + next, err := page.fn(page.lbslr) + if err != nil { + return err + } + page.lbslr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LoadBalancingSettingsListResultPage) NotDone() bool { + return !page.lbslr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LoadBalancingSettingsListResultPage) Response() LoadBalancingSettingsListResult { + return page.lbslr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LoadBalancingSettingsListResultPage) Values() []LoadBalancingSettingsModel { + if page.lbslr.IsEmpty() { + return nil + } + return *page.lbslr.Value +} + +// LoadBalancingSettingsModel load balancing settings for a backend pool +type LoadBalancingSettingsModel struct { + autorest.Response `json:"-"` + // LoadBalancingSettingsProperties - Properties of the load balancing settings + *LoadBalancingSettingsProperties `json:"properties,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for LoadBalancingSettingsModel. +func (lbsm LoadBalancingSettingsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lbsm.LoadBalancingSettingsProperties != nil { + objectMap["properties"] = lbsm.LoadBalancingSettingsProperties + } + if lbsm.Name != nil { + objectMap["name"] = lbsm.Name + } + if lbsm.Type != nil { + objectMap["type"] = lbsm.Type + } + if lbsm.ID != nil { + objectMap["id"] = lbsm.ID + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LoadBalancingSettingsModel struct. +func (lbsm *LoadBalancingSettingsModel) 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 loadBalancingSettingsProperties LoadBalancingSettingsProperties + err = json.Unmarshal(*v, &loadBalancingSettingsProperties) + if err != nil { + return err + } + lbsm.LoadBalancingSettingsProperties = &loadBalancingSettingsProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + lbsm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + lbsm.Type = &typeVar + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + lbsm.ID = &ID + } + } + } + + return nil +} + +// LoadBalancingSettingsProperties the JSON object that contains the properties required to create load balancing +// settings +type LoadBalancingSettingsProperties struct { + // ResourceState - Resource status. Possible values include: 'ResourceStateCreating', 'ResourceStateEnabling', 'ResourceStateEnabled', 'ResourceStateDisabling', 'ResourceStateDisabled', 'ResourceStateDeleting' + ResourceState ResourceState `json:"resourceState,omitempty"` + // SampleSize - The number of samples to consider for load balancing decisions + SampleSize *int32 `json:"sampleSize,omitempty"` + // SuccessfulSamplesRequired - The number of samples within the sample period that must succeed + SuccessfulSamplesRequired *int32 `json:"successfulSamplesRequired,omitempty"` + // AdditionalLatencyMilliseconds - The additional latency in milliseconds for probes to fall into the lowest latency bucket + AdditionalLatencyMilliseconds *int32 `json:"additionalLatencyMilliseconds,omitempty"` +} + +// LoadBalancingSettingsUpdateParameters round-Robin load balancing settings for a backend pool +type LoadBalancingSettingsUpdateParameters struct { + // SampleSize - The number of samples to consider for load balancing decisions + SampleSize *int32 `json:"sampleSize,omitempty"` + // SuccessfulSamplesRequired - The number of samples within the sample period that must succeed + SuccessfulSamplesRequired *int32 `json:"successfulSamplesRequired,omitempty"` + // AdditionalLatencyMilliseconds - The additional latency in milliseconds for probes to fall into the lowest latency bucket + AdditionalLatencyMilliseconds *int32 `json:"additionalLatencyMilliseconds,omitempty"` +} + +// BasicManagedRuleSet base class for all types of ManagedRuleSet. +type BasicManagedRuleSet interface { + AsAzureManagedRuleSet() (*AzureManagedRuleSet, bool) + AsManagedRuleSet() (*ManagedRuleSet, bool) +} + +// ManagedRuleSet base class for all types of ManagedRuleSet. +type ManagedRuleSet struct { + // Priority - Describes priority of the rule + Priority *int32 `json:"priority,omitempty"` + // Version - defines version of the ruleset + Version *int32 `json:"version,omitempty"` + // RuleSetType - Possible values include: 'RuleSetTypeUnknown', 'RuleSetTypeAzureManagedRuleSet' + RuleSetType RuleSetType `json:"ruleSetType,omitempty"` +} + +func unmarshalBasicManagedRuleSet(body []byte) (BasicManagedRuleSet, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["ruleSetType"] { + case string(RuleSetTypeAzureManagedRuleSet): + var amrs AzureManagedRuleSet + err := json.Unmarshal(body, &amrs) + return amrs, err + default: + var mrs ManagedRuleSet + err := json.Unmarshal(body, &mrs) + return mrs, err + } +} +func unmarshalBasicManagedRuleSetArray(body []byte) ([]BasicManagedRuleSet, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + mrsArray := make([]BasicManagedRuleSet, len(rawMessages)) + + for index, rawMessage := range rawMessages { + mrs, err := unmarshalBasicManagedRuleSet(*rawMessage) + if err != nil { + return nil, err + } + mrsArray[index] = mrs + } + return mrsArray, nil +} + +// MarshalJSON is the custom marshaler for ManagedRuleSet. +func (mrs ManagedRuleSet) MarshalJSON() ([]byte, error) { + mrs.RuleSetType = RuleSetTypeUnknown + objectMap := make(map[string]interface{}) + if mrs.Priority != nil { + objectMap["priority"] = mrs.Priority + } + if mrs.Version != nil { + objectMap["version"] = mrs.Version + } + if mrs.RuleSetType != "" { + objectMap["ruleSetType"] = mrs.RuleSetType + } + return json.Marshal(objectMap) +} + +// AsAzureManagedRuleSet is the BasicManagedRuleSet implementation for ManagedRuleSet. +func (mrs ManagedRuleSet) AsAzureManagedRuleSet() (*AzureManagedRuleSet, bool) { + return nil, false +} + +// AsManagedRuleSet is the BasicManagedRuleSet implementation for ManagedRuleSet. +func (mrs ManagedRuleSet) AsManagedRuleSet() (*ManagedRuleSet, bool) { + return &mrs, true +} + +// AsBasicManagedRuleSet is the BasicManagedRuleSet implementation for ManagedRuleSet. +func (mrs ManagedRuleSet) AsBasicManagedRuleSet() (BasicManagedRuleSet, bool) { + return &mrs, true +} + +// ManagedRuleSets defines ManagedRuleSets - array of managedRuleSet +type ManagedRuleSets struct { + // RuleSets - List of rules + RuleSets *[]BasicManagedRuleSet `json:"ruleSets,omitempty"` +} + +// UnmarshalJSON is the custom unmarshaler for ManagedRuleSets struct. +func (mrs *ManagedRuleSets) 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 "ruleSets": + if v != nil { + ruleSets, err := unmarshalBasicManagedRuleSetArray(*v) + if err != nil { + return err + } + mrs.RuleSets = &ruleSets + } + } + } + + return nil +} + +// MatchCondition1 define match conditions +type MatchCondition1 struct { + // MatchVariable - Match Variable. Possible values include: 'RemoteAddr', 'RequestMethod', 'QueryString', 'PostArgs', 'RequestURI', 'RequestHeader', 'RequestBody' + MatchVariable MatchCondition `json:"matchVariable,omitempty"` + // Selector - Name of selector in RequestHeader or RequestBody to be matched + Selector *string `json:"selector,omitempty"` + // Operator - Describes operator to be matched. Possible values include: 'Any', 'IPMatch', 'GeoMatch', 'Equal', 'Contains', 'LessThan', 'GreaterThan', 'LessThanOrEqual', 'GreaterThanOrEqual', 'BeginsWith', 'EndsWith' + Operator Operator `json:"operator,omitempty"` + // NegateCondition - Describes if this is negate condition or not + NegateCondition *bool `json:"negateCondition,omitempty"` + // MatchValue - Match value + MatchValue *[]string `json:"matchValue,omitempty"` +} + +// PoliciesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type PoliciesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PoliciesDeleteFuture) Result(client PoliciesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.PoliciesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PolicySettings defines contents of a web application firewall global configuration +type PolicySettings struct { + // EnabledState - describes if the policy is in enabled state or disabled state. Possible values include: 'EnabledStateDisabled', 'EnabledStateEnabled' + EnabledState EnabledState `json:"enabledState,omitempty"` + // Mode - Describes if it is in detection mode or prevention mode at policy level. Possible values include: 'Prevention', 'Detection' + Mode Mode `json:"mode,omitempty"` +} + +// Properties the JSON object that contains the properties required to create an endpoint. +type Properties struct { + // ResourceState - Resource status of the Front Door. Possible values include: 'ResourceStateCreating', 'ResourceStateEnabling', 'ResourceStateEnabled', 'ResourceStateDisabling', 'ResourceStateDisabled', 'ResourceStateDeleting' + ResourceState ResourceState `json:"resourceState,omitempty"` + // ProvisioningState - Provisioning state of the Front Door. + ProvisioningState *string `json:"provisioningState,omitempty"` + // Cname - The host that each frontendEndpoint must CNAME to. + Cname *string `json:"cname,omitempty"` + // FriendlyName - A friendly name for the frontDoor + FriendlyName *string `json:"friendlyName,omitempty"` + // RoutingRules - Routing rules associated with this Front Door. + RoutingRules *[]RoutingRule `json:"routingRules,omitempty"` + // LoadBalancingSettings - Load balancing settings associated with this Front Door instance. + LoadBalancingSettings *[]LoadBalancingSettingsModel `json:"loadBalancingSettings,omitempty"` + // HealthProbeSettings - Health probe settings associated with this Front Door instance. + HealthProbeSettings *[]HealthProbeSettingsModel `json:"healthProbeSettings,omitempty"` + // BackendPools - Backend pools available to routing rules. + BackendPools *[]BackendPool `json:"backendPools,omitempty"` + // FrontendEndpoints - Frontend endpoints available to routing rules. + FrontendEndpoints *[]FrontendEndpoint `json:"frontendEndpoints,omitempty"` + // EnabledState - Operational status of the Front Door load balancer. Permitted values are 'Enabled' or 'Disabled'. Possible values include: 'EnabledStateEnumEnabled', 'EnabledStateEnumDisabled' + EnabledState EnabledStateEnum `json:"enabledState,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 common resource representation. +type Resource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// RoutingRule a routing rule represents a specification for traffic to treat and where to send it, along with +// health probe information. +type RoutingRule struct { + autorest.Response `json:"-"` + // RoutingRuleProperties - Properties of the Front Door Routing Rule + *RoutingRuleProperties `json:"properties,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoutingRule. +func (rr RoutingRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rr.RoutingRuleProperties != nil { + objectMap["properties"] = rr.RoutingRuleProperties + } + if rr.Name != nil { + objectMap["name"] = rr.Name + } + if rr.Type != nil { + objectMap["type"] = rr.Type + } + if rr.ID != nil { + objectMap["id"] = rr.ID + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoutingRule struct. +func (rr *RoutingRule) 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 routingRuleProperties RoutingRuleProperties + err = json.Unmarshal(*v, &routingRuleProperties) + if err != nil { + return err + } + rr.RoutingRuleProperties = &routingRuleProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rr.Type = &typeVar + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rr.ID = &ID + } + } + } + + return nil +} + +// RoutingRuleListResult result of the request to list Routing Rules. It contains a list of Routing Rule objects +// and a URL link to get the the next set of results. +type RoutingRuleListResult struct { + autorest.Response `json:"-"` + // Value - List of Routing Rules within a Front Door. + Value *[]RoutingRule `json:"value,omitempty"` + // NextLink - URL to get the next set of RoutingRule objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoutingRuleListResultIterator provides access to a complete listing of RoutingRule values. +type RoutingRuleListResultIterator struct { + i int + page RoutingRuleListResultPage +} + +// Next 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 *RoutingRuleListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoutingRuleListResultIterator) 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 RoutingRuleListResultIterator) Response() RoutingRuleListResult { + 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 RoutingRuleListResultIterator) Value() RoutingRule { + if !iter.page.NotDone() { + return RoutingRule{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (rrlr RoutingRuleListResult) IsEmpty() bool { + return rrlr.Value == nil || len(*rrlr.Value) == 0 +} + +// routingRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rrlr RoutingRuleListResult) routingRuleListResultPreparer() (*http.Request, error) { + if rrlr.NextLink == nil || len(to.String(rrlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rrlr.NextLink))) +} + +// RoutingRuleListResultPage contains a page of RoutingRule values. +type RoutingRuleListResultPage struct { + fn func(RoutingRuleListResult) (RoutingRuleListResult, error) + rrlr RoutingRuleListResult +} + +// 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. +func (page *RoutingRuleListResultPage) Next() error { + next, err := page.fn(page.rrlr) + if err != nil { + return err + } + page.rrlr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoutingRuleListResultPage) NotDone() bool { + return !page.rrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoutingRuleListResultPage) Response() RoutingRuleListResult { + return page.rrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoutingRuleListResultPage) Values() []RoutingRule { + if page.rrlr.IsEmpty() { + return nil + } + return *page.rrlr.Value +} + +// RoutingRuleProperties the JSON object that contains the properties required to create a routing rule. +type RoutingRuleProperties struct { + // ResourceState - Resource status. Possible values include: 'ResourceStateCreating', 'ResourceStateEnabling', 'ResourceStateEnabled', 'ResourceStateDisabling', 'ResourceStateDisabled', 'ResourceStateDeleting' + ResourceState ResourceState `json:"resourceState,omitempty"` + // FrontendEndpoints - Frontend endpoints associated with this rule + FrontendEndpoints *[]SubResource `json:"frontendEndpoints,omitempty"` + // AcceptedProtocols - Protocol schemes to match for this rule + AcceptedProtocols *[]Protocol `json:"acceptedProtocols,omitempty"` + // PatternsToMatch - The route patterns of the rule. + PatternsToMatch *[]string `json:"patternsToMatch,omitempty"` + // CustomForwardingPath - A custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path. + CustomForwardingPath *string `json:"customForwardingPath,omitempty"` + // ForwardingProtocol - Protocol this rule will use when forwarding traffic to backends. Possible values include: 'HTTPOnly', 'HTTPSOnly', 'MatchRequest' + ForwardingProtocol ForwardingProtocol `json:"forwardingProtocol,omitempty"` + // CacheConfiguration - The caching configuration associated with this rule. + CacheConfiguration *CacheConfiguration `json:"cacheConfiguration,omitempty"` + // BackendPool - A reference to the BackendPool which this rule routes to. + BackendPool *SubResource `json:"backendPool,omitempty"` + // EnabledState - Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'. Possible values include: 'EnabledStateEnumEnabled', 'EnabledStateEnumDisabled' + EnabledState EnabledStateEnum `json:"enabledState,omitempty"` +} + +// RoutingRulesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type RoutingRulesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RoutingRulesCreateOrUpdateFuture) Result(client RoutingRulesClient) (rr RoutingRule, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.RoutingRulesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if rr.Response.Response, err = future.GetResult(sender); err == nil && rr.Response.Response.StatusCode != http.StatusNoContent { + rr, err = client.CreateOrUpdateResponder(rr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesCreateOrUpdateFuture", "Result", rr.Response.Response, "Failure responding to request") + } + } + return +} + +// RoutingRulesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type RoutingRulesDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *RoutingRulesDeleteFuture) Result(client RoutingRulesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("frontdoor.RoutingRulesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// RoutingRuleUpdateParameters routing rules to apply to an endpoint +type RoutingRuleUpdateParameters struct { + // FrontendEndpoints - Frontend endpoints associated with this rule + FrontendEndpoints *[]SubResource `json:"frontendEndpoints,omitempty"` + // AcceptedProtocols - Protocol schemes to match for this rule + AcceptedProtocols *[]Protocol `json:"acceptedProtocols,omitempty"` + // PatternsToMatch - The route patterns of the rule. + PatternsToMatch *[]string `json:"patternsToMatch,omitempty"` + // CustomForwardingPath - A custom path used to rewrite resource paths matched by this rule. Leave empty to use incoming path. + CustomForwardingPath *string `json:"customForwardingPath,omitempty"` + // ForwardingProtocol - Protocol this rule will use when forwarding traffic to backends. Possible values include: 'HTTPOnly', 'HTTPSOnly', 'MatchRequest' + ForwardingProtocol ForwardingProtocol `json:"forwardingProtocol,omitempty"` + // CacheConfiguration - The caching configuration associated with this rule. + CacheConfiguration *CacheConfiguration `json:"cacheConfiguration,omitempty"` + // BackendPool - A reference to the BackendPool which this rule routes to. + BackendPool *SubResource `json:"backendPool,omitempty"` + // EnabledState - Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'. Possible values include: 'EnabledStateEnumEnabled', 'EnabledStateEnumDisabled' + EnabledState EnabledStateEnum `json:"enabledState,omitempty"` +} + +// SubResource reference to another subresource. +type SubResource struct { + // ID - Resource ID. + ID *string `json:"id,omitempty"` +} + +// TagsObject tags object for patch operations. +type TagsObject struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsObject. +func (toVar TagsObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if toVar.Tags != nil { + objectMap["tags"] = toVar.Tags + } + return json.Marshal(objectMap) +} + +// UpdateParameters the properties needed to update a Front Door +type UpdateParameters struct { + // FriendlyName - A friendly name for the frontDoor + FriendlyName *string `json:"friendlyName,omitempty"` + // RoutingRules - Routing rules associated with this Front Door. + RoutingRules *[]RoutingRule `json:"routingRules,omitempty"` + // LoadBalancingSettings - Load balancing settings associated with this Front Door instance. + LoadBalancingSettings *[]LoadBalancingSettingsModel `json:"loadBalancingSettings,omitempty"` + // HealthProbeSettings - Health probe settings associated with this Front Door instance. + HealthProbeSettings *[]HealthProbeSettingsModel `json:"healthProbeSettings,omitempty"` + // BackendPools - Backend pools available to routing rules. + BackendPools *[]BackendPool `json:"backendPools,omitempty"` + // FrontendEndpoints - Frontend endpoints available to routing rules. + FrontendEndpoints *[]FrontendEndpoint `json:"frontendEndpoints,omitempty"` + // EnabledState - Operational status of the Front Door load balancer. Permitted values are 'Enabled' or 'Disabled'. Possible values include: 'EnabledStateEnumEnabled', 'EnabledStateEnumDisabled' + EnabledState EnabledStateEnum `json:"enabledState,omitempty"` +} + +// 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 - Indicates whether the custom domain is valid or not. + CustomDomainValidated *bool `json:"customDomainValidated,omitempty"` + // Reason - The reason why the custom domain is not valid. + Reason *string `json:"reason,omitempty"` + // Message - Error message describing why the custom domain is not valid. + Message *string `json:"message,omitempty"` +} + +// WebApplicationFirewallPolicy defines web application firewall policy. +type WebApplicationFirewallPolicy struct { + autorest.Response `json:"-"` + // WebApplicationFirewallPolicyPropertiesFormat - Properties of the web application firewall policy. + *WebApplicationFirewallPolicyPropertiesFormat `json:"properties,omitempty"` + // Etag - Gets a unique read-only string that changes whenever the resource is updated. + Etag *string `json:"etag,omitempty"` + // ID - Resource ID. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Location - Resource location. + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for WebApplicationFirewallPolicy. +func (wafp WebApplicationFirewallPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wafp.WebApplicationFirewallPolicyPropertiesFormat != nil { + objectMap["properties"] = wafp.WebApplicationFirewallPolicyPropertiesFormat + } + if wafp.Etag != nil { + objectMap["etag"] = wafp.Etag + } + if wafp.ID != nil { + objectMap["id"] = wafp.ID + } + if wafp.Name != nil { + objectMap["name"] = wafp.Name + } + if wafp.Type != nil { + objectMap["type"] = wafp.Type + } + if wafp.Location != nil { + objectMap["location"] = wafp.Location + } + if wafp.Tags != nil { + objectMap["tags"] = wafp.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for WebApplicationFirewallPolicy struct. +func (wafp *WebApplicationFirewallPolicy) 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 webApplicationFirewallPolicyPropertiesFormat WebApplicationFirewallPolicyPropertiesFormat + err = json.Unmarshal(*v, &webApplicationFirewallPolicyPropertiesFormat) + if err != nil { + return err + } + wafp.WebApplicationFirewallPolicyPropertiesFormat = &webApplicationFirewallPolicyPropertiesFormat + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + wafp.Etag = &etag + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wafp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wafp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wafp.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + wafp.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + wafp.Tags = tags + } + } + } + + return nil +} + +// WebApplicationFirewallPolicyListResult result of the request to list WebApplicationFirewallPolicies. It contains +// a list of WebApplicationFirewallPolicy objects and a URL link to get the the next set of results. +type WebApplicationFirewallPolicyListResult struct { + autorest.Response `json:"-"` + // Value - List of WebApplicationFirewallPolicies within a resource group. + Value *[]WebApplicationFirewallPolicy `json:"value,omitempty"` + // NextLink - URL to get the next set of WebApplicationFirewallPolicy objects if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// WebApplicationFirewallPolicyListResultIterator provides access to a complete listing of +// WebApplicationFirewallPolicy values. +type WebApplicationFirewallPolicyListResultIterator struct { + i int + page WebApplicationFirewallPolicyListResultPage +} + +// Next 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 *WebApplicationFirewallPolicyListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WebApplicationFirewallPolicyListResultIterator) 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 WebApplicationFirewallPolicyListResultIterator) Response() WebApplicationFirewallPolicyListResult { + 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 WebApplicationFirewallPolicyListResultIterator) Value() WebApplicationFirewallPolicy { + if !iter.page.NotDone() { + return WebApplicationFirewallPolicy{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (wafplr WebApplicationFirewallPolicyListResult) IsEmpty() bool { + return wafplr.Value == nil || len(*wafplr.Value) == 0 +} + +// webApplicationFirewallPolicyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wafplr WebApplicationFirewallPolicyListResult) webApplicationFirewallPolicyListResultPreparer() (*http.Request, error) { + if wafplr.NextLink == nil || len(to.String(wafplr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wafplr.NextLink))) +} + +// WebApplicationFirewallPolicyListResultPage contains a page of WebApplicationFirewallPolicy values. +type WebApplicationFirewallPolicyListResultPage struct { + fn func(WebApplicationFirewallPolicyListResult) (WebApplicationFirewallPolicyListResult, error) + wafplr WebApplicationFirewallPolicyListResult +} + +// 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. +func (page *WebApplicationFirewallPolicyListResultPage) Next() error { + next, err := page.fn(page.wafplr) + if err != nil { + return err + } + page.wafplr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WebApplicationFirewallPolicyListResultPage) NotDone() bool { + return !page.wafplr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WebApplicationFirewallPolicyListResultPage) Response() WebApplicationFirewallPolicyListResult { + return page.wafplr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WebApplicationFirewallPolicyListResultPage) Values() []WebApplicationFirewallPolicy { + if page.wafplr.IsEmpty() { + return nil + } + return *page.wafplr.Value +} + +// WebApplicationFirewallPolicyPropertiesFormat defines web application firewall policy properties +type WebApplicationFirewallPolicyPropertiesFormat struct { + // PolicySettings - Describes policySettings for policy + PolicySettings *PolicySettings `json:"policySettings,omitempty"` + // CustomRules - Describes custom rules inside the policy + CustomRules *CustomRules `json:"customRules,omitempty"` + // ManagedRules - Describes managed rules inside the policy + ManagedRules *ManagedRuleSets `json:"managedRules,omitempty"` + // ProvisioningState - Provisioning state of the WebApplicationFirewallPolicy. + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/policies.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/policies.go new file mode 100644 index 000000000000..b87343f1e318 --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/policies.go @@ -0,0 +1,359 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// PoliciesClient is the frontdoor Client +type PoliciesClient struct { + BaseClient +} + +// NewPoliciesClient creates an instance of the PoliciesClient client. +func NewPoliciesClient(subscriptionID string) PoliciesClient { + return NewPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPoliciesClientWithBaseURI creates an instance of the PoliciesClient client. +func NewPoliciesClientWithBaseURI(baseURI string, subscriptionID string) PoliciesClient { + return PoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or update policy with specified ruleset name within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// policyName - the name of the resource group. +// parameters - policy to be created. +func (client PoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, policyName string, parameters WebApplicationFirewallPolicy) (result WebApplicationFirewallPolicy, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: policyName, + Constraints: []validation.Constraint{{Target: "policyName", Name: validation.MaxLength, Rule: 128, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.PoliciesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, policyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PoliciesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, policyName string, parameters WebApplicationFirewallPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyName": autorest.Encode("path", policyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result WebApplicationFirewallPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes Policy +// Parameters: +// resourceGroupName - the name of the resource group. +// policyName - the name of the resource group. +func (client PoliciesClient) Delete(ctx context.Context, resourceGroupName string, policyName string) (result PoliciesDeleteFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: policyName, + Constraints: []validation.Constraint{{Target: "policyName", Name: validation.MaxLength, Rule: 128, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.PoliciesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, policyName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PoliciesClient) DeletePreparer(ctx context.Context, resourceGroupName string, policyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyName": autorest.Encode("path", policyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PoliciesClient) DeleteSender(req *http.Request) (future PoliciesDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get retrieve protection policy with specified name within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +// policyName - the name of the resource group. +func (client PoliciesClient) Get(ctx context.Context, resourceGroupName string, policyName string) (result WebApplicationFirewallPolicy, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: policyName, + Constraints: []validation.Constraint{{Target: "policyName", Name: validation.MaxLength, Rule: 128, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.PoliciesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, policyName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PoliciesClient) GetPreparer(ctx context.Context, resourceGroupName string, policyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyName": autorest.Encode("path", policyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PoliciesClient) GetResponder(resp *http.Response) (result WebApplicationFirewallPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all of the protection policies within a resource group. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client PoliciesClient) List(ctx context.Context, resourceGroupName string) (result WebApplicationFirewallPolicyListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.wafplr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "List", resp, "Failure sending request") + return + } + + result.wafplr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client PoliciesClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PoliciesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PoliciesClient) ListResponder(resp *http.Response) (result WebApplicationFirewallPolicyListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PoliciesClient) listNextResults(lastResults WebApplicationFirewallPolicyListResult) (result WebApplicationFirewallPolicyListResult, err error) { + req, err := lastResults.webApplicationFirewallPolicyListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.PoliciesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PoliciesClient) ListComplete(ctx context.Context, resourceGroupName string) (result WebApplicationFirewallPolicyListResultIterator, err error) { + result.page, err = client.List(ctx, resourceGroupName) + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/routingrules.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/routingrules.go new file mode 100644 index 000000000000..01922b3225c0 --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/routingrules.go @@ -0,0 +1,413 @@ +package frontdoor + +// 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" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// RoutingRulesClient is the frontdoor Client +type RoutingRulesClient struct { + BaseClient +} + +// NewRoutingRulesClient creates an instance of the RoutingRulesClient client. +func NewRoutingRulesClient(subscriptionID string) RoutingRulesClient { + return NewRoutingRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoutingRulesClientWithBaseURI creates an instance of the RoutingRulesClient client. +func NewRoutingRulesClientWithBaseURI(baseURI string, subscriptionID string) RoutingRulesClient { + return RoutingRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new Routing Rule with the specified Rule name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// routingRuleName - name of the Routing Rule which is unique within the Front Door. +// routingRuleParameters - routing Rule properties needed to create a new Front Door. +func (client RoutingRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, routingRuleName string, routingRuleParameters RoutingRule) (result RoutingRulesCreateOrUpdateFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: routingRuleName, + Constraints: []validation.Constraint{{Target: "routingRuleName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "routingRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "routingRuleName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.RoutingRulesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, frontDoorName, routingRuleName, routingRuleParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client RoutingRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, routingRuleName string, routingRuleParameters RoutingRule) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routingRuleName": autorest.Encode("path", routingRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/routingRules/{routingRuleName}", pathParameters), + autorest.WithJSON(routingRuleParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client RoutingRulesClient) CreateOrUpdateSender(req *http.Request) (future RoutingRulesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client RoutingRulesClient) CreateOrUpdateResponder(resp *http.Response) (result RoutingRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an existing Routing Rule with the specified parameters. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// routingRuleName - name of the Routing Rule which is unique within the Front Door. +func (client RoutingRulesClient) Delete(ctx context.Context, resourceGroupName string, frontDoorName string, routingRuleName string) (result RoutingRulesDeleteFuture, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: routingRuleName, + Constraints: []validation.Constraint{{Target: "routingRuleName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "routingRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "routingRuleName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.RoutingRulesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, frontDoorName, routingRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client RoutingRulesClient) DeletePreparer(ctx context.Context, resourceGroupName string, frontDoorName string, routingRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routingRuleName": autorest.Encode("path", routingRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/routingRules/{routingRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client RoutingRulesClient) DeleteSender(req *http.Request) (future RoutingRulesDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client RoutingRulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a Routing Rule with the specified Rule name within the specified Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +// routingRuleName - name of the Routing Rule which is unique within the Front Door. +func (client RoutingRulesClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, routingRuleName string) (result RoutingRule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}, + {TargetValue: routingRuleName, + Constraints: []validation.Constraint{{Target: "routingRuleName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "routingRuleName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "routingRuleName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.RoutingRulesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, frontDoorName, routingRuleName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RoutingRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, frontDoorName string, routingRuleName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routingRuleName": autorest.Encode("path", routingRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/routingRules/{routingRuleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RoutingRulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RoutingRulesClient) GetResponder(resp *http.Response) (result RoutingRule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByFrontDoor lists all of the Routing Rules within a Front Door. +// Parameters: +// resourceGroupName - name of the Resource group within the Azure subscription. +// frontDoorName - name of the Front Door which is globally unique. +func (client RoutingRulesClient) ListByFrontDoor(ctx context.Context, resourceGroupName string, frontDoorName string) (result RoutingRuleListResultPage, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 80, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9_\-\(\)\.]*[^\.]$`, Chain: nil}}}, + {TargetValue: frontDoorName, + Constraints: []validation.Constraint{{Target: "frontDoorName", Name: validation.MaxLength, Rule: 74, Chain: nil}, + {Target: "frontDoorName", Name: validation.MinLength, Rule: 5, Chain: nil}, + {Target: "frontDoorName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([-a-zA-Z0-9][a-zA-Z0-9])$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("frontdoor.RoutingRulesClient", "ListByFrontDoor", err.Error()) + } + + result.fn = client.listByFrontDoorNextResults + req, err := client.ListByFrontDoorPreparer(ctx, resourceGroupName, frontDoorName) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "ListByFrontDoor", nil, "Failure preparing request") + return + } + + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.rrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "ListByFrontDoor", resp, "Failure sending request") + return + } + + result.rrlr, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "ListByFrontDoor", resp, "Failure responding to request") + } + + return +} + +// ListByFrontDoorPreparer prepares the ListByFrontDoor request. +func (client RoutingRulesClient) ListByFrontDoorPreparer(ctx context.Context, resourceGroupName string, frontDoorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "frontDoorName": autorest.Encode("path", frontDoorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-08-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/routingRules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByFrontDoorSender sends the ListByFrontDoor request. The method will close the +// http.Response Body if it receives an error. +func (client RoutingRulesClient) ListByFrontDoorSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByFrontDoorResponder handles the response to the ListByFrontDoor request. The method always +// closes the http.Response Body. +func (client RoutingRulesClient) ListByFrontDoorResponder(resp *http.Response) (result RoutingRuleListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByFrontDoorNextResults retrieves the next set of results, if any. +func (client RoutingRulesClient) listByFrontDoorNextResults(lastResults RoutingRuleListResult) (result RoutingRuleListResult, err error) { + req, err := lastResults.routingRuleListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "listByFrontDoorNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByFrontDoorSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "listByFrontDoorNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByFrontDoorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "frontdoor.RoutingRulesClient", "listByFrontDoorNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByFrontDoorComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoutingRulesClient) ListByFrontDoorComplete(ctx context.Context, resourceGroupName string, frontDoorName string) (result RoutingRuleListResultIterator, err error) { + result.page, err = client.ListByFrontDoor(ctx, resourceGroupName, frontDoorName) + return +} diff --git a/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/version.go b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/version.go new file mode 100644 index 000000000000..44ae30b1f3ca --- /dev/null +++ b/services/preview/frontdoor/mgmt/2018-08-01-preview/frontdoor/version.go @@ -0,0 +1,30 @@ +package frontdoor + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " frontdoor/2018-08-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}