From 656e65b4979a5e6aed6899e203b9d7e3ef154890 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 21 Jan 2021 09:25:19 +0000 Subject: [PATCH] CodeGen from PR 12533 in Azure/azure-rest-api-specs Merge 5144b1fcf54a0c80b07c01404dfb168ef3399ad2 into c658577f43a6956d745862a121c7a7393e1eb108 --- .../Generated/AFDCustomDomainsOperations.cs | 1675 ++++++++++++ .../AFDCustomDomainsOperationsExtensions.cs | 557 ++++ .../src/Generated/AFDEndpointsOperations.cs | 2297 +++++++++++++++++ .../AFDEndpointsOperationsExtensions.cs | 715 +++++ .../Generated/AFDOriginGroupsOperations.cs | 1799 +++++++++++++ .../AFDOriginGroupsOperationsExtensions.cs | 519 ++++ .../src/Generated/AFDOriginsOperations.cs | 1470 +++++++++++ .../AFDOriginsOperationsExtensions.cs | 487 ++++ .../src/Generated/AFDProfilesOperations.cs | 654 +++++ .../AFDProfilesOperationsExtensions.cs | 147 ++ .../src/Generated/CdnManagementClient.cs | 80 +- .../Generated/IAFDCustomDomainsOperations.cs | 347 +++ .../src/Generated/IAFDEndpointsOperations.cs | 442 ++++ .../Generated/IAFDOriginGroupsOperations.cs | 328 +++ .../src/Generated/IAFDOriginsOperations.cs | 300 +++ .../src/Generated/IAFDProfilesOperations.cs | 105 + .../src/Generated/ICdnManagementClient.cs | 62 +- .../src/Generated/ILogAnalyticsOperations.cs | 237 ++ .../src/Generated/IRoutesOperations.cs | 314 +++ .../src/Generated/IRuleSetsOperations.cs | 266 ++ .../src/Generated/IRulesOperations.cs | 300 +++ .../src/Generated/ISecretsOperations.cs | 276 ++ .../Generated/ISecurityPoliciesOperations.cs | 276 ++ .../src/Generated/IValidateOperations.cs | 53 + .../src/Generated/LogAnalyticsOperations.cs | 1497 +++++++++++ .../LogAnalyticsOperationsExtensions.cs | 387 +++ .../src/Generated/Models/AFDDomain.cs | 146 ++ .../Models/AFDDomainHttpsParameters.cs | 88 + .../Models/AFDDomainUpdateParameters.cs | 82 + .../src/Generated/Models/AFDEndpoint.cs | 125 + .../Generated/Models/AFDEndpointProtocols.cs | 22 + .../Models/AFDEndpointUpdateParameters.cs | 95 + .../src/Generated/Models/AFDOrigin.cs | 226 ++ .../src/Generated/Models/AFDOriginGroup.cs | 157 ++ .../Models/AFDOriginGroupUpdateParameters.cs | 134 + .../Models/AFDOriginUpdateParameters.cs | 195 ++ .../Generated/Models/AFDStateProperties.cs | 64 + .../Generated/Models/AfdCertificateType.cs | 22 + .../src/Generated/Models/AfdErrorResponse.cs | 56 + .../Models/AfdErrorResponseException.cs | 62 + .../Generated/Models/AfdMinimumTlsVersion.cs | 60 + .../Generated/Models/AfdProvisioningState.cs | 25 + .../Generated/Models/AfdPurgeParameters.cs | 77 + .../Models/CdnWebApplicationFirewallPolicy.cs | 4 +- .../src/Generated/Models/Certificate.cs | 67 + .../Generated/Models/CompressionSettings.cs | 72 + .../Generated/Models/ContinentsResponse.cs | 57 + .../ContinentsResponseContinentsItem.cs | 48 + .../ContinentsResponseCountryOrRegionsItem.cs | 54 + .../Models/CookiesMatchConditionParameters.cs | 21 +- .../src/Generated/Models/CookiesOperator.cs | 1 + .../src/Generated/Models/CustomDomain.cs | 4 +- .../Generated/Models/CustomerCertificate.cs | 106 + .../Models/CustomerCertificateParameters.cs | 145 ++ .../DeliveryRuleHttpVersionCondition.cs | 4 - .../Models/DeliveryRuleIsDeviceCondition.cs | 4 - .../DeliveryRuleRequestMethodCondition.cs | 4 - .../DeliveryRuleRequestSchemeCondition.cs | 4 - .../src/Generated/Models/DeploymentStatus.cs | 24 + .../Models/DomainValidationProperties.cs | 61 + .../Generated/Models/DomainValidationState.cs | 26 + .../src/Generated/Models/EdgeNode.cs | 4 +- .../src/Generated/Models/EnabledState.cs | 22 + .../src/Generated/Models/Endpoint.cs | 4 +- .../Generated/Models/ForwardingProtocol.cs | 23 + .../HttpVersionMatchConditionParameters.cs | 20 +- .../src/Generated/Models/HttpsRedirect.cs | 22 + .../src/Generated/Models/IdentityType.cs | 24 + .../IsDeviceMatchConditionParameters.cs | 20 +- .../KeyVaultCertificateSourceParameters.cs | 6 +- .../Generated/Models/LinkToDefaultDomain.cs | 22 + .../Models/LoadBalancingSettingsParameters.cs | 76 + .../Generated/Models/ManagedCertificate.cs | 46 + .../Models/ManagedCertificateParameters.cs | 95 + .../Models/MatchProcessingBehavior.cs | 22 + .../src/Generated/Models/MetricsResponse.cs | 72 + .../Models/MetricsResponseSeriesItem.cs | 70 + .../MetricsResponseSeriesItemDataItem.cs | 54 + .../MetricsResponseSeriesItemGroupsItem.cs | 54 + .../src/Generated/Models/Origin.cs | 4 +- .../src/Generated/Models/OriginGroup.cs | 4 +- .../Models/OriginGroupOverrideAction.cs | 72 + .../OriginGroupOverrideActionParameters.cs | 81 + .../PostArgsMatchConditionParameters.cs | 21 +- .../src/Generated/Models/PostArgsOperator.cs | 1 + .../src/Generated/Models/Profile.cs | 12 +- .../src/Generated/Models/ProxyResource.cs | 9 +- .../QueryStringMatchConditionParameters.cs | 15 +- .../Generated/Models/QueryStringOperator.cs | 1 + .../src/Generated/Models/RankingsResponse.cs | 63 + .../Models/RankingsResponseTablesItem.cs | 54 + .../RankingsResponseTablesItemDataItem.cs | 56 + ...gsResponseTablesItemDataItemMetricsItem.cs | 60 + .../RemoteAddressMatchConditionParameters.cs | 10 +- .../RequestBodyMatchConditionParameters.cs | 15 +- .../Generated/Models/RequestBodyOperator.cs | 1 + .../RequestHeaderMatchConditionParameters.cs | 21 +- .../Generated/Models/RequestHeaderOperator.cs | 1 + .../RequestMethodMatchConditionParameters.cs | 20 +- .../RequestSchemeMatchConditionParameters.cs | 20 +- .../RequestUriMatchConditionParameters.cs | 15 +- .../Generated/Models/RequestUriOperator.cs | 1 + .../src/Generated/Models/ResourcesResponse.cs | 57 + .../ResourcesResponseCustomDomainsItem.cs | 66 + .../Models/ResourcesResponseEndpointsItem.cs | 68 + ...sResponseEndpointsItemCustomDomainsItem.cs | 66 + .../src/Generated/Models/Route.cs | 236 ++ .../Generated/Models/RouteUpdateParameters.cs | 197 ++ .../src/Generated/Models/Rule.cs | 136 + .../src/Generated/Models/RuleSet.cs | 72 + .../Generated/Models/RuleUpdateParameters.cs | 97 + .../src/Generated/Models/Secret.cs | 81 + .../src/Generated/Models/SecretParameters.cs | 35 + .../src/Generated/Models/SecretProperties.cs | 58 + .../src/Generated/Models/SecretType.cs | 23 + .../src/Generated/Models/SecurityPolicy.cs | 80 + .../Models/SecurityPolicyParameters.cs | 35 + ...PolicyWebApplicationFirewallAssociation.cs | 63 + ...yPolicyWebApplicationFirewallParameters.cs | 64 + .../SharedPrivateLinkResourceProperties.cs | 99 + .../Models/SharedPrivateLinkResourceStatus.cs | 78 + .../src/Generated/Models/Sku.cs | 12 +- .../src/Generated/Models/SkuName.cs | 7 + .../src/Generated/Models/Status.cs | 24 + .../src/Generated/Models/SystemData.cs | 105 + .../src/Generated/Models/TrackedResource.cs | 8 +- ...rlFileExtensionMatchConditionParameters.cs | 15 +- .../Models/UrlFileExtensionOperator.cs | 1 + .../UrlFileNameMatchConditionParameters.cs | 15 +- .../Generated/Models/UrlFileNameOperator.cs | 1 + .../Models/UrlPathMatchConditionParameters.cs | 14 +- .../src/Generated/Models/UrlPathOperator.cs | 1 + .../src/Generated/Models/UrlSigningAction.cs | 5 +- .../Models/UrlSigningActionParameters.cs | 62 +- .../Models/UrlSigningKeyParameters.cs | 92 + .../src/Generated/Models/Usage.cs | 102 + .../src/Generated/Models/UsageName.cs | 60 + .../Generated/Models/ValidateSecretInput.cs | 80 + .../Generated/Models/ValidateSecretOutput.cs | 62 + .../Generated/Models/ValidateSecretType.cs | 23 + .../src/Generated/Models/ValidationToken.cs | 49 + .../Generated/Models/WafMetricsResponse.cs | 72 + .../Models/WafMetricsResponseSeriesItem.cs | 70 + .../WafMetricsResponseSeriesItemDataItem.cs | 54 + .../WafMetricsResponseSeriesItemGroupsItem.cs | 54 + .../Generated/Models/WafRankingsResponse.cs | 69 + .../Models/WafRankingsResponseDataItem.cs | 56 + .../WafRankingsResponseDataItemMetricsItem.cs | 60 + .../src/Generated/PoliciesOperations.cs | 40 +- .../src/Generated/RoutesOperations.cs | 1477 +++++++++++ .../Generated/RoutesOperationsExtensions.cs | 501 ++++ .../src/Generated/RuleSetsOperations.cs | 1514 +++++++++++ .../Generated/RuleSetsOperationsExtensions.cs | 409 +++ .../src/Generated/RulesOperations.cs | 1470 +++++++++++ .../Generated/RulesOperationsExtensions.cs | 487 ++++ .../Generated/SdkInfo_CdnManagementClient.cs | 49 +- .../src/Generated/SecretsOperations.cs | 1414 ++++++++++ .../Generated/SecretsOperationsExtensions.cs | 439 ++++ .../Generated/SecurityPoliciesOperations.cs | 1413 ++++++++++ .../SecurityPoliciesOperationsExtensions.cs | 439 ++++ .../src/Generated/ValidateOperations.cs | 255 ++ .../Generated/ValidateOperationsExtensions.cs | 67 + 162 files changed, 31590 insertions(+), 313 deletions(-) create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDCustomDomainsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDEndpointsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginGroupsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDProfilesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ILogAnalyticsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRoutesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRuleSetsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRulesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecretsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecurityPoliciesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IValidateOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomain.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainHttpsParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainUpdateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpoint.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointProtocols.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointUpdateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOrigin.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroup.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroupUpdateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginUpdateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDStateProperties.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdCertificateType.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponse.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponseException.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdMinimumTlsVersion.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdProvisioningState.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdPurgeParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Certificate.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CompressionSettings.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponse.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseContinentsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseCountryOrRegionsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificate.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeploymentStatus.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationProperties.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationState.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EnabledState.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ForwardingProtocol.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpsRedirect.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IdentityType.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LinkToDefaultDomain.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LoadBalancingSettingsParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificate.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchProcessingBehavior.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponse.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemDataItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemGroupsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideAction.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideActionParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponse.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItemMetricsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponse.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseCustomDomainsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItemCustomDomainsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Route.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RouteUpdateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Rule.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleSet.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleUpdateParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Secret.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretProperties.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretType.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicy.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallAssociation.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceProperties.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceStatus.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Status.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SystemData.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningKeyParameters.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Usage.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UsageName.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretInput.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretOutput.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretType.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidationToken.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponse.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemDataItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemGroupsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponse.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItemMetricsItem.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperationsExtensions.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperations.cs create mode 100644 sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperationsExtensions.cs diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperations.cs new file mode 100644 index 000000000000..53ce714b7d2e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperations.cs @@ -0,0 +1,1675 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDCustomDomainsOperations operations. + /// + internal partial class AFDCustomDomainsOperations : IServiceOperations, IAFDCustomDomainsOperations + { + /// + /// Initializes a new instance of the AFDCustomDomainsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AFDCustomDomainsOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing AzureFrontDoor domain with the specified domain name under + /// the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (customDomainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customDomainName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("customDomainName", customDomainName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{customDomainName}", System.Uri.EscapeDataString(customDomainName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new domain within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, customDomain, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing domain within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - using + /// AzureFrontDoor managed certificate or user's own certificate. If not + /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, tlsSettings, azureDnsZone, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain name + /// under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates the domain validation token. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> RefreshValidationTokenWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginRefreshValidationTokenWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new domain within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (customDomainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customDomainName"); + } + if (customDomain == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customDomain"); + } + if (customDomain != null) + { + customDomain.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("customDomainName", customDomainName); + tracingParameters.Add("customDomain", customDomain); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{customDomainName}", System.Uri.EscapeDataString(customDomainName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(customDomain != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(customDomain, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing domain within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - using + /// AzureFrontDoor managed certificate or user's own certificate. If not + /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (customDomainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customDomainName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (tlsSettings != null) + { + tlsSettings.Validate(); + } + AFDDomainUpdateParameters customDomainUpdateProperties = new AFDDomainUpdateParameters(); + if (tlsSettings != null || azureDnsZone != null) + { + customDomainUpdateProperties.TlsSettings = tlsSettings; + customDomainUpdateProperties.AzureDnsZone = azureDnsZone; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("customDomainName", customDomainName); + tracingParameters.Add("customDomainUpdateProperties", customDomainUpdateProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{customDomainName}", System.Uri.EscapeDataString(customDomainName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(customDomainUpdateProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(customDomainUpdateProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain name + /// under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (customDomainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customDomainName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("customDomainName", customDomainName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{customDomainName}", System.Uri.EscapeDataString(customDomainName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates the domain validation token. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginRefreshValidationTokenWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (customDomainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customDomainName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("customDomainName", customDomainName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginRefreshValidationToken", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}/refreshValidationToken").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{customDomainName}", System.Uri.EscapeDataString(customDomainName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfileNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperationsExtensions.cs new file mode 100644 index 000000000000..15cfe867924a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDCustomDomainsOperationsExtensions.cs @@ -0,0 +1,557 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AFDCustomDomainsOperations. + /// + public static partial class AFDCustomDomainsOperationsExtensions + { + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static IPage ListByProfile(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName) + { + return operations.ListByProfileAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing AzureFrontDoor domain with the specified domain name under + /// the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + public static AFDDomain Get(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName) + { + return operations.GetAsync(resourceGroupName, profileName, customDomainName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing AzureFrontDoor domain with the specified domain name under + /// the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new domain within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + public static AFDDomain Create(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain) + { + return operations.CreateAsync(resourceGroupName, profileName, customDomainName, customDomain).GetAwaiter().GetResult(); + } + + /// + /// Creates a new domain within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, customDomain, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing domain within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - using + /// AzureFrontDoor managed certificate or user's own certificate. If not + /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + public static AFDDomain Update(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference)) + { + return operations.UpdateAsync(resourceGroupName, profileName, customDomainName, tlsSettings, azureDnsZone).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing domain within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - using + /// AzureFrontDoor managed certificate or user's own certificate. If not + /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, tlsSettings, azureDnsZone, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + public static void Delete(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName) + { + operations.DeleteAsync(resourceGroupName, profileName, customDomainName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates the domain validation token. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + public static ValidationToken RefreshValidationToken(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName) + { + return operations.RefreshValidationTokenAsync(resourceGroupName, profileName, customDomainName).GetAwaiter().GetResult(); + } + + /// + /// Updates the domain validation token. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task RefreshValidationTokenAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.RefreshValidationTokenWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new domain within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + public static AFDDomain BeginCreate(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, customDomainName, customDomain).GetAwaiter().GetResult(); + } + + /// + /// Creates a new domain within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, customDomain, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing domain within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - using + /// AzureFrontDoor managed certificate or user's own certificate. If not + /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + public static AFDDomain BeginUpdate(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference)) + { + return operations.BeginUpdateAsync(resourceGroupName, profileName, customDomainName, tlsSettings, azureDnsZone).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing domain within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - using + /// AzureFrontDoor managed certificate or user's own certificate. If not + /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, tlsSettings, azureDnsZone, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + public static void BeginDelete(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, customDomainName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Updates the domain validation token. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + public static ValidationToken BeginRefreshValidationToken(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName) + { + return operations.BeginRefreshValidationTokenAsync(resourceGroupName, profileName, customDomainName).GetAwaiter().GetResult(); + } + + /// + /// Updates the domain validation token. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task BeginRefreshValidationTokenAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginRefreshValidationTokenWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByProfileNext(this IAFDCustomDomainsOperations operations, string nextPageLink) + { + return operations.ListByProfileNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileNextAsync(this IAFDCustomDomainsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperations.cs new file mode 100644 index 000000000000..dd9003f18e39 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperations.cs @@ -0,0 +1,2297 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDEndpointsOperations operations. + /// + internal partial class AFDEndpointsOperations : IServiceOperations, IAFDEndpointsOperations + { + /// + /// Initializes a new instance of the AFDEndpointsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AFDEndpointsOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, endpoint, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. Only + /// tags can be updated after creating an endpoint. To update origins, use the + /// Update Origin operation. To update origin groups, use the Update Origin + /// group operation. To update domains, use the Update Custom Domain operation. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a wild + /// card directory. + /// + /// + /// List of domains. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task PurgeContentWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginPurgeContentWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, contentPaths, domains, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsage", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/usages").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Validates the custom domain mapping to ensure it maps to the correct CDN + /// endpoint in DNS. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ValidateCustomDomainWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string hostName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (hostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "hostName"); + } + ValidateCustomDomainInput customDomainProperties = new ValidateCustomDomainInput(); + if (hostName != null) + { + customDomainProperties.HostName = hostName; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("customDomainProperties", customDomainProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ValidateCustomDomain", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/validateCustomDomain").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(customDomainProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(customDomainProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (endpoint == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpoint"); + } + if (endpoint != null) + { + endpoint.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("endpoint", endpoint); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(endpoint != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(endpoint, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. Only + /// tags can be updated after creating an endpoint. To update origins, use the + /// Update Origin operation. To update origin groups, use the Update Origin + /// group operation. To update domains, use the Update Custom Domain operation. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (endpointUpdateProperties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointUpdateProperties"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("endpointUpdateProperties", endpointUpdateProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(endpointUpdateProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(endpointUpdateProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a wild + /// card directory. + /// + /// + /// List of domains. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginPurgeContentWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (contentPaths == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "contentPaths"); + } + AfdPurgeParameters contents = new AfdPurgeParameters(); + if (contentPaths != null || domains != null) + { + contents.ContentPaths = contentPaths; + contents.Domains = domains; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("contents", contents); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginPurgeContent", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/purge").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(contents != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(contents, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfileNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsageNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperationsExtensions.cs new file mode 100644 index 000000000000..394beb12549c --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDEndpointsOperationsExtensions.cs @@ -0,0 +1,715 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AFDEndpointsOperations. + /// + public static partial class AFDEndpointsOperationsExtensions + { + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static IPage ListByProfile(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName) + { + return operations.ListByProfileAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + public static AFDEndpoint Get(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName) + { + return operations.GetAsync(resourceGroupName, profileName, endpointName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + public static AFDEndpoint Create(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint) + { + return operations.CreateAsync(resourceGroupName, profileName, endpointName, endpoint).GetAwaiter().GetResult(); + } + + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, endpoint, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. Only + /// tags can be updated after creating an endpoint. To update origins, use the + /// Update Origin operation. To update origin groups, use the Update Origin + /// group operation. To update domains, use the Update Custom Domain operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + public static AFDEndpoint Update(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties) + { + return operations.UpdateAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. Only + /// tags can be updated after creating an endpoint. To update origins, use the + /// Update Origin operation. To update origin groups, use the Update Origin + /// group operation. To update domains, use the Update Custom Domain operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + public static void Delete(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName) + { + operations.DeleteAsync(resourceGroupName, profileName, endpointName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a wild + /// card directory. + /// + /// + /// List of domains. + /// + public static void PurgeContent(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList)) + { + operations.PurgeContentAsync(resourceGroupName, profileName, endpointName, contentPaths, domains).GetAwaiter().GetResult(); + } + + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a wild + /// card directory. + /// + /// + /// List of domains. + /// + /// + /// The cancellation token. + /// + public static async Task PurgeContentAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.PurgeContentWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, contentPaths, domains, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + public static IPage ListResourceUsage(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName) + { + return operations.ListResourceUsageAsync(resourceGroupName, profileName, endpointName).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Validates the custom domain mapping to ensure it maps to the correct CDN + /// endpoint in DNS. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + public static ValidateCustomDomainOutput ValidateCustomDomain(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, string hostName) + { + return operations.ValidateCustomDomainAsync(resourceGroupName, profileName, endpointName, hostName).GetAwaiter().GetResult(); + } + + /// + /// Validates the custom domain mapping to ensure it maps to the correct CDN + /// endpoint in DNS. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateCustomDomainAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, string hostName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateCustomDomainWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, hostName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + public static AFDEndpoint BeginCreate(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, endpointName, endpoint).GetAwaiter().GetResult(); + } + + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, endpoint, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. Only + /// tags can be updated after creating an endpoint. To update origins, use the + /// Update Origin operation. To update origin groups, use the Update Origin + /// group operation. To update domains, use the Update Custom Domain operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + public static AFDEndpoint BeginUpdate(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties) + { + return operations.BeginUpdateAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. Only + /// tags can be updated after creating an endpoint. To update origins, use the + /// Update Origin operation. To update origin groups, use the Update Origin + /// group operation. To update domains, use the Update Custom Domain operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + public static void BeginDelete(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, endpointName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a wild + /// card directory. + /// + /// + /// List of domains. + /// + public static void BeginPurgeContent(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList)) + { + operations.BeginPurgeContentAsync(resourceGroupName, profileName, endpointName, contentPaths, domains).GetAwaiter().GetResult(); + } + + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a wild + /// card directory. + /// + /// + /// List of domains. + /// + /// + /// The cancellation token. + /// + public static async Task BeginPurgeContentAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginPurgeContentWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, contentPaths, domains, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByProfileNext(this IAFDEndpointsOperations operations, string nextPageLink) + { + return operations.ListByProfileNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileNextAsync(this IAFDEndpointsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListResourceUsageNext(this IAFDEndpointsOperations operations, string nextPageLink) + { + return operations.ListResourceUsageNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageNextAsync(this IAFDEndpointsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperations.cs new file mode 100644 index 000000000000..0a6ec4c05f9e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperations.cs @@ -0,0 +1,1799 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDOriginGroupsOperations operations. + /// + internal partial class AFDOriginGroupsOperations : IServiceOperations, IAFDOriginGroupsOperations + { + /// + /// Initializes a new instance of the AFDOriginGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AFDOriginGroupsOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originGroup, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originGroupUpdateProperties, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsage", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/usages").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (originGroup == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroup"); + } + if (originGroup != null) + { + originGroup.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("originGroup", originGroup); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(originGroup != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(originGroup, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (originGroupUpdateProperties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupUpdateProperties"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("originGroupUpdateProperties", originGroupUpdateProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(originGroupUpdateProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(originGroupUpdateProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfileNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsageNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperationsExtensions.cs new file mode 100644 index 000000000000..3e92f655f7f0 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginGroupsOperationsExtensions.cs @@ -0,0 +1,519 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AFDOriginGroupsOperations. + /// + public static partial class AFDOriginGroupsOperationsExtensions + { + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static IPage ListByProfile(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName) + { + return operations.ListByProfileAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + public static AFDOriginGroup Get(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName) + { + return operations.GetAsync(resourceGroupName, profileName, originGroupName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + public static AFDOriginGroup Create(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup) + { + return operations.CreateAsync(resourceGroupName, profileName, originGroupName, originGroup).GetAwaiter().GetResult(); + } + + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originGroup, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + public static AFDOriginGroup Update(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties) + { + return operations.UpdateAsync(resourceGroupName, profileName, originGroupName, originGroupUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originGroupUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + public static void Delete(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName) + { + operations.DeleteAsync(resourceGroupName, profileName, originGroupName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + public static IPage ListResourceUsage(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName) + { + return operations.ListResourceUsageAsync(resourceGroupName, profileName, originGroupName).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + public static AFDOriginGroup BeginCreate(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, originGroupName, originGroup).GetAwaiter().GetResult(); + } + + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originGroup, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + public static AFDOriginGroup BeginUpdate(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties) + { + return operations.BeginUpdateAsync(resourceGroupName, profileName, originGroupName, originGroupUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originGroupUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + public static void BeginDelete(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, originGroupName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IAFDOriginGroupsOperations operations, string resourceGroupName, string profileName, string originGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByProfileNext(this IAFDOriginGroupsOperations operations, string nextPageLink) + { + return operations.ListByProfileNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileNextAsync(this IAFDOriginGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListResourceUsageNext(this IAFDOriginGroupsOperations operations, string nextPageLink) + { + return operations.ListResourceUsageNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageNextAsync(this IAFDOriginGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperations.cs new file mode 100644 index 000000000000..83c2a9577a22 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperations.cs @@ -0,0 +1,1470 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDOriginsOperations operations. + /// + internal partial class AFDOriginsOperations : IServiceOperations, IAFDOriginsOperations + { + /// + /// Initializes a new instance of the AFDOriginsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AFDOriginsOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByOriginGroupWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByOriginGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (originName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("originName", originName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{originName}", System.Uri.EscapeDataString(originName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, origin, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, originUpdateProperties, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (originName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originName"); + } + if (origin == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "origin"); + } + if (origin != null) + { + origin.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("originName", originName); + tracingParameters.Add("origin", origin); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{originName}", System.Uri.EscapeDataString(originName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(origin != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(origin, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (originName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originName"); + } + if (originUpdateProperties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originUpdateProperties"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("originName", originName); + tracingParameters.Add("originUpdateProperties", originUpdateProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{originName}", System.Uri.EscapeDataString(originName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(originUpdateProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(originUpdateProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (originGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originGroupName"); + } + if (originName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "originName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("originGroupName", originGroupName); + tracingParameters.Add("originName", originName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{originGroupName}", System.Uri.EscapeDataString(originGroupName)); + _url = _url.Replace("{originName}", System.Uri.EscapeDataString(originName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByOriginGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByOriginGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperationsExtensions.cs new file mode 100644 index 000000000000..61071fc1c844 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDOriginsOperationsExtensions.cs @@ -0,0 +1,487 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AFDOriginsOperations. + /// + public static partial class AFDOriginsOperationsExtensions + { + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + public static IPage ListByOriginGroup(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName) + { + return operations.ListByOriginGroupAsync(resourceGroupName, profileName, originGroupName).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByOriginGroupAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByOriginGroupWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + public static AFDOrigin Get(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName) + { + return operations.GetAsync(resourceGroupName, profileName, originGroupName, originName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + public static AFDOrigin Create(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin) + { + return operations.CreateAsync(resourceGroupName, profileName, originGroupName, originName, origin).GetAwaiter().GetResult(); + } + + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, origin, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + public static AFDOrigin Update(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties) + { + return operations.UpdateAsync(resourceGroupName, profileName, originGroupName, originName, originUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, originUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + public static void Delete(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName) + { + operations.DeleteAsync(resourceGroupName, profileName, originGroupName, originName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + public static AFDOrigin BeginCreate(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, originGroupName, originName, origin).GetAwaiter().GetResult(); + } + + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, origin, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + public static AFDOrigin BeginUpdate(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties) + { + return operations.BeginUpdateAsync(resourceGroupName, profileName, originGroupName, originName, originUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, originUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + public static void BeginDelete(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, originGroupName, originName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByOriginGroupNext(this IAFDOriginsOperations operations, string nextPageLink) + { + return operations.ListByOriginGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByOriginGroupNextAsync(this IAFDOriginsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByOriginGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperations.cs new file mode 100644 index 000000000000..4561a892dc5d --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperations.cs @@ -0,0 +1,654 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDProfilesOperations operations. + /// + internal partial class AFDProfilesOperations : IServiceOperations, IAFDProfilesOperations + { + /// + /// Initializes a new instance of the AFDProfilesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AFDProfilesOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsage", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/usages").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Validates the custom domain mapping to ensure it maps to the correct CDN + /// endpoint in DNS. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CheckHostNameAvailabilityWithHttpMessagesAsync(string resourceGroupName, string profileName, string hostName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (hostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "hostName"); + } + ValidateCustomDomainInput checkHostNameAvailabilityInput = new ValidateCustomDomainInput(); + if (hostName != null) + { + checkHostNameAvailabilityInput.HostName = hostName; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("checkHostNameAvailabilityInput", checkHostNameAvailabilityInput); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckHostNameAvailability", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkHostNameAvailability").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(checkHostNameAvailabilityInput != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(checkHostNameAvailabilityInput, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsageNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperationsExtensions.cs new file mode 100644 index 000000000000..ea1223c68430 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/AFDProfilesOperationsExtensions.cs @@ -0,0 +1,147 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AFDProfilesOperations. + /// + public static partial class AFDProfilesOperationsExtensions + { + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static IPage ListResourceUsage(this IAFDProfilesOperations operations, string resourceGroupName, string profileName) + { + return operations.ListResourceUsageAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageAsync(this IAFDProfilesOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Validates the custom domain mapping to ensure it maps to the correct CDN + /// endpoint in DNS. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + public static ValidateCustomDomainOutput CheckHostNameAvailability(this IAFDProfilesOperations operations, string resourceGroupName, string profileName, string hostName) + { + return operations.CheckHostNameAvailabilityAsync(resourceGroupName, profileName, hostName).GetAwaiter().GetResult(); + } + + /// + /// Validates the custom domain mapping to ensure it maps to the correct CDN + /// endpoint in DNS. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + /// + /// The cancellation token. + /// + public static async Task CheckHostNameAvailabilityAsync(this IAFDProfilesOperations operations, string resourceGroupName, string profileName, string hostName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckHostNameAvailabilityWithHttpMessagesAsync(resourceGroupName, profileName, hostName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListResourceUsageNext(this IAFDProfilesOperations operations, string nextPageLink) + { + return operations.ListResourceUsageNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageNextAsync(this IAFDProfilesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/CdnManagementClient.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/CdnManagementClient.cs index e70dbdae5e59..f21f12c90987 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/CdnManagementClient.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/CdnManagementClient.cs @@ -55,7 +55,7 @@ public partial class CdnManagementClient : ServiceClient, I /// /// Version of the API to be used with the client request. Current version is - /// 2017-04-02. + /// 2020-09-01. /// public string ApiVersion { get; private set; } @@ -117,6 +117,66 @@ public partial class CdnManagementClient : ServiceClient, I /// public virtual IEdgeNodesOperations EdgeNodes { get; private set; } + /// + /// Gets the IAFDProfilesOperations. + /// + public virtual IAFDProfilesOperations AFDProfiles { get; private set; } + + /// + /// Gets the IAFDCustomDomainsOperations. + /// + public virtual IAFDCustomDomainsOperations AFDCustomDomains { get; private set; } + + /// + /// Gets the IAFDEndpointsOperations. + /// + public virtual IAFDEndpointsOperations AFDEndpoints { get; private set; } + + /// + /// Gets the IAFDOriginGroupsOperations. + /// + public virtual IAFDOriginGroupsOperations AFDOriginGroups { get; private set; } + + /// + /// Gets the IAFDOriginsOperations. + /// + public virtual IAFDOriginsOperations AFDOrigins { get; private set; } + + /// + /// Gets the IRoutesOperations. + /// + public virtual IRoutesOperations Routes { get; private set; } + + /// + /// Gets the IRuleSetsOperations. + /// + public virtual IRuleSetsOperations RuleSets { get; private set; } + + /// + /// Gets the IRulesOperations. + /// + public virtual IRulesOperations Rules { get; private set; } + + /// + /// Gets the ISecurityPoliciesOperations. + /// + public virtual ISecurityPoliciesOperations SecurityPolicies { get; private set; } + + /// + /// Gets the ISecretsOperations. + /// + public virtual ISecretsOperations Secrets { get; private set; } + + /// + /// Gets the IValidateOperations. + /// + public virtual IValidateOperations Validate { get; private set; } + + /// + /// Gets the ILogAnalyticsOperations. + /// + public virtual ILogAnalyticsOperations LogAnalytics { get; private set; } + /// /// Gets the IPoliciesOperations. /// @@ -376,10 +436,22 @@ private void Initialize() ResourceUsage = new ResourceUsageOperations(this); Operations = new Operations(this); EdgeNodes = new EdgeNodesOperations(this); + AFDProfiles = new AFDProfilesOperations(this); + AFDCustomDomains = new AFDCustomDomainsOperations(this); + AFDEndpoints = new AFDEndpointsOperations(this); + AFDOriginGroups = new AFDOriginGroupsOperations(this); + AFDOrigins = new AFDOriginsOperations(this); + Routes = new RoutesOperations(this); + RuleSets = new RuleSetsOperations(this); + Rules = new RulesOperations(this); + SecurityPolicies = new SecurityPoliciesOperations(this); + Secrets = new SecretsOperations(this); + Validate = new ValidateOperations(this); + LogAnalytics = new LogAnalyticsOperations(this); Policies = new PoliciesOperations(this); ManagedRuleSets = new ManagedRuleSetsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2020-04-15"; + ApiVersion = "2020-09-01"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; @@ -415,6 +487,10 @@ private void Initialize() DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("name")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("certificateSource")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("certificateSource")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("type")); CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDCustomDomainsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDCustomDomainsOperations.cs new file mode 100644 index 000000000000..47f83c65ee9c --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDCustomDomainsOperations.cs @@ -0,0 +1,347 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDCustomDomainsOperations operations. + /// + public partial interface IAFDCustomDomainsOperations + { + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing AzureFrontDoor domain with the specified domain + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new domain within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing domain within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - + /// using AzureFrontDoor managed certificate or user's own certificate. + /// If not specified, enabling ssl uses AzureFrontDoor managed + /// certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates the domain validation token. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> RefreshValidationTokenWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new domain within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// Domain properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing domain within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally + /// + /// + /// The configuration specifying how to enable HTTPS for the domain - + /// using AzureFrontDoor managed certificate or user's own certificate. + /// If not specified, enabling ssl uses AzureFrontDoor managed + /// certificate by default. + /// + /// + /// Resource reference to the Azure DNS zone + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing AzureFrontDoor domain with the specified domain + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates the domain validation token. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the domain under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginRefreshValidationTokenWithHttpMessagesAsync(string resourceGroupName, string profileName, string customDomainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists existing AzureFrontDoor domains. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDEndpointsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDEndpointsOperations.cs new file mode 100644 index 000000000000..5fcf64078011 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDEndpointsOperations.cs @@ -0,0 +1,442 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDEndpointsOperations operations. + /// + public partial interface IAFDEndpointsOperations + { + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing AzureFrontDoor endpoint with the specified + /// endpoint name under the specified subscription, resource group and + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing AzureFrontDoor endpoint with the specified + /// endpoint name under the specified subscription, resource group and + /// profile. Only tags can be updated after creating an endpoint. To + /// update origins, use the Update Origin operation. To update origin + /// groups, use the Update Origin group operation. To update domains, + /// use the Update Custom Domain operation. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified + /// endpoint name under the specified subscription, resource group and + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a + /// wild card directory. + /// + /// + /// List of domains. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task PurgeContentWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates the custom domain mapping to ensure it maps to the + /// correct CDN endpoint in DNS. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ValidateCustomDomainWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string hostName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new AzureFrontDoor endpoint with the specified endpoint + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpoint endpoint, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing AzureFrontDoor endpoint with the specified + /// endpoint name under the specified subscription, resource group and + /// profile. Only tags can be updated after creating an endpoint. To + /// update origins, use the Update Origin operation. To update origin + /// groups, use the Update Origin group operation. To update domains, + /// use the Update Custom Domain operation. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Endpoint update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing AzureFrontDoor endpoint with the specified + /// endpoint name under the specified subscription, resource group and + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Removes a content from AzureFrontDoor. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The path to the content to be purged. Can describe a file path or a + /// wild card directory. + /// + /// + /// List of domains. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginPurgeContentWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, IList contentPaths, IList domains = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists existing AzureFrontDoor endpoints. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginGroupsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginGroupsOperations.cs new file mode 100644 index 000000000000..379c8ad734cb --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginGroupsOperations.cs @@ -0,0 +1,328 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDOriginGroupsOperations operations. + /// + public partial interface IAFDOriginGroupsOperations + { + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new origin group within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the endpoint. + /// + /// + /// Origin group properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroup originGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Origin group properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, AFDOriginGroupUpdateParameters originGroupUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing origin group within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the existing origin groups within a profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginsOperations.cs new file mode 100644 index 000000000000..4a1e58ec45ee --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDOriginsOperations.cs @@ -0,0 +1,300 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDOriginsOperations operations. + /// + public partial interface IAFDOriginsOperations + { + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByOriginGroupWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new origin within the specified origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin that is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// Origin properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, AFDOriginUpdateParameters originUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing origin within an origin group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the origin group which is unique within the profile. + /// + /// + /// Name of the origin which is unique within the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string originGroupName, string originName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the existing origins within an origin group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByOriginGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDProfilesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDProfilesOperations.cs new file mode 100644 index 000000000000..53b7f56e9658 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IAFDProfilesOperations.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AFDProfilesOperations operations. + /// + public partial interface IAFDProfilesOperations + { + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates the custom domain mapping to ensure it maps to the + /// correct CDN endpoint in DNS. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The host name of the custom domain. Must be a domain name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CheckHostNameAvailabilityWithHttpMessagesAsync(string resourceGroupName, string profileName, string hostName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ICdnManagementClient.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ICdnManagementClient.cs index 8c9a20c7787c..150069dbd188 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ICdnManagementClient.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ICdnManagementClient.cs @@ -51,7 +51,7 @@ public partial interface ICdnManagementClient : System.IDisposable /// /// Version of the API to be used with the client request. Current - /// version is 2017-04-02. + /// version is 2020-09-01. /// string ApiVersion { get; } @@ -114,6 +114,66 @@ public partial interface ICdnManagementClient : System.IDisposable /// IEdgeNodesOperations EdgeNodes { get; } + /// + /// Gets the IAFDProfilesOperations. + /// + IAFDProfilesOperations AFDProfiles { get; } + + /// + /// Gets the IAFDCustomDomainsOperations. + /// + IAFDCustomDomainsOperations AFDCustomDomains { get; } + + /// + /// Gets the IAFDEndpointsOperations. + /// + IAFDEndpointsOperations AFDEndpoints { get; } + + /// + /// Gets the IAFDOriginGroupsOperations. + /// + IAFDOriginGroupsOperations AFDOriginGroups { get; } + + /// + /// Gets the IAFDOriginsOperations. + /// + IAFDOriginsOperations AFDOrigins { get; } + + /// + /// Gets the IRoutesOperations. + /// + IRoutesOperations Routes { get; } + + /// + /// Gets the IRuleSetsOperations. + /// + IRuleSetsOperations RuleSets { get; } + + /// + /// Gets the IRulesOperations. + /// + IRulesOperations Rules { get; } + + /// + /// Gets the ISecurityPoliciesOperations. + /// + ISecurityPoliciesOperations SecurityPolicies { get; } + + /// + /// Gets the ISecretsOperations. + /// + ISecretsOperations Secrets { get; } + + /// + /// Gets the IValidateOperations. + /// + IValidateOperations Validate { get; } + + /// + /// Gets the ILogAnalyticsOperations. + /// + ILogAnalyticsOperations LogAnalytics { get; } + /// /// Gets the IPoliciesOperations. /// diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ILogAnalyticsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ILogAnalyticsOperations.cs new file mode 100644 index 000000000000..80b53e41be93 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ILogAnalyticsOperations.cs @@ -0,0 +1,237 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LogAnalyticsOperations operations. + /// + public partial interface ILogAnalyticsOperations + { + /// + /// Get log report for AFD profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetLogAnalyticsMetricsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList groupBy = default(IList), IList continents = default(IList), IList countryOrRegions = default(IList), IList customDomains = default(IList), IList protocols = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get log analytics ranking report for AFD profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetLogAnalyticsRankingsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList rankings, IList metrics, double maxRanking, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, IList customDomains = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all available location names for AFD log analytics report. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetLogAnalyticsLocationsWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all endpoints and custom domains available for AFD log report + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetLogAnalyticsResourcesWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get Waf related log analytics report for AFD profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWafLogAnalyticsMetricsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList actions = default(IList), IList groupBy = default(IList), IList ruleTypes = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get WAF log analytics charts for AFD profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWafLogAnalyticsRankingsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, double maxRanking, IList rankings, IList actions = default(IList), IList ruleTypes = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRoutesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRoutesOperations.cs new file mode 100644 index 000000000000..812dd0a6e4dc --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRoutesOperations.cs @@ -0,0 +1,314 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RoutesOperations operations. + /// + public partial interface IRoutesOperations + { + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByEndpointWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing route with the specified route name under the + /// specified subscription, resource group, profile, and AzureFrontDoor + /// endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new route with the specified route name under the + /// specified subscription, resource group, profile, and AzureFrontDoor + /// endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Route route, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing route with the specified route name under the + /// specified subscription, resource group, profile, and AzureFrontDoor + /// endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing route with the specified route name under the + /// specified subscription, resource group, profile, and AzureFrontDoor + /// endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new route with the specified route name under the + /// specified subscription, resource group, profile, and AzureFrontDoor + /// endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Route route, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing route with the specified route name under the + /// specified subscription, resource group, profile, and AzureFrontDoor + /// endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing route with the specified route name under the + /// specified subscription, resource group, profile, and AzureFrontDoor + /// endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByEndpointNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRuleSetsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRuleSetsOperations.cs new file mode 100644 index 000000000000..85db52393a25 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRuleSetsOperations.cs @@ -0,0 +1,266 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RuleSetsOperations operations. + /// + public partial interface IRuleSetsOperations + { + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing AzureFrontDoor rule set with the specified rule + /// set name under the specified subscription, resource group and + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule + /// set name under the specified subscription, resource group and + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule + /// set name under the specified subscription, resource group and + /// profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks the quota and actual usage of endpoints under the given CDN + /// profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRulesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRulesOperations.cs new file mode 100644 index 000000000000..f82c10ae730f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IRulesOperations.cs @@ -0,0 +1,300 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RulesOperations operations. + /// + public partial interface IRulesOperations + { + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByRuleSetWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByRuleSetNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecretsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecretsOperations.cs new file mode 100644 index 000000000000..984742bc493e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecretsOperations.cs @@ -0,0 +1,276 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecretsOperations operations. + /// + public partial interface ISecretsOperations + { + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Secret within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing Secret within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecurityPoliciesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecurityPoliciesOperations.cs new file mode 100644 index 000000000000..5cad82e71349 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ISecurityPoliciesOperations.cs @@ -0,0 +1,276 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecurityPoliciesOperations operations. + /// + public partial interface ISecurityPoliciesOperations + { + /// + /// Lists security policies associated with the profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an existing security policy within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> PatchWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing security policy within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginPatchWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an existing security policy within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists security policies associated with the profile + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IValidateOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IValidateOperations.cs new file mode 100644 index 000000000000..16dc555a43a5 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IValidateOperations.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ValidateOperations operations. + /// + public partial interface IValidateOperations + { + /// + /// Validate a Secret in the profile. + /// + /// + /// The secret source. + /// + /// + /// The secret type. Possible values include: 'UrlSigningKey', + /// 'ManagedCertificate', 'CustomerCertificate' + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> SecretMethodWithHttpMessagesAsync(ResourceReference secretSource, string secretType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperations.cs new file mode 100644 index 000000000000..58def0c9ca4f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperations.cs @@ -0,0 +1,1497 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LogAnalyticsOperations operations. + /// + internal partial class LogAnalyticsOperations : IServiceOperations, ILogAnalyticsOperations + { + /// + /// Initializes a new instance of the LogAnalyticsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LogAnalyticsOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Get log report for AFD profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetLogAnalyticsMetricsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList groupBy = default(IList), IList continents = default(IList), IList countryOrRegions = default(IList), IList customDomains = default(IList), IList protocols = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (metrics == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "metrics"); + } + if (granularity == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "granularity"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("metrics", metrics); + tracingParameters.Add("dateTimeBegin", dateTimeBegin); + tracingParameters.Add("dateTimeEnd", dateTimeEnd); + tracingParameters.Add("granularity", granularity); + tracingParameters.Add("groupBy", groupBy); + tracingParameters.Add("continents", continents); + tracingParameters.Add("countryOrRegions", countryOrRegions); + tracingParameters.Add("customDomains", customDomains); + tracingParameters.Add("protocols", protocols); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetLogAnalyticsMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsMetrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (metrics != null) + { + _queryParameters.Add(string.Format("metrics={0}", System.Uri.EscapeDataString(string.Join(",", metrics)))); + } + _queryParameters.Add(string.Format("dateTimeBegin={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeBegin, Client.SerializationSettings).Trim('"')))); + _queryParameters.Add(string.Format("dateTimeEnd={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeEnd, Client.SerializationSettings).Trim('"')))); + if (granularity != null) + { + _queryParameters.Add(string.Format("granularity={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(granularity, Client.SerializationSettings).Trim('"')))); + } + if (groupBy != null) + { + _queryParameters.Add(string.Format("groupBy={0}", System.Uri.EscapeDataString(string.Join(",", groupBy)))); + } + if (continents != null) + { + _queryParameters.Add(string.Format("continents={0}", System.Uri.EscapeDataString(string.Join(",", continents)))); + } + if (countryOrRegions != null) + { + _queryParameters.Add(string.Format("countryOrRegions={0}", System.Uri.EscapeDataString(string.Join(",", countryOrRegions)))); + } + if (customDomains != null) + { + _queryParameters.Add(string.Format("customDomains={0}", System.Uri.EscapeDataString(string.Join(",", customDomains)))); + } + if (protocols != null) + { + _queryParameters.Add(string.Format("protocols={0}", System.Uri.EscapeDataString(string.Join(",", protocols)))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get log analytics ranking report for AFD profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetLogAnalyticsRankingsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList rankings, IList metrics, double maxRanking, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, IList customDomains = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (rankings == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "rankings"); + } + if (metrics == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "metrics"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("rankings", rankings); + tracingParameters.Add("metrics", metrics); + tracingParameters.Add("maxRanking", maxRanking); + tracingParameters.Add("dateTimeBegin", dateTimeBegin); + tracingParameters.Add("dateTimeEnd", dateTimeEnd); + tracingParameters.Add("customDomains", customDomains); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetLogAnalyticsRankings", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsRankings").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (rankings != null) + { + _queryParameters.Add(string.Format("rankings={0}", System.Uri.EscapeDataString(string.Join(",", rankings)))); + } + if (metrics != null) + { + _queryParameters.Add(string.Format("metrics={0}", System.Uri.EscapeDataString(string.Join(",", metrics)))); + } + _queryParameters.Add(string.Format("maxRanking={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(maxRanking, Client.SerializationSettings).Trim('"')))); + _queryParameters.Add(string.Format("dateTimeBegin={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeBegin, Client.SerializationSettings).Trim('"')))); + _queryParameters.Add(string.Format("dateTimeEnd={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeEnd, Client.SerializationSettings).Trim('"')))); + if (customDomains != null) + { + _queryParameters.Add(string.Format("customDomains={0}", System.Uri.EscapeDataString(string.Join(",", customDomains)))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all available location names for AFD log analytics report. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetLogAnalyticsLocationsWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetLogAnalyticsLocations", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsLocations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all endpoints and custom domains available for AFD log report + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetLogAnalyticsResourcesWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetLogAnalyticsResources", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get Waf related log analytics report for AFD profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWafLogAnalyticsMetricsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList actions = default(IList), IList groupBy = default(IList), IList ruleTypes = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (metrics == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "metrics"); + } + if (granularity == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "granularity"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("metrics", metrics); + tracingParameters.Add("dateTimeBegin", dateTimeBegin); + tracingParameters.Add("dateTimeEnd", dateTimeEnd); + tracingParameters.Add("granularity", granularity); + tracingParameters.Add("actions", actions); + tracingParameters.Add("groupBy", groupBy); + tracingParameters.Add("ruleTypes", ruleTypes); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetWafLogAnalyticsMetrics", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsMetrics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (metrics != null) + { + _queryParameters.Add(string.Format("metrics={0}", System.Uri.EscapeDataString(string.Join(",", metrics)))); + } + _queryParameters.Add(string.Format("dateTimeBegin={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeBegin, Client.SerializationSettings).Trim('"')))); + _queryParameters.Add(string.Format("dateTimeEnd={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeEnd, Client.SerializationSettings).Trim('"')))); + if (granularity != null) + { + _queryParameters.Add(string.Format("granularity={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(granularity, Client.SerializationSettings).Trim('"')))); + } + if (actions != null) + { + _queryParameters.Add(string.Format("actions={0}", System.Uri.EscapeDataString(string.Join(",", actions)))); + } + if (groupBy != null) + { + _queryParameters.Add(string.Format("groupBy={0}", System.Uri.EscapeDataString(string.Join(",", groupBy)))); + } + if (ruleTypes != null) + { + _queryParameters.Add(string.Format("ruleTypes={0}", System.Uri.EscapeDataString(string.Join(",", ruleTypes)))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get WAF log analytics charts for AFD profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWafLogAnalyticsRankingsWithHttpMessagesAsync(string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, double maxRanking, IList rankings, IList actions = default(IList), IList ruleTypes = default(IList), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (metrics == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "metrics"); + } + if (rankings == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "rankings"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("metrics", metrics); + tracingParameters.Add("dateTimeBegin", dateTimeBegin); + tracingParameters.Add("dateTimeEnd", dateTimeEnd); + tracingParameters.Add("maxRanking", maxRanking); + tracingParameters.Add("rankings", rankings); + tracingParameters.Add("actions", actions); + tracingParameters.Add("ruleTypes", ruleTypes); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetWafLogAnalyticsRankings", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsRankings").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (metrics != null) + { + _queryParameters.Add(string.Format("metrics={0}", System.Uri.EscapeDataString(string.Join(",", metrics)))); + } + _queryParameters.Add(string.Format("dateTimeBegin={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeBegin, Client.SerializationSettings).Trim('"')))); + _queryParameters.Add(string.Format("dateTimeEnd={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(dateTimeEnd, Client.SerializationSettings).Trim('"')))); + _queryParameters.Add(string.Format("maxRanking={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(maxRanking, Client.SerializationSettings).Trim('"')))); + if (rankings != null) + { + _queryParameters.Add(string.Format("rankings={0}", System.Uri.EscapeDataString(string.Join(",", rankings)))); + } + if (actions != null) + { + _queryParameters.Add(string.Format("actions={0}", System.Uri.EscapeDataString(string.Join(",", actions)))); + } + if (ruleTypes != null) + { + _queryParameters.Add(string.Format("ruleTypes={0}", System.Uri.EscapeDataString(string.Join(",", ruleTypes)))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperationsExtensions.cs new file mode 100644 index 000000000000..7834b8715b77 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/LogAnalyticsOperationsExtensions.cs @@ -0,0 +1,387 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LogAnalyticsOperations. + /// + public static partial class LogAnalyticsOperationsExtensions + { + /// + /// Get log report for AFD profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MetricsResponse GetLogAnalyticsMetrics(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList groupBy = default(IList), IList continents = default(IList), IList countryOrRegions = default(IList), IList customDomains = default(IList), IList protocols = default(IList)) + { + return operations.GetLogAnalyticsMetricsAsync(resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, granularity, groupBy, continents, countryOrRegions, customDomains, protocols).GetAwaiter().GetResult(); + } + + /// + /// Get log report for AFD profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task GetLogAnalyticsMetricsAsync(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList groupBy = default(IList), IList continents = default(IList), IList countryOrRegions = default(IList), IList customDomains = default(IList), IList protocols = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetLogAnalyticsMetricsWithHttpMessagesAsync(resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, granularity, groupBy, continents, countryOrRegions, customDomains, protocols, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get log analytics ranking report for AFD profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static RankingsResponse GetLogAnalyticsRankings(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList rankings, IList metrics, double maxRanking, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, IList customDomains = default(IList)) + { + return operations.GetLogAnalyticsRankingsAsync(resourceGroupName, profileName, rankings, metrics, maxRanking, dateTimeBegin, dateTimeEnd, customDomains).GetAwaiter().GetResult(); + } + + /// + /// Get log analytics ranking report for AFD profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task GetLogAnalyticsRankingsAsync(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList rankings, IList metrics, double maxRanking, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, IList customDomains = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetLogAnalyticsRankingsWithHttpMessagesAsync(resourceGroupName, profileName, rankings, metrics, maxRanking, dateTimeBegin, dateTimeEnd, customDomains, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all available location names for AFD log analytics report. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static ContinentsResponse GetLogAnalyticsLocations(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName) + { + return operations.GetLogAnalyticsLocationsAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Get all available location names for AFD log analytics report. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task GetLogAnalyticsLocationsAsync(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetLogAnalyticsLocationsWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all endpoints and custom domains available for AFD log report + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static ResourcesResponse GetLogAnalyticsResources(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName) + { + return operations.GetLogAnalyticsResourcesAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Get all endpoints and custom domains available for AFD log report + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task GetLogAnalyticsResourcesAsync(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetLogAnalyticsResourcesWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get Waf related log analytics report for AFD profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + public static WafMetricsResponse GetWafLogAnalyticsMetrics(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList actions = default(IList), IList groupBy = default(IList), IList ruleTypes = default(IList)) + { + return operations.GetWafLogAnalyticsMetricsAsync(resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, granularity, actions, groupBy, ruleTypes).GetAwaiter().GetResult(); + } + + /// + /// Get Waf related log analytics report for AFD profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// Possible values include: 'PT5M', 'PT1H', 'P1D' + /// + /// + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task GetWafLogAnalyticsMetricsAsync(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, string granularity, IList actions = default(IList), IList groupBy = default(IList), IList ruleTypes = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWafLogAnalyticsMetricsWithHttpMessagesAsync(resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, granularity, actions, groupBy, ruleTypes, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get WAF log analytics charts for AFD profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static WafRankingsResponse GetWafLogAnalyticsRankings(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, double maxRanking, IList rankings, IList actions = default(IList), IList ruleTypes = default(IList)) + { + return operations.GetWafLogAnalyticsRankingsAsync(resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, maxRanking, rankings, actions, ruleTypes).GetAwaiter().GetResult(); + } + + /// + /// Get WAF log analytics charts for AFD profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task GetWafLogAnalyticsRankingsAsync(this ILogAnalyticsOperations operations, string resourceGroupName, string profileName, IList metrics, System.DateTime dateTimeBegin, System.DateTime dateTimeEnd, double maxRanking, IList rankings, IList actions = default(IList), IList ruleTypes = default(IList), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWafLogAnalyticsRankingsWithHttpMessagesAsync(resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, maxRanking, rankings, actions, ruleTypes, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomain.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomain.cs new file mode 100644 index 000000000000..9e689784fb72 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomain.cs @@ -0,0 +1,146 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Friendly domain name mapping to the endpoint hostname that the customer + /// provides for branding purposes, e.g. www.contoso.com. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDDomain : ProxyResource + { + /// + /// Initializes a new instance of the AFDDomain class. + /// + public AFDDomain() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDDomain class. + /// + /// The host name of the domain. Must be a + /// domain name. + /// Resource ID. + /// Resource name. + /// Resource type. + /// The configuration specifying how to + /// enable HTTPS for the domain - using AzureFrontDoor managed + /// certificate or user's own certificate. If not specified, enabling + /// ssl uses AzureFrontDoor managed certificate by default. + /// Resource reference to the Azure DNS + /// zone + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + /// Provisioning substate shows the + /// progress of custom HTTPS enabling/disabling process step by step. + /// DCV stands for DomainControlValidation. Possible values include: + /// 'Unknown', 'Submitting', 'Pending', 'TimedOut', + /// 'PendingRevalidation', 'Approved' + /// Values the customer needs to + /// validate domain ownership + public AFDDomain(string hostName, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), string provisioningState = default(string), string deploymentStatus = default(string), string domainValidationState = default(string), DomainValidationProperties validationProperties = default(DomainValidationProperties)) + : base(id, name, type, systemData) + { + TlsSettings = tlsSettings; + AzureDnsZone = azureDnsZone; + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + DomainValidationState = domainValidationState; + HostName = hostName; + ValidationProperties = validationProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the configuration specifying how to enable HTTPS for + /// the domain - using AzureFrontDoor managed certificate or user's own + /// certificate. If not specified, enabling ssl uses AzureFrontDoor + /// managed certificate by default. + /// + [JsonProperty(PropertyName = "properties.tlsSettings")] + public AFDDomainHttpsParameters TlsSettings { get; set; } + + /// + /// Gets or sets resource reference to the Azure DNS zone + /// + [JsonProperty(PropertyName = "properties.azureDnsZone")] + public ResourceReference AzureDnsZone { get; set; } + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Gets provisioning substate shows the progress of custom HTTPS + /// enabling/disabling process step by step. DCV stands for + /// DomainControlValidation. Possible values include: 'Unknown', + /// 'Submitting', 'Pending', 'TimedOut', 'PendingRevalidation', + /// 'Approved' + /// + [JsonProperty(PropertyName = "properties.domainValidationState")] + public string DomainValidationState { get; private set; } + + /// + /// Gets or sets the host name of the domain. Must be a domain name. + /// + [JsonProperty(PropertyName = "properties.hostName")] + public string HostName { get; set; } + + /// + /// Gets values the customer needs to validate domain ownership + /// + [JsonProperty(PropertyName = "properties.validationProperties")] + public DomainValidationProperties ValidationProperties { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (HostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "HostName"); + } + if (TlsSettings != null) + { + TlsSettings.Validate(); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainHttpsParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainHttpsParameters.cs new file mode 100644 index 000000000000..3b4f1dff1860 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainHttpsParameters.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The JSON object that contains the properties to secure a domain. + /// + public partial class AFDDomainHttpsParameters + { + /// + /// Initializes a new instance of the AFDDomainHttpsParameters class. + /// + public AFDDomainHttpsParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDDomainHttpsParameters class. + /// + /// Defines the source of the SSL + /// certificate. Possible values include: 'CustomerCertificate', + /// 'ManagedCertificate' + /// TLS protocol version that will be + /// used for Https. Possible values include: 'TLS10', 'TLS12' + /// Resource reference to the secret. ie. + /// subs/rg/profile/secret + public AFDDomainHttpsParameters(string certificateType, AfdMinimumTlsVersion? minimumTlsVersion = default(AfdMinimumTlsVersion?), ResourceReference secret = default(ResourceReference)) + { + CertificateType = certificateType; + MinimumTlsVersion = minimumTlsVersion; + Secret = secret; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the source of the SSL certificate. Possible + /// values include: 'CustomerCertificate', 'ManagedCertificate' + /// + [JsonProperty(PropertyName = "certificateType")] + public string CertificateType { get; set; } + + /// + /// Gets or sets TLS protocol version that will be used for Https. + /// Possible values include: 'TLS10', 'TLS12' + /// + [JsonProperty(PropertyName = "minimumTlsVersion")] + public AfdMinimumTlsVersion? MinimumTlsVersion { get; set; } + + /// + /// Gets or sets resource reference to the secret. ie. + /// subs/rg/profile/secret + /// + [JsonProperty(PropertyName = "secret")] + public ResourceReference Secret { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (CertificateType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CertificateType"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainUpdateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainUpdateParameters.cs new file mode 100644 index 000000000000..63651f4c661f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDDomainUpdateParameters.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The domain JSON object required for domain creation or update. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDDomainUpdateParameters + { + /// + /// Initializes a new instance of the AFDDomainUpdateParameters class. + /// + public AFDDomainUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDDomainUpdateParameters class. + /// + /// The configuration specifying how to + /// enable HTTPS for the domain - using AzureFrontDoor managed + /// certificate or user's own certificate. If not specified, enabling + /// ssl uses AzureFrontDoor managed certificate by default. + /// Resource reference to the Azure DNS + /// zone + public AFDDomainUpdateParameters(AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference)) + { + TlsSettings = tlsSettings; + AzureDnsZone = azureDnsZone; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the configuration specifying how to enable HTTPS for + /// the domain - using AzureFrontDoor managed certificate or user's own + /// certificate. If not specified, enabling ssl uses AzureFrontDoor + /// managed certificate by default. + /// + [JsonProperty(PropertyName = "properties.tlsSettings")] + public AFDDomainHttpsParameters TlsSettings { get; set; } + + /// + /// Gets or sets resource reference to the Azure DNS zone + /// + [JsonProperty(PropertyName = "properties.azureDnsZone")] + public ResourceReference AzureDnsZone { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (TlsSettings != null) + { + TlsSettings.Validate(); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpoint.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpoint.cs new file mode 100644 index 000000000000..dd502ae461d3 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpoint.cs @@ -0,0 +1,125 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// CDN endpoint is the entity within a CDN profile containing + /// configuration information such as origin, protocol, content caching and + /// delivery behavior. The AzureFrontDoor endpoint uses the URL format + /// <endpointname>.azureedge.net. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDEndpoint : TrackedResource + { + /// + /// Initializes a new instance of the AFDEndpoint class. + /// + public AFDEndpoint() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDEndpoint class. + /// + /// Resource location. + /// Resource ID. + /// Resource name. + /// Resource type. + /// Resource tags. + /// Send and receive timeout + /// on forwarding request to the origin. When timeout is reached, the + /// request fails and returns. + /// Whether to enable use of this rule. + /// Permitted values are 'Enabled' or 'Disabled'. Possible values + /// include: 'Enabled', 'Disabled' + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + /// The host name of the endpoint structured as + /// {endpointName}.{DNSZone}, e.g. contoso.azureedge.net + public AFDEndpoint(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData), int? originResponseTimeoutSeconds = default(int?), string enabledState = default(string), string provisioningState = default(string), string deploymentStatus = default(string), string hostName = default(string)) + : base(location, id, name, type, tags, systemData) + { + OriginResponseTimeoutSeconds = originResponseTimeoutSeconds; + EnabledState = enabledState; + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + HostName = hostName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets send and receive timeout on forwarding request to the + /// origin. When timeout is reached, the request fails and returns. + /// + [JsonProperty(PropertyName = "properties.originResponseTimeoutSeconds")] + public int? OriginResponseTimeoutSeconds { get; set; } + + /// + /// Gets or sets whether to enable use of this rule. Permitted values + /// are 'Enabled' or 'Disabled'. Possible values include: 'Enabled', + /// 'Disabled' + /// + [JsonProperty(PropertyName = "properties.enabledState")] + public string EnabledState { get; set; } + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Gets the host name of the endpoint structured as + /// {endpointName}.{DNSZone}, e.g. contoso.azureedge.net + /// + [JsonProperty(PropertyName = "properties.hostName")] + public string HostName { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (OriginResponseTimeoutSeconds < 16) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "OriginResponseTimeoutSeconds", 16); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointProtocols.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointProtocols.cs new file mode 100644 index 000000000000..028a92b6b34a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointProtocols.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for AFDEndpointProtocols. + /// + public static class AFDEndpointProtocols + { + public const string Http = "Http"; + public const string Https = "Https"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointUpdateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointUpdateParameters.cs new file mode 100644 index 000000000000..ef1e5f875ccc --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDEndpointUpdateParameters.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties required to create or update an endpoint. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDEndpointUpdateParameters : IResource + { + /// + /// Initializes a new instance of the AFDEndpointUpdateParameters + /// class. + /// + public AFDEndpointUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDEndpointUpdateParameters + /// class. + /// + /// Endpoint tags. + /// Send and receive timeout + /// on forwarding request to the origin. When timeout is reached, the + /// request fails and returns. + /// Whether to enable use of this rule. + /// Permitted values are 'Enabled' or 'Disabled'. Possible values + /// include: 'Enabled', 'Disabled' + public AFDEndpointUpdateParameters(IDictionary tags = default(IDictionary), int? originResponseTimeoutSeconds = default(int?), string enabledState = default(string)) + { + Tags = tags; + OriginResponseTimeoutSeconds = originResponseTimeoutSeconds; + EnabledState = enabledState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets endpoint tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets send and receive timeout on forwarding request to the + /// origin. When timeout is reached, the request fails and returns. + /// + [JsonProperty(PropertyName = "properties.originResponseTimeoutSeconds")] + public int? OriginResponseTimeoutSeconds { get; set; } + + /// + /// Gets or sets whether to enable use of this rule. Permitted values + /// are 'Enabled' or 'Disabled'. Possible values include: 'Enabled', + /// 'Disabled' + /// + [JsonProperty(PropertyName = "properties.enabledState")] + public string EnabledState { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (OriginResponseTimeoutSeconds < 16) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "OriginResponseTimeoutSeconds", 16); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOrigin.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOrigin.cs new file mode 100644 index 000000000000..91f28d089f87 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOrigin.cs @@ -0,0 +1,226 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// CDN origin is the source of the content being delivered via CDN. When + /// the edge nodes represented by an endpoint do not have the requested + /// content cached, they attempt to fetch it from one or more of the + /// configured origins. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDOrigin : ProxyResource + { + /// + /// Initializes a new instance of the AFDOrigin class. + /// + public AFDOrigin() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDOrigin class. + /// + /// The address of the origin. Domain names, + /// IPv4 addresses, and IPv6 addresses are supported.This should be + /// unique across all origins in an endpoint. + /// Resource ID. + /// Resource name. + /// Resource type. + /// Resource reference to the Azure origin + /// resource. + /// The value of the HTTP port. Must be between + /// 1 and 65535. + /// The value of the HTTPS port. Must be + /// between 1 and 65535. + /// The host header value sent to the + /// origin with each request. If you leave this blank, the request + /// hostname determines this value. Azure CDN origins, such as Web + /// Apps, Blob Storage, and Cloud Services require this host header + /// value to match the origin hostname by default. This overrides the + /// host header defined at Endpoint + /// Priority of origin in given origin group for + /// load balancing. Higher priorities will not be used for load + /// balancing if any lower priority origin is healthy.Must be between 1 + /// and 5 + /// Weight of the origin in given origin group for + /// load balancing. Must be between 1 and 1000 + /// The properties of the + /// private link resource for private origin. + /// Whether to enable health probes to be + /// made against backends defined under backendPools. Health probes can + /// only be disabled if there is a single enabled backend in single + /// enabled backend pool. Possible values include: 'Enabled', + /// 'Disabled' + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + public AFDOrigin(string hostName, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), ResourceReference azureOrigin = default(ResourceReference), int? httpPort = default(int?), int? httpsPort = default(int?), string originHostHeader = default(string), int? priority = default(int?), int? weight = default(int?), object sharedPrivateLinkResource = default(object), string enabledState = default(string), string provisioningState = default(string), string deploymentStatus = default(string)) + : base(id, name, type, systemData) + { + AzureOrigin = azureOrigin; + HostName = hostName; + HttpPort = httpPort; + HttpsPort = httpsPort; + OriginHostHeader = originHostHeader; + Priority = priority; + Weight = weight; + SharedPrivateLinkResource = sharedPrivateLinkResource; + EnabledState = enabledState; + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource reference to the Azure origin resource. + /// + [JsonProperty(PropertyName = "properties.azureOrigin")] + public ResourceReference AzureOrigin { get; set; } + + /// + /// Gets or sets the address of the origin. Domain names, IPv4 + /// addresses, and IPv6 addresses are supported.This should be unique + /// across all origins in an endpoint. + /// + [JsonProperty(PropertyName = "properties.hostName")] + public string HostName { get; set; } + + /// + /// Gets or sets the value of the HTTP port. Must be between 1 and + /// 65535. + /// + [JsonProperty(PropertyName = "properties.httpPort")] + public int? HttpPort { get; set; } + + /// + /// Gets or sets the value of the HTTPS port. Must be between 1 and + /// 65535. + /// + [JsonProperty(PropertyName = "properties.httpsPort")] + public int? HttpsPort { get; set; } + + /// + /// Gets or sets the host header value sent to the origin with each + /// request. If you leave this blank, the request hostname determines + /// this value. Azure CDN origins, such as Web Apps, Blob Storage, and + /// Cloud Services require this host header value to match the origin + /// hostname by default. This overrides the host header defined at + /// Endpoint + /// + [JsonProperty(PropertyName = "properties.originHostHeader")] + public string OriginHostHeader { get; set; } + + /// + /// Gets or sets priority of origin in given origin group for load + /// balancing. Higher priorities will not be used for load balancing if + /// any lower priority origin is healthy.Must be between 1 and 5 + /// + [JsonProperty(PropertyName = "properties.priority")] + public int? Priority { get; set; } + + /// + /// Gets or sets weight of the origin in given origin group for load + /// balancing. Must be between 1 and 1000 + /// + [JsonProperty(PropertyName = "properties.weight")] + public int? Weight { get; set; } + + /// + /// Gets or sets the properties of the private link resource for + /// private origin. + /// + [JsonProperty(PropertyName = "properties.sharedPrivateLinkResource")] + public object SharedPrivateLinkResource { get; set; } + + /// + /// Gets or sets whether to enable health probes to be made against + /// backends defined under backendPools. Health probes can only be + /// disabled if there is a single enabled backend in single enabled + /// backend pool. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.enabledState")] + public string EnabledState { get; set; } + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (HostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "HostName"); + } + if (HttpPort > 65535) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "HttpPort", 65535); + } + if (HttpPort < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "HttpPort", 1); + } + if (HttpsPort > 65535) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "HttpsPort", 65535); + } + if (HttpsPort < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "HttpsPort", 1); + } + if (Priority > 5) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Priority", 5); + } + if (Priority < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Priority", 1); + } + if (Weight > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Weight", 1000); + } + if (Weight < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Weight", 1); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroup.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroup.cs new file mode 100644 index 000000000000..7e2e1563d7e6 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroup.cs @@ -0,0 +1,157 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// AFDOrigin group comprising of origins is used for load balancing to + /// origins when the content cannot be served from CDN. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDOriginGroup : ProxyResource + { + /// + /// Initializes a new instance of the AFDOriginGroup class. + /// + public AFDOriginGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDOriginGroup class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// Load balancing settings for a + /// backend pool + /// Health probe settings to the + /// origin that is used to determine the health of the origin. + /// Time + /// in minutes to shift the traffic to the endpoint gradually when an + /// unhealthy endpoint comes healthy or a new endpoint is added. + /// Default is 10 mins. This property is currently not + /// supported. + /// The JSON + /// object that contains the properties to determine origin health + /// using real requests/responses. This property is currently not + /// supported. + /// Whether to allow session + /// affinity on this host. Valid options are 'Enabled' or 'Disabled'. + /// Possible values include: 'Enabled', 'Disabled' + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + public AFDOriginGroup(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), LoadBalancingSettingsParameters loadBalancingSettings = default(LoadBalancingSettingsParameters), HealthProbeParameters healthProbeSettings = default(HealthProbeParameters), int? trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default(int?), ResponseBasedOriginErrorDetectionParameters responseBasedAfdOriginErrorDetectionSettings = default(ResponseBasedOriginErrorDetectionParameters), string sessionAffinityState = default(string), string provisioningState = default(string), string deploymentStatus = default(string)) + : base(id, name, type, systemData) + { + LoadBalancingSettings = loadBalancingSettings; + HealthProbeSettings = healthProbeSettings; + TrafficRestorationTimeToHealedOrNewEndpointsInMinutes = trafficRestorationTimeToHealedOrNewEndpointsInMinutes; + ResponseBasedAfdOriginErrorDetectionSettings = responseBasedAfdOriginErrorDetectionSettings; + SessionAffinityState = sessionAffinityState; + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets load balancing settings for a backend pool + /// + [JsonProperty(PropertyName = "properties.loadBalancingSettings")] + public LoadBalancingSettingsParameters LoadBalancingSettings { get; set; } + + /// + /// Gets or sets health probe settings to the origin that is used to + /// determine the health of the origin. + /// + [JsonProperty(PropertyName = "properties.healthProbeSettings")] + public HealthProbeParameters HealthProbeSettings { get; set; } + + /// + /// Gets or sets time in minutes to shift the traffic to the endpoint + /// gradually when an unhealthy endpoint comes healthy or a new + /// endpoint is added. Default is 10 mins. This property is currently + /// not supported. + /// + [JsonProperty(PropertyName = "properties.trafficRestorationTimeToHealedOrNewEndpointsInMinutes")] + public int? TrafficRestorationTimeToHealedOrNewEndpointsInMinutes { get; set; } + + /// + /// Gets or sets the JSON object that contains the properties to + /// determine origin health using real requests/responses. This + /// property is currently not supported. + /// + [JsonProperty(PropertyName = "properties.responseBasedAfdOriginErrorDetectionSettings")] + public ResponseBasedOriginErrorDetectionParameters ResponseBasedAfdOriginErrorDetectionSettings { get; set; } + + /// + /// Gets or sets whether to allow session affinity on this host. Valid + /// options are 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.sessionAffinityState")] + public string SessionAffinityState { get; set; } + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (HealthProbeSettings != null) + { + HealthProbeSettings.Validate(); + } + if (TrafficRestorationTimeToHealedOrNewEndpointsInMinutes > 50) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "TrafficRestorationTimeToHealedOrNewEndpointsInMinutes", 50); + } + if (TrafficRestorationTimeToHealedOrNewEndpointsInMinutes < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "TrafficRestorationTimeToHealedOrNewEndpointsInMinutes", 0); + } + if (ResponseBasedAfdOriginErrorDetectionSettings != null) + { + ResponseBasedAfdOriginErrorDetectionSettings.Validate(); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroupUpdateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroupUpdateParameters.cs new file mode 100644 index 000000000000..c4476da2e015 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginGroupUpdateParameters.cs @@ -0,0 +1,134 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// AFDOrigin group properties needed for origin group creation or update. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDOriginGroupUpdateParameters : IResource + { + /// + /// Initializes a new instance of the AFDOriginGroupUpdateParameters + /// class. + /// + public AFDOriginGroupUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDOriginGroupUpdateParameters + /// class. + /// + /// Load balancing settings for a + /// backend pool + /// Health probe settings to the + /// origin that is used to determine the health of the origin. + /// Time + /// in minutes to shift the traffic to the endpoint gradually when an + /// unhealthy endpoint comes healthy or a new endpoint is added. + /// Default is 10 mins. This property is currently not + /// supported. + /// The JSON + /// object that contains the properties to determine origin health + /// using real requests/responses. This property is currently not + /// supported. + /// Whether to allow session + /// affinity on this host. Valid options are 'Enabled' or 'Disabled'. + /// Possible values include: 'Enabled', 'Disabled' + public AFDOriginGroupUpdateParameters(LoadBalancingSettingsParameters loadBalancingSettings = default(LoadBalancingSettingsParameters), HealthProbeParameters healthProbeSettings = default(HealthProbeParameters), int? trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default(int?), ResponseBasedOriginErrorDetectionParameters responseBasedAfdOriginErrorDetectionSettings = default(ResponseBasedOriginErrorDetectionParameters), string sessionAffinityState = default(string)) + { + LoadBalancingSettings = loadBalancingSettings; + HealthProbeSettings = healthProbeSettings; + TrafficRestorationTimeToHealedOrNewEndpointsInMinutes = trafficRestorationTimeToHealedOrNewEndpointsInMinutes; + ResponseBasedAfdOriginErrorDetectionSettings = responseBasedAfdOriginErrorDetectionSettings; + SessionAffinityState = sessionAffinityState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets load balancing settings for a backend pool + /// + [JsonProperty(PropertyName = "properties.loadBalancingSettings")] + public LoadBalancingSettingsParameters LoadBalancingSettings { get; set; } + + /// + /// Gets or sets health probe settings to the origin that is used to + /// determine the health of the origin. + /// + [JsonProperty(PropertyName = "properties.healthProbeSettings")] + public HealthProbeParameters HealthProbeSettings { get; set; } + + /// + /// Gets or sets time in minutes to shift the traffic to the endpoint + /// gradually when an unhealthy endpoint comes healthy or a new + /// endpoint is added. Default is 10 mins. This property is currently + /// not supported. + /// + [JsonProperty(PropertyName = "properties.trafficRestorationTimeToHealedOrNewEndpointsInMinutes")] + public int? TrafficRestorationTimeToHealedOrNewEndpointsInMinutes { get; set; } + + /// + /// Gets or sets the JSON object that contains the properties to + /// determine origin health using real requests/responses. This + /// property is currently not supported. + /// + [JsonProperty(PropertyName = "properties.responseBasedAfdOriginErrorDetectionSettings")] + public ResponseBasedOriginErrorDetectionParameters ResponseBasedAfdOriginErrorDetectionSettings { get; set; } + + /// + /// Gets or sets whether to allow session affinity on this host. Valid + /// options are 'Enabled' or 'Disabled'. Possible values include: + /// 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.sessionAffinityState")] + public string SessionAffinityState { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (HealthProbeSettings != null) + { + HealthProbeSettings.Validate(); + } + if (TrafficRestorationTimeToHealedOrNewEndpointsInMinutes > 50) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "TrafficRestorationTimeToHealedOrNewEndpointsInMinutes", 50); + } + if (TrafficRestorationTimeToHealedOrNewEndpointsInMinutes < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "TrafficRestorationTimeToHealedOrNewEndpointsInMinutes", 0); + } + if (ResponseBasedAfdOriginErrorDetectionSettings != null) + { + ResponseBasedAfdOriginErrorDetectionSettings.Validate(); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginUpdateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginUpdateParameters.cs new file mode 100644 index 000000000000..632d162e9cc1 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDOriginUpdateParameters.cs @@ -0,0 +1,195 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// AFDOrigin properties needed for origin update. + /// + [Rest.Serialization.JsonTransformation] + public partial class AFDOriginUpdateParameters : IResource + { + /// + /// Initializes a new instance of the AFDOriginUpdateParameters class. + /// + public AFDOriginUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDOriginUpdateParameters class. + /// + /// Resource reference to the Azure origin + /// resource. + /// The address of the origin. Domain names, + /// IPv4 addresses, and IPv6 addresses are supported.This should be + /// unique across all origins in an endpoint. + /// The value of the HTTP port. Must be between + /// 1 and 65535. + /// The value of the HTTPS port. Must be + /// between 1 and 65535. + /// The host header value sent to the + /// origin with each request. If you leave this blank, the request + /// hostname determines this value. Azure CDN origins, such as Web + /// Apps, Blob Storage, and Cloud Services require this host header + /// value to match the origin hostname by default. This overrides the + /// host header defined at Endpoint + /// Priority of origin in given origin group for + /// load balancing. Higher priorities will not be used for load + /// balancing if any lower priority origin is healthy.Must be between 1 + /// and 5 + /// Weight of the origin in given origin group for + /// load balancing. Must be between 1 and 1000 + /// The properties of the + /// private link resource for private origin. + /// Whether to enable health probes to be + /// made against backends defined under backendPools. Health probes can + /// only be disabled if there is a single enabled backend in single + /// enabled backend pool. Possible values include: 'Enabled', + /// 'Disabled' + public AFDOriginUpdateParameters(ResourceReference azureOrigin = default(ResourceReference), string hostName = default(string), int? httpPort = default(int?), int? httpsPort = default(int?), string originHostHeader = default(string), int? priority = default(int?), int? weight = default(int?), object sharedPrivateLinkResource = default(object), string enabledState = default(string)) + { + AzureOrigin = azureOrigin; + HostName = hostName; + HttpPort = httpPort; + HttpsPort = httpsPort; + OriginHostHeader = originHostHeader; + Priority = priority; + Weight = weight; + SharedPrivateLinkResource = sharedPrivateLinkResource; + EnabledState = enabledState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource reference to the Azure origin resource. + /// + [JsonProperty(PropertyName = "properties.azureOrigin")] + public ResourceReference AzureOrigin { get; set; } + + /// + /// Gets or sets the address of the origin. Domain names, IPv4 + /// addresses, and IPv6 addresses are supported.This should be unique + /// across all origins in an endpoint. + /// + [JsonProperty(PropertyName = "properties.hostName")] + public string HostName { get; set; } + + /// + /// Gets or sets the value of the HTTP port. Must be between 1 and + /// 65535. + /// + [JsonProperty(PropertyName = "properties.httpPort")] + public int? HttpPort { get; set; } + + /// + /// Gets or sets the value of the HTTPS port. Must be between 1 and + /// 65535. + /// + [JsonProperty(PropertyName = "properties.httpsPort")] + public int? HttpsPort { get; set; } + + /// + /// Gets or sets the host header value sent to the origin with each + /// request. If you leave this blank, the request hostname determines + /// this value. Azure CDN origins, such as Web Apps, Blob Storage, and + /// Cloud Services require this host header value to match the origin + /// hostname by default. This overrides the host header defined at + /// Endpoint + /// + [JsonProperty(PropertyName = "properties.originHostHeader")] + public string OriginHostHeader { get; set; } + + /// + /// Gets or sets priority of origin in given origin group for load + /// balancing. Higher priorities will not be used for load balancing if + /// any lower priority origin is healthy.Must be between 1 and 5 + /// + [JsonProperty(PropertyName = "properties.priority")] + public int? Priority { get; set; } + + /// + /// Gets or sets weight of the origin in given origin group for load + /// balancing. Must be between 1 and 1000 + /// + [JsonProperty(PropertyName = "properties.weight")] + public int? Weight { get; set; } + + /// + /// Gets or sets the properties of the private link resource for + /// private origin. + /// + [JsonProperty(PropertyName = "properties.sharedPrivateLinkResource")] + public object SharedPrivateLinkResource { get; set; } + + /// + /// Gets or sets whether to enable health probes to be made against + /// backends defined under backendPools. Health probes can only be + /// disabled if there is a single enabled backend in single enabled + /// backend pool. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.enabledState")] + public string EnabledState { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (HttpPort > 65535) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "HttpPort", 65535); + } + if (HttpPort < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "HttpPort", 1); + } + if (HttpsPort > 65535) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "HttpsPort", 65535); + } + if (HttpsPort < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "HttpsPort", 1); + } + if (Priority > 5) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Priority", 5); + } + if (Priority < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Priority", 1); + } + if (Weight > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Weight", 1000); + } + if (Weight < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Weight", 1); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDStateProperties.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDStateProperties.cs new file mode 100644 index 000000000000..4bab5b964416 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AFDStateProperties.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The tracking states for afd resources. + /// + public partial class AFDStateProperties + { + /// + /// Initializes a new instance of the AFDStateProperties class. + /// + public AFDStateProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AFDStateProperties class. + /// + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + public AFDStateProperties(string provisioningState = default(string), string deploymentStatus = default(string)) + { + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "deploymentStatus")] + public string DeploymentStatus { get; private set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdCertificateType.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdCertificateType.cs new file mode 100644 index 000000000000..2fa03a70d14d --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdCertificateType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for AfdCertificateType. + /// + public static class AfdCertificateType + { + public const string CustomerCertificate = "CustomerCertificate"; + public const string ManagedCertificate = "ManagedCertificate"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponse.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponse.cs new file mode 100644 index 000000000000..aa71302bbb53 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponse.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response + /// + /// + /// Common error response for all Azure Resource Manager APIs to return + /// error details for failed operations. (This also follows the OData error + /// response format.). + /// + public partial class AfdErrorResponse + { + /// + /// Initializes a new instance of the AfdErrorResponse class. + /// + public AfdErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AfdErrorResponse class. + /// + /// The error object. + public AfdErrorResponse(ErrorResponse error = default(ErrorResponse)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the error object. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponse Error { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponseException.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponseException.cs new file mode 100644 index 000000000000..f7dd76351f87 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with AfdErrorResponse + /// information. + /// + public partial class AfdErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public AfdErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the AfdErrorResponseException class. + /// + public AfdErrorResponseException() + { + } + + /// + /// Initializes a new instance of the AfdErrorResponseException class. + /// + /// The exception message. + public AfdErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the AfdErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public AfdErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdMinimumTlsVersion.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdMinimumTlsVersion.cs new file mode 100644 index 000000000000..2f3da0554f8e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdMinimumTlsVersion.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for AfdMinimumTlsVersion. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum AfdMinimumTlsVersion + { + [EnumMember(Value = "TLS10")] + TLS10, + [EnumMember(Value = "TLS12")] + TLS12 + } + internal static class AfdMinimumTlsVersionEnumExtension + { + internal static string ToSerializedValue(this AfdMinimumTlsVersion? value) + { + return value == null ? null : ((AfdMinimumTlsVersion)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this AfdMinimumTlsVersion value) + { + switch( value ) + { + case AfdMinimumTlsVersion.TLS10: + return "TLS10"; + case AfdMinimumTlsVersion.TLS12: + return "TLS12"; + } + return null; + } + + internal static AfdMinimumTlsVersion? ParseAfdMinimumTlsVersion(this string value) + { + switch( value ) + { + case "TLS10": + return AfdMinimumTlsVersion.TLS10; + case "TLS12": + return AfdMinimumTlsVersion.TLS12; + } + return null; + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdProvisioningState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdProvisioningState.cs new file mode 100644 index 000000000000..c646cab189ee --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdProvisioningState.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for AfdProvisioningState. + /// + public static class AfdProvisioningState + { + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + public const string Updating = "Updating"; + public const string Deleting = "Deleting"; + public const string Creating = "Creating"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdPurgeParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdPurgeParameters.cs new file mode 100644 index 000000000000..936ecf31815e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/AfdPurgeParameters.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Parameters required for content purge. + /// + public partial class AfdPurgeParameters + { + /// + /// Initializes a new instance of the AfdPurgeParameters class. + /// + public AfdPurgeParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AfdPurgeParameters class. + /// + /// The path to the content to be purged. + /// Can describe a file path or a wild card directory. + /// List of domains. + public AfdPurgeParameters(IList contentPaths, IList domains = default(IList)) + { + ContentPaths = contentPaths; + Domains = domains; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the path to the content to be purged. Can describe a + /// file path or a wild card directory. + /// + [JsonProperty(PropertyName = "contentPaths")] + public IList ContentPaths { get; set; } + + /// + /// Gets or sets list of domains. + /// + [JsonProperty(PropertyName = "domains")] + public IList Domains { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ContentPaths == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ContentPaths"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicy.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicy.cs index 31d0d1e2215b..1ca2d59ff717 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicy.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicy.cs @@ -59,8 +59,8 @@ public CdnWebApplicationFirewallPolicy() /// Resource status of the policy. /// Gets a unique read-only string that changes /// whenever the resource is updated. - public CdnWebApplicationFirewallPolicy(string location, Sku sku, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), PolicySettings policySettings = default(PolicySettings), RateLimitRuleList rateLimitRules = default(RateLimitRuleList), CustomRuleList customRules = default(CustomRuleList), ManagedRuleSetList managedRules = default(ManagedRuleSetList), IList endpointLinks = default(IList), string provisioningState = default(string), string resourceState = default(string), string etag = default(string)) - : base(location, id, name, type, tags) + public CdnWebApplicationFirewallPolicy(string location, Sku sku, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData), PolicySettings policySettings = default(PolicySettings), RateLimitRuleList rateLimitRules = default(RateLimitRuleList), CustomRuleList customRules = default(CustomRuleList), ManagedRuleSetList managedRules = default(ManagedRuleSetList), IList endpointLinks = default(IList), string provisioningState = default(string), string resourceState = default(string), string etag = default(string)) + : base(location, id, name, type, tags, systemData) { PolicySettings = policySettings; RateLimitRules = rateLimitRules; diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Certificate.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Certificate.cs new file mode 100644 index 000000000000..f268c76540ee --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Certificate.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Certificate used for https + /// + public partial class Certificate + { + /// + /// Initializes a new instance of the Certificate class. + /// + public Certificate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Certificate class. + /// + /// Subject name in the certificate. + /// Certificate expiration date. + /// Certificate thumbprint. + public Certificate(string subject = default(string), string expirationDate = default(string), string thumbprint = default(string)) + { + Subject = subject; + ExpirationDate = expirationDate; + Thumbprint = thumbprint; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets subject name in the certificate. + /// + [JsonProperty(PropertyName = "subject")] + public string Subject { get; set; } + + /// + /// Gets or sets certificate expiration date. + /// + [JsonProperty(PropertyName = "expirationDate")] + public string ExpirationDate { get; set; } + + /// + /// Gets or sets certificate thumbprint. + /// + [JsonProperty(PropertyName = "thumbprint")] + public string Thumbprint { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CompressionSettings.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CompressionSettings.cs new file mode 100644 index 000000000000..5837628aba7b --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CompressionSettings.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// settings for compression. + /// + public partial class CompressionSettings + { + /// + /// Initializes a new instance of the CompressionSettings class. + /// + public CompressionSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CompressionSettings class. + /// + /// List of content types on which + /// compression applies. The value should be a valid MIME type. + /// Indicates whether content + /// compression is enabled on AzureFrontDoor. Default value is false. + /// If compression is enabled, content will be served as compressed if + /// user requests for a compressed version. Content won't be compressed + /// on AzureFrontDoor when requested content is smaller than 1 byte or + /// larger than 1 MB. + public CompressionSettings(IList contentTypesToCompress = default(IList), bool? isCompressionEnabled = default(bool?)) + { + ContentTypesToCompress = contentTypesToCompress; + IsCompressionEnabled = isCompressionEnabled; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of content types on which compression applies. + /// The value should be a valid MIME type. + /// + [JsonProperty(PropertyName = "contentTypesToCompress")] + public IList ContentTypesToCompress { get; set; } + + /// + /// Gets or sets indicates whether content compression is enabled on + /// AzureFrontDoor. Default value is false. If compression is enabled, + /// content will be served as compressed if user requests for a + /// compressed version. Content won't be compressed on AzureFrontDoor + /// when requested content is smaller than 1 byte or larger than 1 MB. + /// + [JsonProperty(PropertyName = "isCompressionEnabled")] + public bool? IsCompressionEnabled { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponse.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponse.cs new file mode 100644 index 000000000000..6d6132fb879c --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponse.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Continents Response + /// + public partial class ContinentsResponse + { + /// + /// Initializes a new instance of the ContinentsResponse class. + /// + public ContinentsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContinentsResponse class. + /// + public ContinentsResponse(IList continents = default(IList), IList countryOrRegions = default(IList)) + { + Continents = continents; + CountryOrRegions = countryOrRegions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "continents")] + public IList Continents { get; set; } + + /// + /// + [JsonProperty(PropertyName = "countryOrRegions")] + public IList CountryOrRegions { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseContinentsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseContinentsItem.cs new file mode 100644 index 000000000000..13ccec0d0e84 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseContinentsItem.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ContinentsResponseContinentsItem + { + /// + /// Initializes a new instance of the ContinentsResponseContinentsItem + /// class. + /// + public ContinentsResponseContinentsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContinentsResponseContinentsItem + /// class. + /// + public ContinentsResponseContinentsItem(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseCountryOrRegionsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseCountryOrRegionsItem.cs new file mode 100644 index 000000000000..1d14acaa2013 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ContinentsResponseCountryOrRegionsItem.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ContinentsResponseCountryOrRegionsItem + { + /// + /// Initializes a new instance of the + /// ContinentsResponseCountryOrRegionsItem class. + /// + public ContinentsResponseCountryOrRegionsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ContinentsResponseCountryOrRegionsItem class. + /// + public ContinentsResponseCountryOrRegionsItem(string id = default(string), string continentId = default(string)) + { + Id = id; + ContinentId = continentId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "continentId")] + public string ContinentId { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesMatchConditionParameters.cs index 0df2f1f4222c..1a07982f3cdd 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesMatchConditionParameters.cs @@ -34,17 +34,17 @@ public CookiesMatchConditionParameters() /// Initializes a new instance of the CookiesMatchConditionParameters /// class. /// - /// Name of Cookies to be matched /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' + /// Name of Cookies to be matched /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public CookiesMatchConditionParameters(string selector, string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public CookiesMatchConditionParameters(string operatorProperty, string selector = default(string), bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { Selector = selector; OperatorProperty = operatorProperty; @@ -75,7 +75,8 @@ static CookiesMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -111,18 +112,10 @@ static CookiesMatchConditionParameters() /// public virtual void Validate() { - if (Selector == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Selector"); - } if (OperatorProperty == null) { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesOperator.cs index 44140689a090..a8afbc3e9c37 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CookiesOperator.cs @@ -25,5 +25,6 @@ public static class CookiesOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomain.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomain.cs index 07f741dd671d..455786263358 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomain.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomain.cs @@ -59,8 +59,8 @@ public CustomDomain() /// required to deliver content in China. /// Provisioning status of the custom /// domain. - public CustomDomain(string hostName, string id = default(string), string name = default(string), string type = default(string), string resourceState = default(string), string customHttpsProvisioningState = default(string), string customHttpsProvisioningSubstate = default(string), string validationData = default(string), string provisioningState = default(string)) - : base(id, name, type) + public CustomDomain(string hostName, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string resourceState = default(string), string customHttpsProvisioningState = default(string), string customHttpsProvisioningSubstate = default(string), string validationData = default(string), string provisioningState = default(string)) + : base(id, name, type, systemData) { HostName = hostName; ResourceState = resourceState; diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificate.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificate.cs new file mode 100644 index 000000000000..68993224bb7a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificate.cs @@ -0,0 +1,106 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Customer Certificate used for https + /// + public partial class CustomerCertificate : Certificate + { + /// + /// Initializes a new instance of the CustomerCertificate class. + /// + public CustomerCertificate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomerCertificate class. + /// + /// Complete Url to the + /// certificate + /// Subject name in the certificate. + /// Certificate expiration date. + /// Certificate thumbprint. + /// Certificate version. + /// Certificate issuing + /// authority. + /// Whether to use the latest version + /// for the certificate + /// The list of SANs. + public CustomerCertificate(string certificateUrl, string subject = default(string), string expirationDate = default(string), string thumbprint = default(string), string version = default(string), string certificateAuthority = default(string), bool? useLatestVersion = default(bool?), IList subjectAlternativeNames = default(IList)) + : base(subject, expirationDate, thumbprint) + { + Version = version; + CertificateAuthority = certificateAuthority; + CertificateUrl = certificateUrl; + UseLatestVersion = useLatestVersion; + SubjectAlternativeNames = subjectAlternativeNames; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets certificate version. + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; set; } + + /// + /// Gets or sets certificate issuing authority. + /// + [JsonProperty(PropertyName = "certificateAuthority")] + public string CertificateAuthority { get; set; } + + /// + /// Gets or sets complete Url to the certificate + /// + [JsonProperty(PropertyName = "certificateUrl")] + public string CertificateUrl { get; set; } + + /// + /// Gets or sets whether to use the latest version for the certificate + /// + [JsonProperty(PropertyName = "useLatestVersion")] + public bool? UseLatestVersion { get; set; } + + /// + /// Gets or sets the list of SANs. + /// + [JsonProperty(PropertyName = "subjectAlternativeNames")] + public IList SubjectAlternativeNames { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (CertificateUrl == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CertificateUrl"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificateParameters.cs new file mode 100644 index 000000000000..ed6404062c50 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomerCertificateParameters.cs @@ -0,0 +1,145 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Customer Certificate used for https + /// + public partial class CustomerCertificateParameters + { + /// + /// Initializes a new instance of the CustomerCertificateParameters + /// class. + /// + public CustomerCertificateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomerCertificateParameters + /// class. + /// + /// The type of the Secret to create. Possible + /// values include: 'UrlSigningKey', 'CustomerCertificate', + /// 'ManagedCertificate' + /// Resource reference to the KV + /// secret + /// Subject name in the certificate. + /// Certificate expiration date. + /// Certificate thumbprint. + /// Version of the secret to be + /// used + /// Certificate issuing + /// authority. + /// Whether to use the latest version + /// for the certificate + /// The list of SANs. + public CustomerCertificateParameters(string type, ResourceReference secretSource, string subject = default(string), string expirationDate = default(string), string thumbprint = default(string), string secretVersion = default(string), string certificateAuthority = default(string), bool? useLatestVersion = default(bool?), IList subjectAlternativeNames = default(IList)) + { + Type = type; + Subject = subject; + ExpirationDate = expirationDate; + Thumbprint = thumbprint; + SecretSource = secretSource; + SecretVersion = secretVersion; + CertificateAuthority = certificateAuthority; + UseLatestVersion = useLatestVersion; + SubjectAlternativeNames = subjectAlternativeNames; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the Secret to create. Possible values + /// include: 'UrlSigningKey', 'CustomerCertificate', + /// 'ManagedCertificate' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets subject name in the certificate. + /// + [JsonProperty(PropertyName = "subject")] + public string Subject { get; set; } + + /// + /// Gets or sets certificate expiration date. + /// + [JsonProperty(PropertyName = "expirationDate")] + public string ExpirationDate { get; set; } + + /// + /// Gets or sets certificate thumbprint. + /// + [JsonProperty(PropertyName = "thumbprint")] + public string Thumbprint { get; set; } + + /// + /// Gets or sets resource reference to the KV secret + /// + [JsonProperty(PropertyName = "secretSource")] + public ResourceReference SecretSource { get; set; } + + /// + /// Gets or sets version of the secret to be used + /// + [JsonProperty(PropertyName = "secretVersion")] + public string SecretVersion { get; set; } + + /// + /// Gets or sets certificate issuing authority. + /// + [JsonProperty(PropertyName = "certificateAuthority")] + public string CertificateAuthority { get; set; } + + /// + /// Gets or sets whether to use the latest version for the certificate + /// + [JsonProperty(PropertyName = "useLatestVersion")] + public bool? UseLatestVersion { get; set; } + + /// + /// Gets or sets the list of SANs. + /// + [JsonProperty(PropertyName = "subjectAlternativeNames")] + public IList SubjectAlternativeNames { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (SecretSource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SecretSource"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleHttpVersionCondition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleHttpVersionCondition.cs index 2c3a237bfbd9..bf5cada1e2e9 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleHttpVersionCondition.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleHttpVersionCondition.cs @@ -65,10 +65,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "Parameters"); } - if (Parameters != null) - { - Parameters.Validate(); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleIsDeviceCondition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleIsDeviceCondition.cs index e59e61d7049a..91232df33184 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleIsDeviceCondition.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleIsDeviceCondition.cs @@ -65,10 +65,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "Parameters"); } - if (Parameters != null) - { - Parameters.Validate(); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestMethodCondition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestMethodCondition.cs index edc90e365c37..4e14ca10aaa7 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestMethodCondition.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestMethodCondition.cs @@ -65,10 +65,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "Parameters"); } - if (Parameters != null) - { - Parameters.Validate(); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestSchemeCondition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestSchemeCondition.cs index 7d17f8742c24..781eab76d965 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestSchemeCondition.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleRequestSchemeCondition.cs @@ -65,10 +65,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "Parameters"); } - if (Parameters != null) - { - Parameters.Validate(); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeploymentStatus.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeploymentStatus.cs new file mode 100644 index 000000000000..5658bebc8c29 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeploymentStatus.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for DeploymentStatus. + /// + public static class DeploymentStatus + { + public const string NotStarted = "NotStarted"; + public const string InProgress = "InProgress"; + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationProperties.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationProperties.cs new file mode 100644 index 000000000000..7406982b3a73 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationProperties.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The JSON object that contains the properties to validate a domain. + /// + public partial class DomainValidationProperties + { + /// + /// Initializes a new instance of the DomainValidationProperties class. + /// + public DomainValidationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DomainValidationProperties class. + /// + /// Challenge used for DNS TXT record or + /// file based validation + /// The date time that the token + /// expires + public DomainValidationProperties(string validationToken = default(string), string expirationDate = default(string)) + { + ValidationToken = validationToken; + ExpirationDate = expirationDate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets challenge used for DNS TXT record or file based validation + /// + [JsonProperty(PropertyName = "validationToken")] + public string ValidationToken { get; private set; } + + /// + /// Gets the date time that the token expires + /// + [JsonProperty(PropertyName = "expirationDate")] + public string ExpirationDate { get; private set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationState.cs new file mode 100644 index 000000000000..9039d32ee69c --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DomainValidationState.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for DomainValidationState. + /// + public static class DomainValidationState + { + public const string Unknown = "Unknown"; + public const string Submitting = "Submitting"; + public const string Pending = "Pending"; + public const string TimedOut = "TimedOut"; + public const string PendingRevalidation = "PendingRevalidation"; + public const string Approved = "Approved"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EdgeNode.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EdgeNode.cs index 83ffb66dde30..17a96b47cc78 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EdgeNode.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EdgeNode.cs @@ -39,8 +39,8 @@ public EdgeNode() /// Resource ID. /// Resource name. /// Resource type. - public EdgeNode(IList ipAddressGroups, string id = default(string), string name = default(string), string type = default(string)) - : base(id, name, type) + public EdgeNode(IList ipAddressGroups, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type, systemData) { IpAddressGroups = ipAddressGroups; CustomInit(); diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EnabledState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EnabledState.cs new file mode 100644 index 000000000000..01e622828add --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EnabledState.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for EnabledState. + /// + public static class EnabledState + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Endpoint.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Endpoint.cs index 5d347d7607e5..263188c1ed34 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Endpoint.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Endpoint.cs @@ -108,8 +108,8 @@ public Endpoint() /// 'Starting', 'Stopped', 'Stopping' /// Provisioning status of the /// endpoint. - public Endpoint(string location, IList origins, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string originPath = default(string), IList contentTypesToCompress = default(IList), string originHostHeader = default(string), bool? isCompressionEnabled = default(bool?), bool? isHttpAllowed = default(bool?), bool? isHttpsAllowed = default(bool?), QueryStringCachingBehavior? queryStringCachingBehavior = default(QueryStringCachingBehavior?), string optimizationType = default(string), string probePath = default(string), IList geoFilters = default(IList), ResourceReference defaultOriginGroup = default(ResourceReference), IList urlSigningKeys = default(IList), EndpointPropertiesUpdateParametersDeliveryPolicy deliveryPolicy = default(EndpointPropertiesUpdateParametersDeliveryPolicy), EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink webApplicationFirewallPolicyLink = default(EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink), string hostName = default(string), IList originGroups = default(IList), string resourceState = default(string), string provisioningState = default(string)) - : base(location, id, name, type, tags) + public Endpoint(string location, IList origins, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData), string originPath = default(string), IList contentTypesToCompress = default(IList), string originHostHeader = default(string), bool? isCompressionEnabled = default(bool?), bool? isHttpAllowed = default(bool?), bool? isHttpsAllowed = default(bool?), QueryStringCachingBehavior? queryStringCachingBehavior = default(QueryStringCachingBehavior?), string optimizationType = default(string), string probePath = default(string), IList geoFilters = default(IList), ResourceReference defaultOriginGroup = default(ResourceReference), IList urlSigningKeys = default(IList), EndpointPropertiesUpdateParametersDeliveryPolicy deliveryPolicy = default(EndpointPropertiesUpdateParametersDeliveryPolicy), EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink webApplicationFirewallPolicyLink = default(EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink), string hostName = default(string), IList originGroups = default(IList), string resourceState = default(string), string provisioningState = default(string)) + : base(location, id, name, type, tags, systemData) { OriginPath = originPath; ContentTypesToCompress = contentTypesToCompress; diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ForwardingProtocol.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ForwardingProtocol.cs new file mode 100644 index 000000000000..d4fc4460d1cf --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ForwardingProtocol.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for ForwardingProtocol. + /// + public static class ForwardingProtocol + { + public const string HttpOnly = "HttpOnly"; + public const string HttpsOnly = "HttpsOnly"; + public const string MatchRequest = "MatchRequest"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpVersionMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpVersionMatchConditionParameters.cs index 211ca9144a5b..64ad0a484b5e 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpVersionMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpVersionMatchConditionParameters.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Cdn.Models { - using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -34,11 +33,11 @@ public HttpVersionMatchConditionParameters() /// Initializes a new instance of the /// HttpVersionMatchConditionParameters class. /// - /// The match value for the condition of the - /// delivery rule /// Describes if this is negate condition /// or not - public HttpVersionMatchConditionParameters(IList matchValues, bool? negateCondition = default(bool?)) + /// The match value for the condition of the + /// delivery rule + public HttpVersionMatchConditionParameters(bool? negateCondition = default(bool?), IList matchValues = default(IList)) { NegateCondition = negateCondition; MatchValues = matchValues; @@ -81,18 +80,5 @@ static HttpVersionMatchConditionParameters() [JsonProperty(PropertyName = "operator")] public static string OperatorProperty { get; private set; } - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } - } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpsRedirect.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpsRedirect.cs new file mode 100644 index 000000000000..36e6a79144d8 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/HttpsRedirect.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for HttpsRedirect. + /// + public static class HttpsRedirect + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IdentityType.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IdentityType.cs new file mode 100644 index 000000000000..38b7380f6bf2 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IdentityType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for IdentityType. + /// + public static class IdentityType + { + public const string User = "user"; + public const string Application = "application"; + public const string ManagedIdentity = "managedIdentity"; + public const string Key = "key"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IsDeviceMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IsDeviceMatchConditionParameters.cs index 92309e54ae4b..7a38dc323700 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IsDeviceMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/IsDeviceMatchConditionParameters.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Cdn.Models { - using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -34,12 +33,12 @@ public IsDeviceMatchConditionParameters() /// Initializes a new instance of the IsDeviceMatchConditionParameters /// class. /// - /// The match value for the condition of the - /// delivery rule /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public IsDeviceMatchConditionParameters(IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public IsDeviceMatchConditionParameters(bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { NegateCondition = negateCondition; MatchValues = matchValues; @@ -89,18 +88,5 @@ static IsDeviceMatchConditionParameters() [JsonProperty(PropertyName = "operator")] public static string OperatorProperty { get; private set; } - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } - } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/KeyVaultCertificateSourceParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/KeyVaultCertificateSourceParameters.cs index 1a09efcef3f1..130af5fb8e28 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/KeyVaultCertificateSourceParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/KeyVaultCertificateSourceParameters.cs @@ -43,7 +43,7 @@ public KeyVaultCertificateSourceParameters() /// the full certificate PFX) in Key Vault. /// The version(GUID) of Key Vault Secret /// in Key Vault. - public KeyVaultCertificateSourceParameters(string subscriptionId, string resourceGroupName, string vaultName, string secretName, string secretVersion) + public KeyVaultCertificateSourceParameters(string subscriptionId, string resourceGroupName, string vaultName, string secretName, string secretVersion = default(string)) { SubscriptionId = subscriptionId; ResourceGroupName = resourceGroupName; @@ -144,10 +144,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "SecretName"); } - if (SecretVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "SecretVersion"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LinkToDefaultDomain.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LinkToDefaultDomain.cs new file mode 100644 index 000000000000..7a0b2ab7355f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LinkToDefaultDomain.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for LinkToDefaultDomain. + /// + public static class LinkToDefaultDomain + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LoadBalancingSettingsParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LoadBalancingSettingsParameters.cs new file mode 100644 index 000000000000..3130a4b54662 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/LoadBalancingSettingsParameters.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Round-Robin load balancing settings for a backend pool + /// + public partial class LoadBalancingSettingsParameters + { + /// + /// Initializes a new instance of the LoadBalancingSettingsParameters + /// class. + /// + public LoadBalancingSettingsParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LoadBalancingSettingsParameters + /// class. + /// + /// The number of samples to consider for load + /// balancing decisions + /// The number of samples + /// within the sample period that must succeed + /// The additional + /// latency in milliseconds for probes to fall into the lowest latency + /// bucket + public LoadBalancingSettingsParameters(int? sampleSize = default(int?), int? successfulSamplesRequired = default(int?), int? additionalLatencyInMilliseconds = default(int?)) + { + SampleSize = sampleSize; + SuccessfulSamplesRequired = successfulSamplesRequired; + AdditionalLatencyInMilliseconds = additionalLatencyInMilliseconds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the number of samples to consider for load balancing + /// decisions + /// + [JsonProperty(PropertyName = "sampleSize")] + public int? SampleSize { get; set; } + + /// + /// Gets or sets the number of samples within the sample period that + /// must succeed + /// + [JsonProperty(PropertyName = "successfulSamplesRequired")] + public int? SuccessfulSamplesRequired { get; set; } + + /// + /// Gets or sets the additional latency in milliseconds for probes to + /// fall into the lowest latency bucket + /// + [JsonProperty(PropertyName = "additionalLatencyInMilliseconds")] + public int? AdditionalLatencyInMilliseconds { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificate.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificate.cs new file mode 100644 index 000000000000..d49393bd150a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificate.cs @@ -0,0 +1,46 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using System.Linq; + + /// + /// Managed Certificate used for https + /// + public partial class ManagedCertificate : Certificate + { + /// + /// Initializes a new instance of the ManagedCertificate class. + /// + public ManagedCertificate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedCertificate class. + /// + /// Subject name in the certificate. + /// Certificate expiration date. + /// Certificate thumbprint. + public ManagedCertificate(string subject = default(string), string expirationDate = default(string), string thumbprint = default(string)) + : base(subject, expirationDate, thumbprint) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificateParameters.cs new file mode 100644 index 000000000000..c284443f9c3f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedCertificateParameters.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Managed Certificate used for https + /// + public partial class ManagedCertificateParameters + { + /// + /// Initializes a new instance of the ManagedCertificateParameters + /// class. + /// + public ManagedCertificateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedCertificateParameters + /// class. + /// + /// The type of the Secret to create. Possible + /// values include: 'UrlSigningKey', 'CustomerCertificate', + /// 'ManagedCertificate' + /// Subject name in the certificate. + /// Certificate expiration date. + /// Certificate thumbprint. + public ManagedCertificateParameters(string type, string subject = default(string), string expirationDate = default(string), string thumbprint = default(string)) + { + Type = type; + Subject = subject; + ExpirationDate = expirationDate; + Thumbprint = thumbprint; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the Secret to create. Possible values + /// include: 'UrlSigningKey', 'CustomerCertificate', + /// 'ManagedCertificate' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets subject name in the certificate. + /// + [JsonProperty(PropertyName = "subject")] + public string Subject { get; set; } + + /// + /// Gets or sets certificate expiration date. + /// + [JsonProperty(PropertyName = "expirationDate")] + public string ExpirationDate { get; set; } + + /// + /// Gets or sets certificate thumbprint. + /// + [JsonProperty(PropertyName = "thumbprint")] + public string Thumbprint { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchProcessingBehavior.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchProcessingBehavior.cs new file mode 100644 index 000000000000..64c6958b6184 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchProcessingBehavior.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for MatchProcessingBehavior. + /// + public static class MatchProcessingBehavior + { + public const string Continue = "Continue"; + public const string Stop = "Stop"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponse.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponse.cs new file mode 100644 index 000000000000..e7217e9941c8 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponse.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Metrics Response + /// + public partial class MetricsResponse + { + /// + /// Initializes a new instance of the MetricsResponse class. + /// + public MetricsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricsResponse class. + /// + /// Possible values include: 'PT5M', 'PT1H', + /// 'P1D' + public MetricsResponse(System.DateTime? dateTimeBegin = default(System.DateTime?), System.DateTime? dateTimeEnd = default(System.DateTime?), string granularity = default(string), IList series = default(IList)) + { + DateTimeBegin = dateTimeBegin; + DateTimeEnd = dateTimeEnd; + Granularity = granularity; + Series = series; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "dateTimeBegin")] + public System.DateTime? DateTimeBegin { get; set; } + + /// + /// + [JsonProperty(PropertyName = "dateTimeEnd")] + public System.DateTime? DateTimeEnd { get; set; } + + /// + /// Gets or sets possible values include: 'PT5M', 'PT1H', 'P1D' + /// + [JsonProperty(PropertyName = "granularity")] + public string Granularity { get; set; } + + /// + /// + [JsonProperty(PropertyName = "series")] + public IList Series { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItem.cs new file mode 100644 index 000000000000..33d75827663f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItem.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class MetricsResponseSeriesItem + { + /// + /// Initializes a new instance of the MetricsResponseSeriesItem class. + /// + public MetricsResponseSeriesItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricsResponseSeriesItem class. + /// + /// Possible values include: 'count', 'bytes', + /// 'bitsPerSecond' + public MetricsResponseSeriesItem(string metric = default(string), string unit = default(string), IList groups = default(IList), IList data = default(IList)) + { + Metric = metric; + Unit = unit; + Groups = groups; + Data = data; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "metric")] + public string Metric { get; set; } + + /// + /// Gets or sets possible values include: 'count', 'bytes', + /// 'bitsPerSecond' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// + [JsonProperty(PropertyName = "groups")] + public IList Groups { get; set; } + + /// + /// + [JsonProperty(PropertyName = "data")] + public IList Data { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemDataItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemDataItem.cs new file mode 100644 index 000000000000..6137ce8b8d83 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemDataItem.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class MetricsResponseSeriesItemDataItem + { + /// + /// Initializes a new instance of the MetricsResponseSeriesItemDataItem + /// class. + /// + public MetricsResponseSeriesItemDataItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricsResponseSeriesItemDataItem + /// class. + /// + public MetricsResponseSeriesItemDataItem(System.DateTime? dateTime = default(System.DateTime?), double? value = default(double?)) + { + DateTime = dateTime; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "dateTime")] + public System.DateTime? DateTime { get; set; } + + /// + /// + [JsonProperty(PropertyName = "value")] + public double? Value { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemGroupsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemGroupsItem.cs new file mode 100644 index 000000000000..037cb788e477 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MetricsResponseSeriesItemGroupsItem.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class MetricsResponseSeriesItemGroupsItem + { + /// + /// Initializes a new instance of the + /// MetricsResponseSeriesItemGroupsItem class. + /// + public MetricsResponseSeriesItemGroupsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MetricsResponseSeriesItemGroupsItem class. + /// + public MetricsResponseSeriesItemGroupsItem(string name = default(string), string value = default(string)) + { + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Origin.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Origin.cs index c44cc9324916..3498c598aac7 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Origin.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Origin.cs @@ -78,8 +78,8 @@ public Origin() /// The approval status for the /// connection to the Private Link. Possible values include: 'Pending', /// 'Approved', 'Rejected', 'Disconnected', 'Timeout' - public Origin(string id = default(string), string name = default(string), string type = default(string), string hostName = default(string), int? httpPort = default(int?), int? httpsPort = default(int?), string originHostHeader = default(string), int? priority = default(int?), int? weight = default(int?), bool? enabled = default(bool?), string privateLinkAlias = default(string), string privateLinkResourceId = default(string), string privateLinkLocation = default(string), string privateLinkApprovalMessage = default(string), string resourceState = default(string), string provisioningState = default(string), string privateEndpointStatus = default(string)) - : base(id, name, type) + public Origin(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string hostName = default(string), int? httpPort = default(int?), int? httpsPort = default(int?), string originHostHeader = default(string), int? priority = default(int?), int? weight = default(int?), bool? enabled = default(bool?), string privateLinkAlias = default(string), string privateLinkResourceId = default(string), string privateLinkLocation = default(string), string privateLinkApprovalMessage = default(string), string resourceState = default(string), string provisioningState = default(string), string privateEndpointStatus = default(string)) + : base(id, name, type, systemData) { HostName = hostName; HttpPort = httpPort; diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroup.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroup.cs index 1e1157c9729f..ba6064fae7f4 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroup.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroup.cs @@ -56,8 +56,8 @@ public OriginGroup() /// Possible values include: 'Creating', 'Active', 'Deleting' /// Provisioning status of the origin /// group. - public OriginGroup(string id = default(string), string name = default(string), string type = default(string), HealthProbeParameters healthProbeSettings = default(HealthProbeParameters), IList origins = default(IList), int? trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default(int?), ResponseBasedOriginErrorDetectionParameters responseBasedOriginErrorDetectionSettings = default(ResponseBasedOriginErrorDetectionParameters), string resourceState = default(string), string provisioningState = default(string)) - : base(id, name, type) + public OriginGroup(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), HealthProbeParameters healthProbeSettings = default(HealthProbeParameters), IList origins = default(IList), int? trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default(int?), ResponseBasedOriginErrorDetectionParameters responseBasedOriginErrorDetectionSettings = default(ResponseBasedOriginErrorDetectionParameters), string resourceState = default(string), string provisioningState = default(string)) + : base(id, name, type, systemData) { HealthProbeSettings = healthProbeSettings; Origins = origins; diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideAction.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideAction.cs new file mode 100644 index 000000000000..a7b8237e2014 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideAction.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the origin group override action for the delivery rule. + /// + [Newtonsoft.Json.JsonObject("OriginGroupOverride")] + public partial class OriginGroupOverrideAction : DeliveryRuleAction + { + /// + /// Initializes a new instance of the OriginGroupOverrideAction class. + /// + public OriginGroupOverrideAction() + { + Parameters = new OriginGroupOverrideActionParameters(); + CustomInit(); + } + + /// + /// Initializes a new instance of the OriginGroupOverrideAction class. + /// + /// Defines the parameters for the + /// action. + public OriginGroupOverrideAction(OriginGroupOverrideActionParameters parameters) + { + Parameters = parameters; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the parameters for the action. + /// + [JsonProperty(PropertyName = "parameters")] + public OriginGroupOverrideActionParameters Parameters { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Parameters"); + } + if (Parameters != null) + { + Parameters.Validate(); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideActionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideActionParameters.cs new file mode 100644 index 000000000000..98e0afb2f006 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OriginGroupOverrideActionParameters.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the parameters for the origin group override action. + /// + public partial class OriginGroupOverrideActionParameters + { + /// + /// Initializes a new instance of the + /// OriginGroupOverrideActionParameters class. + /// + public OriginGroupOverrideActionParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// OriginGroupOverrideActionParameters class. + /// + /// defines the OriginGroup that would + /// override the DefaultOriginGroup. + public OriginGroupOverrideActionParameters(ResourceReference originGroup) + { + OriginGroup = originGroup; + CustomInit(); + } + /// + /// Static constructor for OriginGroupOverrideActionParameters class. + /// + static OriginGroupOverrideActionParameters() + { + Odatatype = "#Microsoft.Azure.Cdn.Models.DeliveryRuleOriginGroupOverrideActionParameters"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the OriginGroup that would override the + /// DefaultOriginGroup. + /// + [JsonProperty(PropertyName = "originGroup")] + public ResourceReference OriginGroup { get; set; } + + /// + /// + [JsonProperty(PropertyName = "@odata.type")] + public static string Odatatype { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (OriginGroup == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OriginGroup"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsMatchConditionParameters.cs index 46d513316942..23a26e93f871 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsMatchConditionParameters.cs @@ -34,17 +34,17 @@ public PostArgsMatchConditionParameters() /// Initializes a new instance of the PostArgsMatchConditionParameters /// class. /// - /// Name of PostArg to be matched /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' + /// Name of PostArg to be matched /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public PostArgsMatchConditionParameters(string selector, string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public PostArgsMatchConditionParameters(string operatorProperty, string selector = default(string), bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { Selector = selector; OperatorProperty = operatorProperty; @@ -75,7 +75,8 @@ static PostArgsMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -111,18 +112,10 @@ static PostArgsMatchConditionParameters() /// public virtual void Validate() { - if (Selector == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Selector"); - } if (OperatorProperty == null) { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsOperator.cs index bad9f5834e92..38bad2b914a4 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PostArgsOperator.cs @@ -25,5 +25,6 @@ public static class PostArgsOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Profile.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Profile.cs index 3f656ee76c72..37b5b01dff02 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Profile.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Profile.cs @@ -47,12 +47,14 @@ public Profile() /// 'Disabled' /// Provisioning status of the /// profile. - public Profile(string location, Sku sku, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string resourceState = default(string), string provisioningState = default(string)) - : base(location, id, name, type, tags) + /// The Id of the frontdoor. + public Profile(string location, Sku sku, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData), string resourceState = default(string), string provisioningState = default(string), string frontdoorId = default(string)) + : base(location, id, name, type, tags, systemData) { Sku = sku; ResourceState = resourceState; ProvisioningState = provisioningState; + FrontdoorId = frontdoorId; CustomInit(); } @@ -81,6 +83,12 @@ public Profile() [JsonProperty(PropertyName = "properties.provisioningState")] public string ProvisioningState { get; private set; } + /// + /// Gets the Id of the frontdoor. + /// + [JsonProperty(PropertyName = "properties.frontdoorId")] + public string FrontdoorId { get; private set; } + /// /// Validate the object. /// diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ProxyResource.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ProxyResource.cs index 8b2c6bc29a7a..229382169421 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ProxyResource.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ProxyResource.cs @@ -10,6 +10,7 @@ namespace Microsoft.Azure.Management.Cdn.Models { + using Newtonsoft.Json; using System.Linq; /// @@ -32,9 +33,10 @@ public ProxyResource() /// Resource ID. /// Resource name. /// Resource type. - public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + public ProxyResource(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData)) : base(id, name, type) { + SystemData = systemData; CustomInit(); } @@ -43,5 +45,10 @@ public ProxyResource() /// partial void CustomInit(); + /// + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringMatchConditionParameters.cs index 60650c87f3bb..c1fcaf5747e6 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringMatchConditionParameters.cs @@ -37,13 +37,13 @@ public QueryStringMatchConditionParameters() /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public QueryStringMatchConditionParameters(string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public QueryStringMatchConditionParameters(string operatorProperty, bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { OperatorProperty = operatorProperty; NegateCondition = negateCondition; @@ -67,7 +67,8 @@ static QueryStringMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -107,10 +108,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringOperator.cs index ab86bf692e4e..9642b032c4f7 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/QueryStringOperator.cs @@ -25,5 +25,6 @@ public static class QueryStringOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponse.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponse.cs new file mode 100644 index 000000000000..9d3d733da01e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponse.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Rankings Response + /// + public partial class RankingsResponse + { + /// + /// Initializes a new instance of the RankingsResponse class. + /// + public RankingsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RankingsResponse class. + /// + public RankingsResponse(System.DateTime? dateTimeBegin = default(System.DateTime?), System.DateTime? dateTimeEnd = default(System.DateTime?), IList tables = default(IList)) + { + DateTimeBegin = dateTimeBegin; + DateTimeEnd = dateTimeEnd; + Tables = tables; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "dateTimeBegin")] + public System.DateTime? DateTimeBegin { get; set; } + + /// + /// + [JsonProperty(PropertyName = "dateTimeEnd")] + public System.DateTime? DateTimeEnd { get; set; } + + /// + /// + [JsonProperty(PropertyName = "tables")] + public IList Tables { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItem.cs new file mode 100644 index 000000000000..f86255b749f1 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItem.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class RankingsResponseTablesItem + { + /// + /// Initializes a new instance of the RankingsResponseTablesItem class. + /// + public RankingsResponseTablesItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RankingsResponseTablesItem class. + /// + public RankingsResponseTablesItem(string ranking = default(string), IList data = default(IList)) + { + Ranking = ranking; + Data = data; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "ranking")] + public string Ranking { get; set; } + + /// + /// + [JsonProperty(PropertyName = "data")] + public IList Data { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItem.cs new file mode 100644 index 000000000000..abfd1c140812 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItem.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class RankingsResponseTablesItemDataItem + { + /// + /// Initializes a new instance of the + /// RankingsResponseTablesItemDataItem class. + /// + public RankingsResponseTablesItemDataItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// RankingsResponseTablesItemDataItem class. + /// + public RankingsResponseTablesItemDataItem(string name = default(string), IList metrics = default(IList)) + { + Name = name; + Metrics = metrics; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "metrics")] + public IList Metrics { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItemMetricsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItemMetricsItem.cs new file mode 100644 index 000000000000..6552a4eb02e1 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RankingsResponseTablesItemDataItemMetricsItem.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class RankingsResponseTablesItemDataItemMetricsItem + { + /// + /// Initializes a new instance of the + /// RankingsResponseTablesItemDataItemMetricsItem class. + /// + public RankingsResponseTablesItemDataItemMetricsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// RankingsResponseTablesItemDataItemMetricsItem class. + /// + public RankingsResponseTablesItemDataItemMetricsItem(string metric = default(string), long? value = default(long?), double? percentage = default(double?)) + { + Metric = metric; + Value = value; + Percentage = percentage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "metric")] + public string Metric { get; set; } + + /// + /// + [JsonProperty(PropertyName = "value")] + public long? Value { get; set; } + + /// + /// + [JsonProperty(PropertyName = "percentage")] + public double? Percentage { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RemoteAddressMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RemoteAddressMatchConditionParameters.cs index 53be556825a9..844f102fa3c5 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RemoteAddressMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RemoteAddressMatchConditionParameters.cs @@ -36,14 +36,14 @@ public RemoteAddressMatchConditionParameters() /// /// Describes operator to be matched. /// Possible values include: 'Any', 'IPMatch', 'GeoMatch' + /// Describes if this is negate condition + /// or not /// Match values to match against. The /// operator will apply to each value in here with OR semantics. If any /// of them match the variable with the given operator this match /// condition is considered a match. - /// Describes if this is negate condition - /// or not /// List of transforms - public RemoteAddressMatchConditionParameters(string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public RemoteAddressMatchConditionParameters(string operatorProperty, bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { OperatorProperty = operatorProperty; NegateCondition = negateCondition; @@ -109,10 +109,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyMatchConditionParameters.cs index aaf5eaa0b373..87829dfdc604 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyMatchConditionParameters.cs @@ -37,13 +37,13 @@ public RequestBodyMatchConditionParameters() /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public RequestBodyMatchConditionParameters(string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public RequestBodyMatchConditionParameters(string operatorProperty, bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { OperatorProperty = operatorProperty; NegateCondition = negateCondition; @@ -67,7 +67,8 @@ static RequestBodyMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -107,10 +108,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyOperator.cs index 767b73f8d012..3cb3d8a6bc80 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestBodyOperator.cs @@ -25,5 +25,6 @@ public static class RequestBodyOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderMatchConditionParameters.cs index ce07cbc18f6f..ec944c36ef4b 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderMatchConditionParameters.cs @@ -34,17 +34,17 @@ public RequestHeaderMatchConditionParameters() /// Initializes a new instance of the /// RequestHeaderMatchConditionParameters class. /// - /// Name of Header to be matched /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' + /// Name of Header to be matched /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public RequestHeaderMatchConditionParameters(string selector, string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public RequestHeaderMatchConditionParameters(string operatorProperty, string selector = default(string), bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { Selector = selector; OperatorProperty = operatorProperty; @@ -75,7 +75,8 @@ static RequestHeaderMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -111,18 +112,10 @@ static RequestHeaderMatchConditionParameters() /// public virtual void Validate() { - if (Selector == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Selector"); - } if (OperatorProperty == null) { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderOperator.cs index 08b6631dd8e8..6045d49e38b5 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestHeaderOperator.cs @@ -25,5 +25,6 @@ public static class RequestHeaderOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestMethodMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestMethodMatchConditionParameters.cs index 16e60f7e2d57..addbf91c880e 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestMethodMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestMethodMatchConditionParameters.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Cdn.Models { - using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -34,11 +33,11 @@ public RequestMethodMatchConditionParameters() /// Initializes a new instance of the /// RequestMethodMatchConditionParameters class. /// - /// The match value for the condition of the - /// delivery rule /// Describes if this is negate condition /// or not - public RequestMethodMatchConditionParameters(IList matchValues, bool? negateCondition = default(bool?)) + /// The match value for the condition of the + /// delivery rule + public RequestMethodMatchConditionParameters(bool? negateCondition = default(bool?), IList matchValues = default(IList)) { NegateCondition = negateCondition; MatchValues = matchValues; @@ -81,18 +80,5 @@ static RequestMethodMatchConditionParameters() [JsonProperty(PropertyName = "operator")] public static string OperatorProperty { get; private set; } - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } - } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestSchemeMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestSchemeMatchConditionParameters.cs index be8d92fb7160..9cbfd8645d78 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestSchemeMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestSchemeMatchConditionParameters.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Cdn.Models { - using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -34,11 +33,11 @@ public RequestSchemeMatchConditionParameters() /// Initializes a new instance of the /// RequestSchemeMatchConditionParameters class. /// - /// The match value for the condition of the - /// delivery rule /// Describes if this is negate condition /// or not - public RequestSchemeMatchConditionParameters(IList matchValues, bool? negateCondition = default(bool?)) + /// The match value for the condition of the + /// delivery rule + public RequestSchemeMatchConditionParameters(bool? negateCondition = default(bool?), IList matchValues = default(IList)) { NegateCondition = negateCondition; MatchValues = matchValues; @@ -81,18 +80,5 @@ static RequestSchemeMatchConditionParameters() [JsonProperty(PropertyName = "operator")] public static string OperatorProperty { get; private set; } - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } - } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriMatchConditionParameters.cs index d23be012b114..7e674179daf0 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriMatchConditionParameters.cs @@ -37,13 +37,13 @@ public RequestUriMatchConditionParameters() /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public RequestUriMatchConditionParameters(string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public RequestUriMatchConditionParameters(string operatorProperty, bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { OperatorProperty = operatorProperty; NegateCondition = negateCondition; @@ -67,7 +67,8 @@ static RequestUriMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -107,10 +108,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriOperator.cs index 6d782050565f..32bd0473c00e 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RequestUriOperator.cs @@ -25,5 +25,6 @@ public static class RequestUriOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponse.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponse.cs new file mode 100644 index 000000000000..251c0fe804f3 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponse.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Resources Response + /// + public partial class ResourcesResponse + { + /// + /// Initializes a new instance of the ResourcesResponse class. + /// + public ResourcesResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcesResponse class. + /// + public ResourcesResponse(IList endpoints = default(IList), IList customDomains = default(IList)) + { + Endpoints = endpoints; + CustomDomains = customDomains; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "endpoints")] + public IList Endpoints { get; set; } + + /// + /// + [JsonProperty(PropertyName = "customDomains")] + public IList CustomDomains { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseCustomDomainsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseCustomDomainsItem.cs new file mode 100644 index 000000000000..81f23a4ffa7a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseCustomDomainsItem.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ResourcesResponseCustomDomainsItem + { + /// + /// Initializes a new instance of the + /// ResourcesResponseCustomDomainsItem class. + /// + public ResourcesResponseCustomDomainsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourcesResponseCustomDomainsItem class. + /// + public ResourcesResponseCustomDomainsItem(string id = default(string), string name = default(string), string endpointId = default(string), bool? history = default(bool?)) + { + Id = id; + Name = name; + EndpointId = endpointId; + History = history; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "endpointId")] + public string EndpointId { get; set; } + + /// + /// + [JsonProperty(PropertyName = "history")] + public bool? History { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItem.cs new file mode 100644 index 000000000000..0be3918ea3ba --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItem.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class ResourcesResponseEndpointsItem + { + /// + /// Initializes a new instance of the ResourcesResponseEndpointsItem + /// class. + /// + public ResourcesResponseEndpointsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcesResponseEndpointsItem + /// class. + /// + public ResourcesResponseEndpointsItem(string id = default(string), string name = default(string), bool? history = default(bool?), IList customDomains = default(IList)) + { + Id = id; + Name = name; + History = history; + CustomDomains = customDomains; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "history")] + public bool? History { get; set; } + + /// + /// + [JsonProperty(PropertyName = "customDomains")] + public IList CustomDomains { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItemCustomDomainsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItemCustomDomainsItem.cs new file mode 100644 index 000000000000..23637fdfb14a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ResourcesResponseEndpointsItemCustomDomainsItem.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ResourcesResponseEndpointsItemCustomDomainsItem + { + /// + /// Initializes a new instance of the + /// ResourcesResponseEndpointsItemCustomDomainsItem class. + /// + public ResourcesResponseEndpointsItemCustomDomainsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ResourcesResponseEndpointsItemCustomDomainsItem class. + /// + public ResourcesResponseEndpointsItemCustomDomainsItem(string id = default(string), string name = default(string), string endpointId = default(string), bool? history = default(bool?)) + { + Id = id; + Name = name; + EndpointId = endpointId; + History = history; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "endpointId")] + public string EndpointId { get; set; } + + /// + /// + [JsonProperty(PropertyName = "history")] + public bool? History { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Route.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Route.cs new file mode 100644 index 000000000000..2db788576e5e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Route.cs @@ -0,0 +1,236 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Friendly Routes name mapping to the any Routes or secret related + /// information. + /// + [Rest.Serialization.JsonTransformation] + public partial class Route : ProxyResource + { + /// + /// Initializes a new instance of the Route class. + /// + public Route() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Route class. + /// + /// A reference to the origin group. + /// Resource ID. + /// Resource name. + /// Resource type. + /// Domains referenced by this + /// endpoint. + /// A directory path on the origin that + /// AzureFrontDoor can use to retrieve content from, e.g. + /// contoso.cloudapp.net/originpath. + /// rule sets referenced by this + /// endpoint. + /// List of supported protocols for + /// this route. + /// The route patterns of the + /// rule. + /// compression settings. + /// Defines how AzureFrontDoor + /// caches requests that include query strings. You can ignore any + /// query strings when caching, bypass caching to prevent requests that + /// contain query strings from being cached, or cache every request + /// with a unique URL. Possible values include: 'IgnoreQueryString', + /// 'BypassCaching', 'UseQueryString', 'NotSet' + /// Specifies what scenario the customer + /// wants this AzureFrontDoor endpoint to optimize for, e.g. Download, + /// Media services. With this information, AzureFrontDoor can apply + /// scenario driven optimization. Possible values include: + /// 'GeneralWebDelivery', 'GeneralMediaStreaming', + /// 'VideoOnDemandMediaStreaming', 'LargeFileDownload', + /// 'DynamicSiteAcceleration' + /// Protocol this rule will use when + /// forwarding traffic to backends. Possible values include: + /// 'HttpOnly', 'HttpsOnly', 'MatchRequest' + /// whether this route will be linked + /// to the default endpoint domain. Possible values include: 'Enabled', + /// 'Disabled' + /// Whether to automatically redirect HTTP + /// traffic to HTTPS traffic. Note that this is a easy way to set up + /// this rule and it will be the first rule that gets executed. + /// Possible values include: 'Enabled', 'Disabled' + /// Whether to enable use of this rule. + /// Permitted values are 'Enabled' or 'Disabled'. Possible values + /// include: 'Enabled', 'Disabled' + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + public Route(ResourceReference originGroup, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), IList customDomains = default(IList), string originPath = default(string), IList ruleSets = default(IList), IList supportedProtocols = default(IList), IList patternsToMatch = default(IList), object compressionSettings = default(object), QueryStringCachingBehavior? queryStringCachingBehavior = default(QueryStringCachingBehavior?), string optimizationType = default(string), string forwardingProtocol = default(string), string linkToDefaultDomain = default(string), string httpsRedirect = default(string), string enabledState = default(string), string provisioningState = default(string), string deploymentStatus = default(string)) + : base(id, name, type, systemData) + { + CustomDomains = customDomains; + OriginGroup = originGroup; + OriginPath = originPath; + RuleSets = ruleSets; + SupportedProtocols = supportedProtocols; + PatternsToMatch = patternsToMatch; + CompressionSettings = compressionSettings; + QueryStringCachingBehavior = queryStringCachingBehavior; + OptimizationType = optimizationType; + ForwardingProtocol = forwardingProtocol; + LinkToDefaultDomain = linkToDefaultDomain; + HttpsRedirect = httpsRedirect; + EnabledState = enabledState; + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets domains referenced by this endpoint. + /// + [JsonProperty(PropertyName = "properties.customDomains")] + public IList CustomDomains { get; set; } + + /// + /// Gets or sets a reference to the origin group. + /// + [JsonProperty(PropertyName = "properties.originGroup")] + public ResourceReference OriginGroup { get; set; } + + /// + /// Gets or sets a directory path on the origin that AzureFrontDoor can + /// use to retrieve content from, e.g. contoso.cloudapp.net/originpath. + /// + [JsonProperty(PropertyName = "properties.originPath")] + public string OriginPath { get; set; } + + /// + /// Gets or sets rule sets referenced by this endpoint. + /// + [JsonProperty(PropertyName = "properties.ruleSets")] + public IList RuleSets { get; set; } + + /// + /// Gets or sets list of supported protocols for this route. + /// + [JsonProperty(PropertyName = "properties.supportedProtocols")] + public IList SupportedProtocols { get; set; } + + /// + /// Gets or sets the route patterns of the rule. + /// + [JsonProperty(PropertyName = "properties.patternsToMatch")] + public IList PatternsToMatch { get; set; } + + /// + /// Gets or sets compression settings. + /// + [JsonProperty(PropertyName = "properties.compressionSettings")] + public object CompressionSettings { get; set; } + + /// + /// Gets or sets defines how AzureFrontDoor caches requests that + /// include query strings. You can ignore any query strings when + /// caching, bypass caching to prevent requests that contain query + /// strings from being cached, or cache every request with a unique + /// URL. Possible values include: 'IgnoreQueryString', 'BypassCaching', + /// 'UseQueryString', 'NotSet' + /// + [JsonProperty(PropertyName = "properties.queryStringCachingBehavior")] + public QueryStringCachingBehavior? QueryStringCachingBehavior { get; set; } + + /// + /// Gets or sets specifies what scenario the customer wants this + /// AzureFrontDoor endpoint to optimize for, e.g. Download, Media + /// services. With this information, AzureFrontDoor can apply scenario + /// driven optimization. Possible values include: 'GeneralWebDelivery', + /// 'GeneralMediaStreaming', 'VideoOnDemandMediaStreaming', + /// 'LargeFileDownload', 'DynamicSiteAcceleration' + /// + [JsonProperty(PropertyName = "properties.optimizationType")] + public string OptimizationType { get; set; } + + /// + /// Gets or sets protocol this rule will use when forwarding traffic to + /// backends. Possible values include: 'HttpOnly', 'HttpsOnly', + /// 'MatchRequest' + /// + [JsonProperty(PropertyName = "properties.forwardingProtocol")] + public string ForwardingProtocol { get; set; } + + /// + /// Gets or sets whether this route will be linked to the default + /// endpoint domain. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.linkToDefaultDomain")] + public string LinkToDefaultDomain { get; set; } + + /// + /// Gets or sets whether to automatically redirect HTTP traffic to + /// HTTPS traffic. Note that this is a easy way to set up this rule and + /// it will be the first rule that gets executed. Possible values + /// include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.httpsRedirect")] + public string HttpsRedirect { get; set; } + + /// + /// Gets or sets whether to enable use of this rule. Permitted values + /// are 'Enabled' or 'Disabled'. Possible values include: 'Enabled', + /// 'Disabled' + /// + [JsonProperty(PropertyName = "properties.enabledState")] + public string EnabledState { get; set; } + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (OriginGroup == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OriginGroup"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RouteUpdateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RouteUpdateParameters.cs new file mode 100644 index 000000000000..8767ac8fc0eb --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RouteUpdateParameters.cs @@ -0,0 +1,197 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The domain JSON object required for domain creation or update. + /// + [Rest.Serialization.JsonTransformation] + public partial class RouteUpdateParameters + { + /// + /// Initializes a new instance of the RouteUpdateParameters class. + /// + public RouteUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RouteUpdateParameters class. + /// + /// Domains referenced by this + /// endpoint. + /// A reference to the origin group. + /// A directory path on the origin that + /// AzureFrontDoor can use to retrieve content from, e.g. + /// contoso.cloudapp.net/originpath. + /// rule sets referenced by this + /// endpoint. + /// List of supported protocols for + /// this route. + /// The route patterns of the + /// rule. + /// compression settings. + /// Defines how AzureFrontDoor + /// caches requests that include query strings. You can ignore any + /// query strings when caching, bypass caching to prevent requests that + /// contain query strings from being cached, or cache every request + /// with a unique URL. Possible values include: 'IgnoreQueryString', + /// 'BypassCaching', 'UseQueryString', 'NotSet' + /// Specifies what scenario the customer + /// wants this AzureFrontDoor endpoint to optimize for, e.g. Download, + /// Media services. With this information, AzureFrontDoor can apply + /// scenario driven optimization. Possible values include: + /// 'GeneralWebDelivery', 'GeneralMediaStreaming', + /// 'VideoOnDemandMediaStreaming', 'LargeFileDownload', + /// 'DynamicSiteAcceleration' + /// Protocol this rule will use when + /// forwarding traffic to backends. Possible values include: + /// 'HttpOnly', 'HttpsOnly', 'MatchRequest' + /// whether this route will be linked + /// to the default endpoint domain. Possible values include: 'Enabled', + /// 'Disabled' + /// Whether to automatically redirect HTTP + /// traffic to HTTPS traffic. Note that this is a easy way to set up + /// this rule and it will be the first rule that gets executed. + /// Possible values include: 'Enabled', 'Disabled' + /// Whether to enable use of this rule. + /// Permitted values are 'Enabled' or 'Disabled'. Possible values + /// include: 'Enabled', 'Disabled' + public RouteUpdateParameters(IList customDomains = default(IList), ResourceReference originGroup = default(ResourceReference), string originPath = default(string), IList ruleSets = default(IList), IList supportedProtocols = default(IList), IList patternsToMatch = default(IList), object compressionSettings = default(object), QueryStringCachingBehavior? queryStringCachingBehavior = default(QueryStringCachingBehavior?), string optimizationType = default(string), string forwardingProtocol = default(string), string linkToDefaultDomain = default(string), string httpsRedirect = default(string), string enabledState = default(string)) + { + CustomDomains = customDomains; + OriginGroup = originGroup; + OriginPath = originPath; + RuleSets = ruleSets; + SupportedProtocols = supportedProtocols; + PatternsToMatch = patternsToMatch; + CompressionSettings = compressionSettings; + QueryStringCachingBehavior = queryStringCachingBehavior; + OptimizationType = optimizationType; + ForwardingProtocol = forwardingProtocol; + LinkToDefaultDomain = linkToDefaultDomain; + HttpsRedirect = httpsRedirect; + EnabledState = enabledState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets domains referenced by this endpoint. + /// + [JsonProperty(PropertyName = "properties.customDomains")] + public IList CustomDomains { get; set; } + + /// + /// Gets or sets a reference to the origin group. + /// + [JsonProperty(PropertyName = "properties.originGroup")] + public ResourceReference OriginGroup { get; set; } + + /// + /// Gets or sets a directory path on the origin that AzureFrontDoor can + /// use to retrieve content from, e.g. contoso.cloudapp.net/originpath. + /// + [JsonProperty(PropertyName = "properties.originPath")] + public string OriginPath { get; set; } + + /// + /// Gets or sets rule sets referenced by this endpoint. + /// + [JsonProperty(PropertyName = "properties.ruleSets")] + public IList RuleSets { get; set; } + + /// + /// Gets or sets list of supported protocols for this route. + /// + [JsonProperty(PropertyName = "properties.supportedProtocols")] + public IList SupportedProtocols { get; set; } + + /// + /// Gets or sets the route patterns of the rule. + /// + [JsonProperty(PropertyName = "properties.patternsToMatch")] + public IList PatternsToMatch { get; set; } + + /// + /// Gets or sets compression settings. + /// + [JsonProperty(PropertyName = "properties.compressionSettings")] + public object CompressionSettings { get; set; } + + /// + /// Gets or sets defines how AzureFrontDoor caches requests that + /// include query strings. You can ignore any query strings when + /// caching, bypass caching to prevent requests that contain query + /// strings from being cached, or cache every request with a unique + /// URL. Possible values include: 'IgnoreQueryString', 'BypassCaching', + /// 'UseQueryString', 'NotSet' + /// + [JsonProperty(PropertyName = "properties.queryStringCachingBehavior")] + public QueryStringCachingBehavior? QueryStringCachingBehavior { get; set; } + + /// + /// Gets or sets specifies what scenario the customer wants this + /// AzureFrontDoor endpoint to optimize for, e.g. Download, Media + /// services. With this information, AzureFrontDoor can apply scenario + /// driven optimization. Possible values include: 'GeneralWebDelivery', + /// 'GeneralMediaStreaming', 'VideoOnDemandMediaStreaming', + /// 'LargeFileDownload', 'DynamicSiteAcceleration' + /// + [JsonProperty(PropertyName = "properties.optimizationType")] + public string OptimizationType { get; set; } + + /// + /// Gets or sets protocol this rule will use when forwarding traffic to + /// backends. Possible values include: 'HttpOnly', 'HttpsOnly', + /// 'MatchRequest' + /// + [JsonProperty(PropertyName = "properties.forwardingProtocol")] + public string ForwardingProtocol { get; set; } + + /// + /// Gets or sets whether this route will be linked to the default + /// endpoint domain. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.linkToDefaultDomain")] + public string LinkToDefaultDomain { get; set; } + + /// + /// Gets or sets whether to automatically redirect HTTP traffic to + /// HTTPS traffic. Note that this is a easy way to set up this rule and + /// it will be the first rule that gets executed. Possible values + /// include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.httpsRedirect")] + public string HttpsRedirect { get; set; } + + /// + /// Gets or sets whether to enable use of this rule. Permitted values + /// are 'Enabled' or 'Disabled'. Possible values include: 'Enabled', + /// 'Disabled' + /// + [JsonProperty(PropertyName = "properties.enabledState")] + public string EnabledState { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Rule.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Rule.cs new file mode 100644 index 000000000000..97866c92ab94 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Rule.cs @@ -0,0 +1,136 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Friendly Rules name mapping to the any Rules or secret related + /// information. + /// + [Rest.Serialization.JsonTransformation] + public partial class Rule : ProxyResource + { + /// + /// Initializes a new instance of the Rule class. + /// + public Rule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Rule class. + /// + /// The order in which the rules are applied for + /// the endpoint. Possible values {0,1,2,3,………}. A rule with a lesser + /// order will be applied before a rule with a greater order. Rule with + /// order 0 is a special rule. It does not require any condition and + /// actions listed in it will always be applied. + /// A list of actions that are executed when all + /// the conditions of a rule are satisfied. + /// Resource ID. + /// Resource name. + /// Resource type. + /// A list of conditions that must be matched + /// for the actions to be executed + /// If this rule is a match + /// should the rules engine continue running the remaining rules or + /// stop. If not present, defaults to Continue. Possible values + /// include: 'Continue', 'Stop' + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + public Rule(int order, IList actions, string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), IList conditions = default(IList), string matchProcessingBehavior = default(string), string provisioningState = default(string), string deploymentStatus = default(string)) + : base(id, name, type, systemData) + { + Order = order; + Conditions = conditions; + Actions = actions; + MatchProcessingBehavior = matchProcessingBehavior; + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the order in which the rules are applied for the + /// endpoint. Possible values {0,1,2,3,………}. A rule with a lesser order + /// will be applied before a rule with a greater order. Rule with order + /// 0 is a special rule. It does not require any condition and actions + /// listed in it will always be applied. + /// + [JsonProperty(PropertyName = "properties.order")] + public int Order { get; set; } + + /// + /// Gets or sets a list of conditions that must be matched for the + /// actions to be executed + /// + [JsonProperty(PropertyName = "properties.conditions")] + public IList Conditions { get; set; } + + /// + /// Gets or sets a list of actions that are executed when all the + /// conditions of a rule are satisfied. + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Gets or sets if this rule is a match should the rules engine + /// continue running the remaining rules or stop. If not present, + /// defaults to Continue. Possible values include: 'Continue', 'Stop' + /// + [JsonProperty(PropertyName = "properties.matchProcessingBehavior")] + public string MatchProcessingBehavior { get; set; } + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Actions == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Actions"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleSet.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleSet.cs new file mode 100644 index 000000000000..a422868252c7 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleSet.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Friendly RuleSet name mapping to the any RuleSet or secret related + /// information. + /// + [Rest.Serialization.JsonTransformation] + public partial class RuleSet : ProxyResource + { + /// + /// Initializes a new instance of the RuleSet class. + /// + public RuleSet() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleSet class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + public RuleSet(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string provisioningState = default(string), string deploymentStatus = default(string)) + : base(id, name, type, systemData) + { + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleUpdateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleUpdateParameters.cs new file mode 100644 index 000000000000..1ff36f5c04cd --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RuleUpdateParameters.cs @@ -0,0 +1,97 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The domain JSON object required for domain creation or update. + /// + [Rest.Serialization.JsonTransformation] + public partial class RuleUpdateParameters + { + /// + /// Initializes a new instance of the RuleUpdateParameters class. + /// + public RuleUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleUpdateParameters class. + /// + /// The order in which the rules are applied for + /// the endpoint. Possible values {0,1,2,3,………}. A rule with a lesser + /// order will be applied before a rule with a greater order. Rule with + /// order 0 is a special rule. It does not require any condition and + /// actions listed in it will always be applied. + /// A list of conditions that must be matched + /// for the actions to be executed + /// A list of actions that are executed when all + /// the conditions of a rule are satisfied. + /// If this rule is a match + /// should the rules engine continue running the remaining rules or + /// stop. If not present, defaults to Continue. Possible values + /// include: 'Continue', 'Stop' + public RuleUpdateParameters(int? order = default(int?), IList conditions = default(IList), IList actions = default(IList), string matchProcessingBehavior = default(string)) + { + Order = order; + Conditions = conditions; + Actions = actions; + MatchProcessingBehavior = matchProcessingBehavior; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the order in which the rules are applied for the + /// endpoint. Possible values {0,1,2,3,………}. A rule with a lesser order + /// will be applied before a rule with a greater order. Rule with order + /// 0 is a special rule. It does not require any condition and actions + /// listed in it will always be applied. + /// + [JsonProperty(PropertyName = "properties.order")] + public int? Order { get; set; } + + /// + /// Gets or sets a list of conditions that must be matched for the + /// actions to be executed + /// + [JsonProperty(PropertyName = "properties.conditions")] + public IList Conditions { get; set; } + + /// + /// Gets or sets a list of actions that are executed when all the + /// conditions of a rule are satisfied. + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Gets or sets if this rule is a match should the rules engine + /// continue running the remaining rules or stop. If not present, + /// defaults to Continue. Possible values include: 'Continue', 'Stop' + /// + [JsonProperty(PropertyName = "properties.matchProcessingBehavior")] + public string MatchProcessingBehavior { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Secret.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Secret.cs new file mode 100644 index 000000000000..1916219d80ec --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Secret.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Friendly Secret name mapping to the any Secret or secret related + /// information. + /// + [Rest.Serialization.JsonTransformation] + public partial class Secret : ProxyResource + { + /// + /// Initializes a new instance of the Secret class. + /// + public Secret() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Secret class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + /// object which contains secret + /// parameters + public Secret(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string provisioningState = default(string), string deploymentStatus = default(string), SecretParameters parameters = default(SecretParameters)) + : base(id, name, type, systemData) + { + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + Parameters = parameters; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Gets or sets object which contains secret parameters + /// + [JsonProperty(PropertyName = "properties.parameters")] + public SecretParameters Parameters { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretParameters.cs new file mode 100644 index 000000000000..731174a3d513 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretParameters.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using System.Linq; + + /// + /// The json object containing secret parameters + /// + public partial class SecretParameters + { + /// + /// Initializes a new instance of the SecretParameters class. + /// + public SecretParameters() + { + CustomInit(); + } + + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretProperties.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretProperties.cs new file mode 100644 index 000000000000..40e2d96c9fa4 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretProperties.cs @@ -0,0 +1,58 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The JSON object that contains the properties of the Secret to create. + /// + public partial class SecretProperties : AFDStateProperties + { + /// + /// Initializes a new instance of the SecretProperties class. + /// + public SecretProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecretProperties class. + /// + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + /// object which contains secret + /// parameters + public SecretProperties(string provisioningState = default(string), string deploymentStatus = default(string), SecretParameters parameters = default(SecretParameters)) + : base(provisioningState, deploymentStatus) + { + Parameters = parameters; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets object which contains secret parameters + /// + [JsonProperty(PropertyName = "parameters")] + public SecretParameters Parameters { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretType.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretType.cs new file mode 100644 index 000000000000..5890f70a5d55 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecretType.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for SecretType. + /// + public static class SecretType + { + public const string UrlSigningKey = "UrlSigningKey"; + public const string CustomerCertificate = "CustomerCertificate"; + public const string ManagedCertificate = "ManagedCertificate"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicy.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicy.cs new file mode 100644 index 000000000000..4b923a61262c --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicy.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// SecurityPolicy association for AzureFrontDoor profile + /// + [Rest.Serialization.JsonTransformation] + public partial class SecurityPolicy : ProxyResource + { + /// + /// Initializes a new instance of the SecurityPolicy class. + /// + public SecurityPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecurityPolicy class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// Provisioning status. Possible + /// values include: 'Succeeded', 'Failed', 'Updating', 'Deleting', + /// 'Creating' + /// Possible values include: + /// 'NotStarted', 'InProgress', 'Succeeded', 'Failed' + /// object which contains security policy + /// parameters + public SecurityPolicy(string id = default(string), string name = default(string), string type = default(string), SystemData systemData = default(SystemData), string provisioningState = default(string), string deploymentStatus = default(string), SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters)) + : base(id, name, type, systemData) + { + ProvisioningState = provisioningState; + DeploymentStatus = deploymentStatus; + Parameters = parameters; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning status. Possible values include: 'Succeeded', + /// 'Failed', 'Updating', 'Deleting', 'Creating' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets possible values include: 'NotStarted', 'InProgress', + /// 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.deploymentStatus")] + public string DeploymentStatus { get; private set; } + + /// + /// Gets or sets object which contains security policy parameters + /// + [JsonProperty(PropertyName = "properties.parameters")] + public SecurityPolicyWebApplicationFirewallParameters Parameters { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyParameters.cs new file mode 100644 index 000000000000..8bbb42a95ac4 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyParameters.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using System.Linq; + + /// + /// The json object containing security policy parameters + /// + public partial class SecurityPolicyParameters + { + /// + /// Initializes a new instance of the SecurityPolicyParameters class. + /// + public SecurityPolicyParameters() + { + CustomInit(); + } + + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallAssociation.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallAssociation.cs new file mode 100644 index 000000000000..2b21de9a2dc0 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallAssociation.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// settings for security policy patterns to match + /// + public partial class SecurityPolicyWebApplicationFirewallAssociation + { + /// + /// Initializes a new instance of the + /// SecurityPolicyWebApplicationFirewallAssociation class. + /// + public SecurityPolicyWebApplicationFirewallAssociation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SecurityPolicyWebApplicationFirewallAssociation class. + /// + /// List of domains. + /// List of paths + public SecurityPolicyWebApplicationFirewallAssociation(IList domains = default(IList), IList patternsToMatch = default(IList)) + { + Domains = domains; + PatternsToMatch = patternsToMatch; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of domains. + /// + [JsonProperty(PropertyName = "domains")] + public IList Domains { get; set; } + + /// + /// Gets or sets list of paths + /// + [JsonProperty(PropertyName = "patternsToMatch")] + public IList PatternsToMatch { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallParameters.cs new file mode 100644 index 000000000000..eaf7844c35b0 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SecurityPolicyWebApplicationFirewallParameters.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The json object containing security policy waf parameters + /// + [Newtonsoft.Json.JsonObject("WebApplicationFirewall")] + public partial class SecurityPolicyWebApplicationFirewallParameters : SecurityPolicyParameters + { + /// + /// Initializes a new instance of the + /// SecurityPolicyWebApplicationFirewallParameters class. + /// + public SecurityPolicyWebApplicationFirewallParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SecurityPolicyWebApplicationFirewallParameters class. + /// + /// Resource ID. + /// Waf associations + public SecurityPolicyWebApplicationFirewallParameters(ResourceReference wafPolicy = default(ResourceReference), IList associations = default(IList)) + { + WafPolicy = wafPolicy; + Associations = associations; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource ID. + /// + [JsonProperty(PropertyName = "wafPolicy")] + public ResourceReference WafPolicy { get; set; } + + /// + /// Gets or sets waf associations + /// + [JsonProperty(PropertyName = "associations")] + public IList Associations { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceProperties.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceProperties.cs new file mode 100644 index 000000000000..c8c7d1dc5390 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceProperties.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes the properties of an existing Shared Private Link Resource to + /// use when connecting to a private origin. + /// + public partial class SharedPrivateLinkResourceProperties + { + /// + /// Initializes a new instance of the + /// SharedPrivateLinkResourceProperties class. + /// + public SharedPrivateLinkResourceProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SharedPrivateLinkResourceProperties class. + /// + /// The resource id of the resource the + /// shared private link resource is for. + /// The location of the shared + /// private link resource + /// The group id from the provider of resource + /// the shared private link resource is for. + /// The request message for requesting + /// approval of the shared private link resource. + /// Status of the shared private link resource. + /// Can be Pending, Approved, Rejected, Disconnected, or Timeout. + /// Possible values include: 'Pending', 'Approved', 'Rejected', + /// 'Disconnected', 'Timeout' + public SharedPrivateLinkResourceProperties(ResourceReference privateLink = default(ResourceReference), string privateLinkLocation = default(string), string groupId = default(string), string requestMessage = default(string), SharedPrivateLinkResourceStatus? status = default(SharedPrivateLinkResourceStatus?)) + { + PrivateLink = privateLink; + PrivateLinkLocation = privateLinkLocation; + GroupId = groupId; + RequestMessage = requestMessage; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource id of the resource the shared private + /// link resource is for. + /// + [JsonProperty(PropertyName = "privateLink")] + public ResourceReference PrivateLink { get; set; } + + /// + /// Gets or sets the location of the shared private link resource + /// + [JsonProperty(PropertyName = "privateLinkLocation")] + public string PrivateLinkLocation { get; set; } + + /// + /// Gets or sets the group id from the provider of resource the shared + /// private link resource is for. + /// + [JsonProperty(PropertyName = "groupId")] + public string GroupId { get; set; } + + /// + /// Gets or sets the request message for requesting approval of the + /// shared private link resource. + /// + [JsonProperty(PropertyName = "requestMessage")] + public string RequestMessage { get; set; } + + /// + /// Gets or sets status of the shared private link resource. Can be + /// Pending, Approved, Rejected, Disconnected, or Timeout. Possible + /// values include: 'Pending', 'Approved', 'Rejected', 'Disconnected', + /// 'Timeout' + /// + [JsonProperty(PropertyName = "status")] + public SharedPrivateLinkResourceStatus? Status { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceStatus.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceStatus.cs new file mode 100644 index 000000000000..c5fd0b6d2560 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SharedPrivateLinkResourceStatus.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for SharedPrivateLinkResourceStatus. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SharedPrivateLinkResourceStatus + { + [EnumMember(Value = "Pending")] + Pending, + [EnumMember(Value = "Approved")] + Approved, + [EnumMember(Value = "Rejected")] + Rejected, + [EnumMember(Value = "Disconnected")] + Disconnected, + [EnumMember(Value = "Timeout")] + Timeout + } + internal static class SharedPrivateLinkResourceStatusEnumExtension + { + internal static string ToSerializedValue(this SharedPrivateLinkResourceStatus? value) + { + return value == null ? null : ((SharedPrivateLinkResourceStatus)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this SharedPrivateLinkResourceStatus value) + { + switch( value ) + { + case SharedPrivateLinkResourceStatus.Pending: + return "Pending"; + case SharedPrivateLinkResourceStatus.Approved: + return "Approved"; + case SharedPrivateLinkResourceStatus.Rejected: + return "Rejected"; + case SharedPrivateLinkResourceStatus.Disconnected: + return "Disconnected"; + case SharedPrivateLinkResourceStatus.Timeout: + return "Timeout"; + } + return null; + } + + internal static SharedPrivateLinkResourceStatus? ParseSharedPrivateLinkResourceStatus(this string value) + { + switch( value ) + { + case "Pending": + return SharedPrivateLinkResourceStatus.Pending; + case "Approved": + return SharedPrivateLinkResourceStatus.Approved; + case "Rejected": + return SharedPrivateLinkResourceStatus.Rejected; + case "Disconnected": + return SharedPrivateLinkResourceStatus.Disconnected; + case "Timeout": + return SharedPrivateLinkResourceStatus.Timeout; + } + return null; + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Sku.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Sku.cs index 8aadf3029ce4..ccd0a432db93 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Sku.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Sku.cs @@ -33,7 +33,11 @@ public Sku() /// Name of the pricing tier. Possible values /// include: 'Standard_Verizon', 'Premium_Verizon', 'Custom_Verizon', /// 'Standard_Akamai', 'Standard_ChinaCdn', 'Standard_Microsoft', - /// 'Premium_ChinaCdn' + /// 'Premium_ChinaCdn', 'Standard_AzureFrontDoor', + /// 'Premium_AzureFrontDoor', 'Standard_955BandWidth_ChinaCdn', + /// 'Standard_AvgBandWidth_ChinaCdn', 'StandardPlus_ChinaCdn', + /// 'StandardPlus_955BandWidth_ChinaCdn', + /// 'StandardPlus_AvgBandWidth_ChinaCdn' public Sku(string name = default(string)) { Name = name; @@ -49,7 +53,11 @@ public Sku() /// Gets or sets name of the pricing tier. Possible values include: /// 'Standard_Verizon', 'Premium_Verizon', 'Custom_Verizon', /// 'Standard_Akamai', 'Standard_ChinaCdn', 'Standard_Microsoft', - /// 'Premium_ChinaCdn' + /// 'Premium_ChinaCdn', 'Standard_AzureFrontDoor', + /// 'Premium_AzureFrontDoor', 'Standard_955BandWidth_ChinaCdn', + /// 'Standard_AvgBandWidth_ChinaCdn', 'StandardPlus_ChinaCdn', + /// 'StandardPlus_955BandWidth_ChinaCdn', + /// 'StandardPlus_AvgBandWidth_ChinaCdn' /// [JsonProperty(PropertyName = "name")] public string Name { get; set; } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SkuName.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SkuName.cs index 8e2227754cdc..f94cb2ade9b2 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SkuName.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SkuName.cs @@ -23,5 +23,12 @@ public static class SkuName public const string StandardChinaCdn = "Standard_ChinaCdn"; public const string StandardMicrosoft = "Standard_Microsoft"; public const string PremiumChinaCdn = "Premium_ChinaCdn"; + public const string StandardAzureFrontDoor = "Standard_AzureFrontDoor"; + public const string PremiumAzureFrontDoor = "Premium_AzureFrontDoor"; + public const string Standard955BandWidthChinaCdn = "Standard_955BandWidth_ChinaCdn"; + public const string StandardAvgBandWidthChinaCdn = "Standard_AvgBandWidth_ChinaCdn"; + public const string StandardPlusChinaCdn = "StandardPlus_ChinaCdn"; + public const string StandardPlus955BandWidthChinaCdn = "StandardPlus_955BandWidth_ChinaCdn"; + public const string StandardPlusAvgBandWidthChinaCdn = "StandardPlus_AvgBandWidth_ChinaCdn"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Status.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Status.cs new file mode 100644 index 000000000000..9f802c9c26ac --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Status.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for Status. + /// + public static class Status + { + public const string Valid = "Valid"; + public const string Invalid = "Invalid"; + public const string AccessDenied = "AccessDenied"; + public const string CertificateExpired = "CertificateExpired"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SystemData.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SystemData.cs new file mode 100644 index 000000000000..c581d0a0a797 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/SystemData.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Read only system data + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// An identifier for the identity that created + /// the resource + /// The type of identity that created the + /// resource. Possible values include: 'user', 'application', + /// 'managedIdentity', 'key' + /// The timestamp of resource creation + /// (UTC) + /// An identifier for the identity that + /// last modified the resource + /// The type of identity that last + /// modified the resource. Possible values include: 'user', + /// 'application', 'managedIdentity', 'key' + /// The timestamp of resource last + /// modification (UTC) + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets an identifier for the identity that created the + /// resource + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'user', 'application', 'managedIdentity', + /// 'key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC) + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets an identifier for the identity that last modified the + /// resource + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'user', 'application', 'managedIdentity', + /// 'key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource last modification (UTC) + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/TrackedResource.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/TrackedResource.cs index cbe51efdc2f0..525c617fcb9d 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/TrackedResource.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/TrackedResource.cs @@ -37,11 +37,12 @@ public TrackedResource() /// Resource name. /// Resource type. /// Resource tags. - public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), SystemData systemData = default(SystemData)) : base(id, name, type) { Location = location; Tags = tags; + SystemData = systemData; CustomInit(); } @@ -62,6 +63,11 @@ public TrackedResource() [JsonProperty(PropertyName = "tags")] public IDictionary Tags { get; set; } + /// + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + /// /// Validate the object. /// diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionMatchConditionParameters.cs index cce16a9dc84c..4eb342df95c1 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionMatchConditionParameters.cs @@ -37,13 +37,13 @@ public UrlFileExtensionMatchConditionParameters() /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public UrlFileExtensionMatchConditionParameters(string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public UrlFileExtensionMatchConditionParameters(string operatorProperty, bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { OperatorProperty = operatorProperty; NegateCondition = negateCondition; @@ -68,7 +68,8 @@ static UrlFileExtensionMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -108,10 +109,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionOperator.cs index 8e8350161370..5f946c6bfdef 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileExtensionOperator.cs @@ -25,5 +25,6 @@ public static class UrlFileExtensionOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameMatchConditionParameters.cs index c6479fb380bf..fc615f11027a 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameMatchConditionParameters.cs @@ -37,13 +37,13 @@ public UrlFileNameMatchConditionParameters() /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'RegEx' /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public UrlFileNameMatchConditionParameters(string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public UrlFileNameMatchConditionParameters(string operatorProperty, bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { OperatorProperty = operatorProperty; NegateCondition = negateCondition; @@ -67,7 +67,8 @@ static UrlFileNameMatchConditionParameters() /// /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', - /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual' + /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', + /// 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -107,10 +108,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameOperator.cs index a72a96306f94..ae7a84333aa1 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlFileNameOperator.cs @@ -25,5 +25,6 @@ public static class UrlFileNameOperator public const string LessThanOrEqual = "LessThanOrEqual"; public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathMatchConditionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathMatchConditionParameters.cs index c351e23920a9..6649caf80cef 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathMatchConditionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathMatchConditionParameters.cs @@ -37,13 +37,13 @@ public UrlPathMatchConditionParameters() /// Describes operator to be matched. /// Possible values include: 'Any', 'Equal', 'Contains', 'BeginsWith', /// 'EndsWith', 'LessThan', 'LessThanOrEqual', 'GreaterThan', - /// 'GreaterThanOrEqual', 'Wildcard' - /// The match value for the condition of the - /// delivery rule + /// 'GreaterThanOrEqual', 'Wildcard', 'RegEx' /// Describes if this is negate condition /// or not + /// The match value for the condition of the + /// delivery rule /// List of transforms - public UrlPathMatchConditionParameters(string operatorProperty, IList matchValues, bool? negateCondition = default(bool?), IList transforms = default(IList)) + public UrlPathMatchConditionParameters(string operatorProperty, bool? negateCondition = default(bool?), IList matchValues = default(IList), IList transforms = default(IList)) { OperatorProperty = operatorProperty; NegateCondition = negateCondition; @@ -68,7 +68,7 @@ static UrlPathMatchConditionParameters() /// Gets or sets describes operator to be matched. Possible values /// include: 'Any', 'Equal', 'Contains', 'BeginsWith', 'EndsWith', /// 'LessThan', 'LessThanOrEqual', 'GreaterThan', 'GreaterThanOrEqual', - /// 'Wildcard' + /// 'Wildcard', 'RegEx' /// [JsonProperty(PropertyName = "operator")] public string OperatorProperty { get; set; } @@ -108,10 +108,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); } - if (MatchValues == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues"); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathOperator.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathOperator.cs index f72935feff35..f7780364efe4 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathOperator.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlPathOperator.cs @@ -26,5 +26,6 @@ public static class UrlPathOperator public const string GreaterThan = "GreaterThan"; public const string GreaterThanOrEqual = "GreaterThanOrEqual"; public const string Wildcard = "Wildcard"; + public const string RegEx = "RegEx"; } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningAction.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningAction.cs index ef6d6ecb744f..021c429899cf 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningAction.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningAction.cs @@ -25,6 +25,7 @@ public partial class UrlSigningAction : DeliveryRuleAction /// public UrlSigningAction() { + Parameters = new UrlSigningActionParameters(); CustomInit(); } @@ -62,10 +63,6 @@ public virtual void Validate() { throw new ValidationException(ValidationRules.CannotBeNull, "Parameters"); } - if (Parameters != null) - { - Parameters.Validate(); - } } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningActionParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningActionParameters.cs index d6c227f06a30..2c32d08aaccd 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningActionParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningActionParameters.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.Cdn.Models { - using Microsoft.Rest; using Newtonsoft.Json; using System.Collections; using System.Collections.Generic; @@ -32,45 +31,29 @@ public UrlSigningActionParameters() /// /// Initializes a new instance of the UrlSigningActionParameters class. /// - /// Id reference of the key to be used to verify - /// the hash and should be defined in UrlSigningKeys - /// Possible values include: - /// '#Microsoft.Azure.Cdn.Models.DeliveryRuleUrlSigningActionParameters' /// Algorithm to use for URL signing. Possible /// values include: 'SHA256' /// Defines which query string /// parameters in the url to be considered for expires, key id etc. /// - /// Match values to match against. Supports - /// CIDR ranges (both IPv4 and IPv6). - public UrlSigningActionParameters(string keyId, string odatatype = default(string), string algorithm = default(string), IList parameterNameOverride = default(IList), IList ipSubnets = default(IList)) + public UrlSigningActionParameters(string algorithm = default(string), IList parameterNameOverride = default(IList)) { - Odatatype = odatatype; - KeyId = keyId; Algorithm = algorithm; ParameterNameOverride = parameterNameOverride; - IpSubnets = ipSubnets; CustomInit(); } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - /// - /// Gets or sets possible values include: - /// '#Microsoft.Azure.Cdn.Models.DeliveryRuleUrlSigningActionParameters' + /// Static constructor for UrlSigningActionParameters class. /// - [JsonProperty(PropertyName = "@odata.type")] - public string Odatatype { get; set; } + static UrlSigningActionParameters() + { + Odatatype = "#Microsoft.Azure.Cdn.Models.DeliveryRuleUrlSigningActionParameters"; + } /// - /// Gets or sets id reference of the key to be used to verify the hash - /// and should be defined in UrlSigningKeys + /// An initialization method that performs custom operations like setting defaults /// - [JsonProperty(PropertyName = "keyId")] - public string KeyId { get; set; } + partial void CustomInit(); /// /// Gets or sets algorithm to use for URL signing. Possible values @@ -87,34 +70,9 @@ public UrlSigningActionParameters() public IList ParameterNameOverride { get; set; } /// - /// Gets or sets match values to match against. Supports CIDR ranges - /// (both IPv4 and IPv6). /// - [JsonProperty(PropertyName = "ipSubnets")] - public IList IpSubnets { get; set; } + [JsonProperty(PropertyName = "@odata.type")] + public static string Odatatype { get; private set; } - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (KeyId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "KeyId"); - } - if (ParameterNameOverride != null) - { - foreach (var element in ParameterNameOverride) - { - if (element != null) - { - element.Validate(); - } - } - } - } } } diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningKeyParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningKeyParameters.cs new file mode 100644 index 000000000000..4f1118bd354a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UrlSigningKeyParameters.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Url signing key parameters + /// + [Newtonsoft.Json.JsonObject("UrlSigningKey")] + public partial class UrlSigningKeyParameters : SecretParameters + { + /// + /// Initializes a new instance of the UrlSigningKeyParameters class. + /// + public UrlSigningKeyParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UrlSigningKeyParameters class. + /// + /// Defines the customer defined key Id. This id + /// will exist in the incoming request to indicate the key used to form + /// the hash. + /// Resource reference to the KV + /// secret + /// Version of the secret to be + /// used + public UrlSigningKeyParameters(string keyId, ResourceReference secretSource, string secretVersion = default(string)) + { + KeyId = keyId; + SecretSource = secretSource; + SecretVersion = secretVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the customer defined key Id. This id will + /// exist in the incoming request to indicate the key used to form the + /// hash. + /// + [JsonProperty(PropertyName = "keyId")] + public string KeyId { get; set; } + + /// + /// Gets or sets resource reference to the KV secret + /// + [JsonProperty(PropertyName = "secretSource")] + public ResourceReference SecretSource { get; set; } + + /// + /// Gets or sets version of the secret to be used + /// + [JsonProperty(PropertyName = "secretVersion")] + public string SecretVersion { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (KeyId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "KeyId"); + } + if (SecretSource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SecretSource"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Usage.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Usage.cs new file mode 100644 index 000000000000..4923ed8e5777 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/Usage.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes resource usage. + /// + public partial class Usage + { + /// + /// Initializes a new instance of the Usage class. + /// + public Usage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Usage class. + /// + /// The current value of the usage. + /// The limit of usage. + /// The name of the type of usage. + /// Resource identifier. + public Usage(long currentValue, long limit, UsageName name, string id = default(string)) + { + Id = id; + CurrentValue = currentValue; + Limit = limit; + Name = name; + CustomInit(); + } + /// + /// Static constructor for Usage class. + /// + static Usage() + { + Unit = "Count"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource identifier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the current value of the usage. + /// + [JsonProperty(PropertyName = "currentValue")] + public long CurrentValue { get; set; } + + /// + /// Gets or sets the limit of usage. + /// + [JsonProperty(PropertyName = "limit")] + public long Limit { get; set; } + + /// + /// Gets or sets the name of the type of usage. + /// + [JsonProperty(PropertyName = "name")] + public UsageName Name { get; set; } + + /// + /// An enum describing the unit of measurement. + /// + [JsonProperty(PropertyName = "unit")] + public static string Unit { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UsageName.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UsageName.cs new file mode 100644 index 000000000000..16a699653367 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/UsageName.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The usage names. + /// + public partial class UsageName + { + /// + /// Initializes a new instance of the UsageName class. + /// + public UsageName() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UsageName class. + /// + /// A string describing the resource name. + /// A localized string describing the + /// resource name. + public UsageName(string value = default(string), string localizedValue = default(string)) + { + Value = value; + LocalizedValue = localizedValue; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a string describing the resource name. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets or sets a localized string describing the resource name. + /// + [JsonProperty(PropertyName = "localizedValue")] + public string LocalizedValue { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretInput.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretInput.cs new file mode 100644 index 000000000000..a799388dec15 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretInput.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Input of the secret to be validated. + /// + public partial class ValidateSecretInput + { + /// + /// Initializes a new instance of the ValidateSecretInput class. + /// + public ValidateSecretInput() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ValidateSecretInput class. + /// + /// The secret source. + /// The secret type. Possible values include: + /// 'UrlSigningKey', 'ManagedCertificate', + /// 'CustomerCertificate' + public ValidateSecretInput(ResourceReference secretSource, string secretType) + { + SecretSource = secretSource; + SecretType = secretType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the secret source. + /// + [JsonProperty(PropertyName = "secretSource")] + public ResourceReference SecretSource { get; set; } + + /// + /// Gets or sets the secret type. Possible values include: + /// 'UrlSigningKey', 'ManagedCertificate', 'CustomerCertificate' + /// + [JsonProperty(PropertyName = "secretType")] + public string SecretType { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SecretSource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SecretSource"); + } + if (SecretType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SecretType"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretOutput.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretOutput.cs new file mode 100644 index 000000000000..e1907d00bb77 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretOutput.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Output of the validated secret. + /// + public partial class ValidateSecretOutput + { + /// + /// Initializes a new instance of the ValidateSecretOutput class. + /// + public ValidateSecretOutput() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ValidateSecretOutput class. + /// + /// The validation status. Possible values + /// include: 'Valid', 'Invalid', 'AccessDenied', + /// 'CertificateExpired' + /// Detailed error message + public ValidateSecretOutput(string status = default(string), string message = default(string)) + { + Status = status; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the validation status. Possible values include: + /// 'Valid', 'Invalid', 'AccessDenied', 'CertificateExpired' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets detailed error message + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretType.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretType.cs new file mode 100644 index 000000000000..8e94247c8b75 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidateSecretType.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + + /// + /// Defines values for ValidateSecretType. + /// + public static class ValidateSecretType + { + public const string UrlSigningKey = "UrlSigningKey"; + public const string ManagedCertificate = "ManagedCertificate"; + public const string CustomerCertificate = "CustomerCertificate"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidationToken.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidationToken.cs new file mode 100644 index 000000000000..58d1187e1446 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ValidationToken.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The validation token. + /// + public partial class ValidationToken + { + /// + /// Initializes a new instance of the ValidationToken class. + /// + public ValidationToken() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ValidationToken class. + /// + public ValidationToken(string token = default(string)) + { + Token = token; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "token")] + public string Token { get; private set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponse.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponse.cs new file mode 100644 index 000000000000..a76e93e3717a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponse.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Waf Metrics Response + /// + public partial class WafMetricsResponse + { + /// + /// Initializes a new instance of the WafMetricsResponse class. + /// + public WafMetricsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WafMetricsResponse class. + /// + /// Possible values include: 'PT5M', 'PT1H', + /// 'P1D' + public WafMetricsResponse(System.DateTime? dateTimeBegin = default(System.DateTime?), System.DateTime? dateTimeEnd = default(System.DateTime?), string granularity = default(string), IList series = default(IList)) + { + DateTimeBegin = dateTimeBegin; + DateTimeEnd = dateTimeEnd; + Granularity = granularity; + Series = series; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "dateTimeBegin")] + public System.DateTime? DateTimeBegin { get; set; } + + /// + /// + [JsonProperty(PropertyName = "dateTimeEnd")] + public System.DateTime? DateTimeEnd { get; set; } + + /// + /// Gets or sets possible values include: 'PT5M', 'PT1H', 'P1D' + /// + [JsonProperty(PropertyName = "granularity")] + public string Granularity { get; set; } + + /// + /// + [JsonProperty(PropertyName = "series")] + public IList Series { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItem.cs new file mode 100644 index 000000000000..92c9918f35c0 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItem.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class WafMetricsResponseSeriesItem + { + /// + /// Initializes a new instance of the WafMetricsResponseSeriesItem + /// class. + /// + public WafMetricsResponseSeriesItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WafMetricsResponseSeriesItem + /// class. + /// + /// Possible values include: 'count' + public WafMetricsResponseSeriesItem(string metric = default(string), string unit = default(string), IList groups = default(IList), IList data = default(IList)) + { + Metric = metric; + Unit = unit; + Groups = groups; + Data = data; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "metric")] + public string Metric { get; set; } + + /// + /// Gets or sets possible values include: 'count' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// + [JsonProperty(PropertyName = "groups")] + public IList Groups { get; set; } + + /// + /// + [JsonProperty(PropertyName = "data")] + public IList Data { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemDataItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemDataItem.cs new file mode 100644 index 000000000000..84c757a78973 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemDataItem.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class WafMetricsResponseSeriesItemDataItem + { + /// + /// Initializes a new instance of the + /// WafMetricsResponseSeriesItemDataItem class. + /// + public WafMetricsResponseSeriesItemDataItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// WafMetricsResponseSeriesItemDataItem class. + /// + public WafMetricsResponseSeriesItemDataItem(System.DateTime? dateTime = default(System.DateTime?), double? value = default(double?)) + { + DateTime = dateTime; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "dateTime")] + public System.DateTime? DateTime { get; set; } + + /// + /// + [JsonProperty(PropertyName = "value")] + public double? Value { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemGroupsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemGroupsItem.cs new file mode 100644 index 000000000000..0bd880aedbc2 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafMetricsResponseSeriesItemGroupsItem.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class WafMetricsResponseSeriesItemGroupsItem + { + /// + /// Initializes a new instance of the + /// WafMetricsResponseSeriesItemGroupsItem class. + /// + public WafMetricsResponseSeriesItemGroupsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// WafMetricsResponseSeriesItemGroupsItem class. + /// + public WafMetricsResponseSeriesItemGroupsItem(string name = default(string), string value = default(string)) + { + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponse.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponse.cs new file mode 100644 index 000000000000..1193817baaa1 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponse.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Waf Rankings Response + /// + public partial class WafRankingsResponse + { + /// + /// Initializes a new instance of the WafRankingsResponse class. + /// + public WafRankingsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WafRankingsResponse class. + /// + public WafRankingsResponse(System.DateTime? dateTimeBegin = default(System.DateTime?), System.DateTime? dateTimeEnd = default(System.DateTime?), IList groups = default(IList), IList data = default(IList)) + { + DateTimeBegin = dateTimeBegin; + DateTimeEnd = dateTimeEnd; + Groups = groups; + Data = data; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "dateTimeBegin")] + public System.DateTime? DateTimeBegin { get; set; } + + /// + /// + [JsonProperty(PropertyName = "dateTimeEnd")] + public System.DateTime? DateTimeEnd { get; set; } + + /// + /// + [JsonProperty(PropertyName = "groups")] + public IList Groups { get; set; } + + /// + /// + [JsonProperty(PropertyName = "data")] + public IList Data { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItem.cs new file mode 100644 index 000000000000..be1c2e7cc867 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItem.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class WafRankingsResponseDataItem + { + /// + /// Initializes a new instance of the WafRankingsResponseDataItem + /// class. + /// + public WafRankingsResponseDataItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WafRankingsResponseDataItem + /// class. + /// + public WafRankingsResponseDataItem(IList groupValues = default(IList), IList metrics = default(IList)) + { + GroupValues = groupValues; + Metrics = metrics; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "groupValues")] + public IList GroupValues { get; set; } + + /// + /// + [JsonProperty(PropertyName = "metrics")] + public IList Metrics { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItemMetricsItem.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItemMetricsItem.cs new file mode 100644 index 000000000000..7feea3d4433d --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/WafRankingsResponseDataItemMetricsItem.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class WafRankingsResponseDataItemMetricsItem + { + /// + /// Initializes a new instance of the + /// WafRankingsResponseDataItemMetricsItem class. + /// + public WafRankingsResponseDataItemMetricsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// WafRankingsResponseDataItemMetricsItem class. + /// + public WafRankingsResponseDataItemMetricsItem(string metric = default(string), long? value = default(long?), double? percentage = default(double?)) + { + Metric = metric; + Value = value; + Percentage = percentage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "metric")] + public string Metric { get; set; } + + /// + /// + [JsonProperty(PropertyName = "value")] + public long? Value { get; set; } + + /// + /// + [JsonProperty(PropertyName = "percentage")] + public double? Percentage { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperations.cs index 9d6bd85c9d9d..1c9e6902f3b4 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperations.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperations.cs @@ -85,17 +85,17 @@ internal PoliciesOperations(CdnManagementClient client) } if (resourceGroupName != null) { - if (resourceGroupName.Length > 90) + if (resourceGroupName.Length > 80) { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 80); } if (resourceGroupName.Length < 1) { throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); } } if (Client.SubscriptionId == null) @@ -285,17 +285,17 @@ internal PoliciesOperations(CdnManagementClient client) } if (resourceGroupName != null) { - if (resourceGroupName.Length > 90) + if (resourceGroupName.Length > 80) { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 80); } if (resourceGroupName.Length < 1) { throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); } } if (policyName == null) @@ -547,17 +547,17 @@ internal PoliciesOperations(CdnManagementClient client) } if (resourceGroupName != null) { - if (resourceGroupName.Length > 90) + if (resourceGroupName.Length > 80) { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 80); } if (resourceGroupName.Length < 1) { throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); } } if (policyName == null) @@ -751,17 +751,17 @@ internal PoliciesOperations(CdnManagementClient client) } if (resourceGroupName != null) { - if (resourceGroupName.Length > 90) + if (resourceGroupName.Length > 80) { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 80); } if (resourceGroupName.Length < 1) { throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); } } if (policyName == null) @@ -1019,17 +1019,17 @@ internal PoliciesOperations(CdnManagementClient client) } if (resourceGroupName != null) { - if (resourceGroupName.Length > 90) + if (resourceGroupName.Length > 80) { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 80); } if (resourceGroupName.Length < 1) { throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); } } if (policyName == null) diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperations.cs new file mode 100644 index 000000000000..ac841edc42f2 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperations.cs @@ -0,0 +1,1477 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RoutesOperations operations. + /// + internal partial class RoutesOperations : IServiceOperations, IRoutesOperations + { + /// + /// Initializes a new instance of the RoutesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RoutesOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByEndpointWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByEndpoint", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (routeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "routeName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("routeName", routeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{routeName}", System.Uri.EscapeDataString(routeName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Route route, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, route, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, routeUpdateProperties, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Route route, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (routeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "routeName"); + } + if (route == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "route"); + } + if (route != null) + { + route.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("routeName", routeName); + tracingParameters.Add("route", route); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{routeName}", System.Uri.EscapeDataString(routeName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(route != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(route, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (routeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "routeName"); + } + if (routeUpdateProperties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "routeUpdateProperties"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("routeName", routeName); + tracingParameters.Add("routeUpdateProperties", routeUpdateProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{routeName}", System.Uri.EscapeDataString(routeName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(routeUpdateProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(routeUpdateProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string endpointName, string routeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (endpointName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "endpointName"); + } + if (routeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "routeName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("endpointName", endpointName); + tracingParameters.Add("routeName", routeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{endpointName}", System.Uri.EscapeDataString(endpointName)); + _url = _url.Replace("{routeName}", System.Uri.EscapeDataString(routeName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByEndpointNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByEndpointNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperationsExtensions.cs new file mode 100644 index 000000000000..3997b06236ae --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RoutesOperationsExtensions.cs @@ -0,0 +1,501 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for RoutesOperations. + /// + public static partial class RoutesOperationsExtensions + { + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + public static IPage ListByEndpoint(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName) + { + return operations.ListByEndpointAsync(resourceGroupName, profileName, endpointName).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByEndpointAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByEndpointWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + public static Route Get(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName) + { + return operations.GetAsync(resourceGroupName, profileName, endpointName, routeName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + public static Route Create(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, Route route) + { + return operations.CreateAsync(resourceGroupName, profileName, endpointName, routeName, route).GetAwaiter().GetResult(); + } + + /// + /// Creates a new route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, Route route, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, route, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + public static Route Update(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties) + { + return operations.UpdateAsync(resourceGroupName, profileName, endpointName, routeName, routeUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, routeUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + public static void Delete(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName) + { + operations.DeleteAsync(resourceGroupName, profileName, endpointName, routeName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a new route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + public static Route BeginCreate(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, Route route) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, endpointName, routeName, route).GetAwaiter().GetResult(); + } + + /// + /// Creates a new route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, Route route, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, route, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + public static Route BeginUpdate(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties) + { + return operations.BeginUpdateAsync(resourceGroupName, profileName, endpointName, routeName, routeUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// Route update properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, RouteUpdateParameters routeUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, routeUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + public static void BeginDelete(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, endpointName, routeName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing route with the specified route name under the specified + /// subscription, resource group, profile, and AzureFrontDoor endpoint. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the endpoint under the profile which is unique globally. + /// + /// + /// Name of the routing rule. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IRoutesOperations operations, string resourceGroupName, string profileName, string endpointName, string routeName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, routeName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByEndpointNext(this IRoutesOperations operations, string nextPageLink) + { + return operations.ListByEndpointNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing origins within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByEndpointNextAsync(this IRoutesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByEndpointNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperations.cs new file mode 100644 index 000000000000..19909da0583a --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperations.cs @@ -0,0 +1,1514 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RuleSetsOperations operations. + /// + internal partial class RuleSetsOperations : IServiceOperations, IRuleSetsOperations + { + /// + /// Initializes a new instance of the RuleSetsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RuleSetsOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing AzureFrontDoor rule set with the specified rule set name + /// under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule set + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsage", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/usages").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + RuleSet ruleSet = new RuleSet(); + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("ruleSet", ruleSet); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(ruleSet != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(ruleSet, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule set + /// name under the specified subscription, resource group and profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfileNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListResourceUsageNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListResourceUsageNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperationsExtensions.cs new file mode 100644 index 000000000000..5c32aa9f6863 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RuleSetsOperationsExtensions.cs @@ -0,0 +1,409 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for RuleSetsOperations. + /// + public static partial class RuleSetsOperationsExtensions + { + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static IPage ListByProfile(this IRuleSetsOperations operations, string resourceGroupName, string profileName) + { + return operations.ListByProfileAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileAsync(this IRuleSetsOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing AzureFrontDoor rule set with the specified rule set name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + public static RuleSet Get(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName) + { + return operations.GetAsync(resourceGroupName, profileName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing AzureFrontDoor rule set with the specified rule set name + /// under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + public static RuleSet Create(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName) + { + return operations.CreateAsync(resourceGroupName, profileName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule set + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + public static void Delete(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName) + { + operations.DeleteAsync(resourceGroupName, profileName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule set + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + public static IPage ListResourceUsage(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName) + { + return operations.ListResourceUsageAsync(resourceGroupName, profileName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageAsync(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + public static RuleSet BeginCreate(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Creates a new rule set within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule set + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + public static void BeginDelete(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing AzureFrontDoor rule set with the specified rule set + /// name under the specified subscription, resource group and profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile which is unique globally. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IRuleSetsOperations operations, string resourceGroupName, string profileName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByProfileNext(this IRuleSetsOperations operations, string nextPageLink) + { + return operations.ListByProfileNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor rule sets within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileNextAsync(this IRuleSetsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListResourceUsageNext(this IRuleSetsOperations operations, string nextPageLink) + { + return operations.ListResourceUsageNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Checks the quota and actual usage of endpoints under the given CDN profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListResourceUsageNextAsync(this IRuleSetsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListResourceUsageNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperations.cs new file mode 100644 index 000000000000..7eb779cde4e4 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperations.cs @@ -0,0 +1,1470 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// RulesOperations operations. + /// + internal partial class RulesOperations : IServiceOperations, IRulesOperations + { + /// + /// Initializes a new instance of the RulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal RulesOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByRuleSetWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByRuleSet", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, rule, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, ruleUpdateProperties, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (rule == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "rule"); + } + if (rule != null) + { + rule.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("rule", rule); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(rule != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(rule, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (ruleUpdateProperties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleUpdateProperties"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("ruleUpdateProperties", ruleUpdateProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(ruleUpdateProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(ruleUpdateProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string ruleSetName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (ruleSetName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleSetName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("ruleSetName", ruleSetName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{ruleSetName}", System.Uri.EscapeDataString(ruleSetName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByRuleSetNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByRuleSetNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperationsExtensions.cs new file mode 100644 index 000000000000..47e83c5e1123 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/RulesOperationsExtensions.cs @@ -0,0 +1,487 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for RulesOperations. + /// + public static partial class RulesOperationsExtensions + { + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + public static IPage ListByRuleSet(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName) + { + return operations.ListByRuleSetAsync(resourceGroupName, profileName, ruleSetName).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByRuleSetAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByRuleSetWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + public static Rule Get(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName) + { + return operations.GetAsync(resourceGroupName, profileName, ruleSetName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + public static Rule Create(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule) + { + return operations.CreateAsync(resourceGroupName, profileName, ruleSetName, ruleName, rule).GetAwaiter().GetResult(); + } + + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, rule, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + public static Rule Update(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties) + { + return operations.UpdateAsync(resourceGroupName, profileName, ruleSetName, ruleName, ruleUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, ruleUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + public static void Delete(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName) + { + operations.DeleteAsync(resourceGroupName, profileName, ruleSetName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + public static Rule BeginCreate(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, ruleSetName, ruleName, rule).GetAwaiter().GetResult(); + } + + /// + /// Creates a new delivery rule within the specified rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The delivery rule properties. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, Rule rule, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, rule, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + public static Rule BeginUpdate(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties) + { + return operations.BeginUpdateAsync(resourceGroupName, profileName, ruleSetName, ruleName, ruleUpdateProperties).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// Delivery rule properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, RuleUpdateParameters ruleUpdateProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, ruleUpdateProperties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + public static void BeginDelete(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, ruleSetName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing delivery rule within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the rule set under the profile. + /// + /// + /// Name of the delivery rule which is unique within the endpoint. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IRulesOperations operations, string resourceGroupName, string profileName, string ruleSetName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, ruleSetName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByRuleSetNext(this IRulesOperations operations, string nextPageLink) + { + return operations.ListByRuleSetNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the existing delivery rules within a rule set. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByRuleSetNextAsync(this IRulesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByRuleSetNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SdkInfo_CdnManagementClient.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SdkInfo_CdnManagementClient.cs index f55574fd48a0..00cfa30c1dc5 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SdkInfo_CdnManagementClient.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SdkInfo_CdnManagementClient.cs @@ -19,32 +19,33 @@ public static IEnumerable> ApiInfo_CdnManagementCl { return new Tuple[] { - new Tuple("Cdn", "CheckNameAvailability", "2020-04-15"), - new Tuple("Cdn", "CheckNameAvailabilityWithSubscription", "2020-04-15"), - new Tuple("Cdn", "CustomDomains", "2020-04-15"), - new Tuple("Cdn", "EdgeNodes", "2020-04-15"), - new Tuple("Cdn", "Endpoints", "2020-04-15"), - new Tuple("Cdn", "ManagedRuleSets", "2020-04-15"), - new Tuple("Cdn", "Operations", "2020-04-15"), - new Tuple("Cdn", "OriginGroups", "2020-04-15"), - new Tuple("Cdn", "Origins", "2020-04-15"), - new Tuple("Cdn", "Policies", "2020-04-15"), - new Tuple("Cdn", "Profiles", "2020-04-15"), - new Tuple("Cdn", "ResourceUsage", "2020-04-15"), - new Tuple("Cdn", "ValidateProbe", "2020-04-15"), + new Tuple("Cdn", "AFDCustomDomains", "2020-09-01"), + new Tuple("Cdn", "AFDEndpoints", "2020-09-01"), + new Tuple("Cdn", "AFDOriginGroups", "2020-09-01"), + new Tuple("Cdn", "AFDOrigins", "2020-09-01"), + new Tuple("Cdn", "AFDProfiles", "2020-09-01"), + new Tuple("Cdn", "CheckNameAvailability", "2020-09-01"), + new Tuple("Cdn", "CheckNameAvailabilityWithSubscription", "2020-09-01"), + new Tuple("Cdn", "CustomDomains", "2020-09-01"), + new Tuple("Cdn", "EdgeNodes", "2020-09-01"), + new Tuple("Cdn", "Endpoints", "2020-09-01"), + new Tuple("Cdn", "LogAnalytics", "2020-09-01"), + new Tuple("Cdn", "ManagedRuleSets", "2020-09-01"), + new Tuple("Cdn", "Operations", "2020-09-01"), + new Tuple("Cdn", "OriginGroups", "2020-09-01"), + new Tuple("Cdn", "Origins", "2020-09-01"), + new Tuple("Cdn", "Policies", "2020-09-01"), + new Tuple("Cdn", "Profiles", "2020-09-01"), + new Tuple("Cdn", "ResourceUsage", "2020-09-01"), + new Tuple("Cdn", "Routes", "2020-09-01"), + new Tuple("Cdn", "RuleSets", "2020-09-01"), + new Tuple("Cdn", "Rules", "2020-09-01"), + new Tuple("Cdn", "Secrets", "2020-09-01"), + new Tuple("Cdn", "SecurityPolicies", "2020-09-01"), + new Tuple("Cdn", "Validate", "2020-09-01"), + new Tuple("Cdn", "ValidateProbe", "2020-09-01"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/cdn/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --tag=package-2020-04 --csharp-sdks-folder=C:\\git\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "81ee445f0291ea1b284509dd42b3d37aea3799d7"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperations.cs new file mode 100644 index 000000000000..dd418cbb9036 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperations.cs @@ -0,0 +1,1414 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecretsOperations operations. + /// + internal partial class SecretsOperations : IServiceOperations, ISecretsOperations + { + /// + /// Initializes a new instance of the SecretsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecretsOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (secretName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secretName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("secretName", secretName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{secretName}", System.Uri.EscapeDataString(secretName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, secretName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, secretName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing Secret within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, secretName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (secretName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secretName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + Secret secret = new Secret(); + if (parameters != null) + { + secret.Parameters = parameters; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("secretName", secretName); + tracingParameters.Add("secret", secret); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{secretName}", System.Uri.EscapeDataString(secretName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(secret != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(secret, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (secretName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secretName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + SecretProperties secretProperties = new SecretProperties(); + if (parameters != null) + { + secretProperties.Parameters = parameters; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("secretName", secretName); + tracingParameters.Add("secretProperties", secretProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{secretName}", System.Uri.EscapeDataString(secretName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(secretProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(secretProperties, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing Secret within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string secretName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (secretName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secretName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("secretName", secretName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{secretName}", System.Uri.EscapeDataString(secretName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfileNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperationsExtensions.cs new file mode 100644 index 000000000000..05571fe4dfe4 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecretsOperationsExtensions.cs @@ -0,0 +1,439 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecretsOperations. + /// + public static partial class SecretsOperationsExtensions + { + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static IPage ListByProfile(this ISecretsOperations operations, string resourceGroupName, string profileName) + { + return operations.ListByProfileAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + public static Secret Get(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName) + { + return operations.GetAsync(resourceGroupName, profileName, secretName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, secretName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + public static Secret Create(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters)) + { + return operations.CreateAsync(resourceGroupName, profileName, secretName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, secretName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + public static Secret Update(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters)) + { + return operations.UpdateAsync(resourceGroupName, profileName, secretName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, profileName, secretName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Secret within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + public static void Delete(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName) + { + operations.DeleteAsync(resourceGroupName, profileName, secretName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Secret within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, secretName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + public static Secret BeginCreate(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters)) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, secretName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new Secret within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, secretName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + public static Secret BeginUpdate(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters)) + { + return operations.BeginUpdateAsync(resourceGroupName, profileName, secretName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// object which contains secret parameters + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, SecretParameters parameters = default(SecretParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, secretName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing Secret within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + public static void BeginDelete(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, secretName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing Secret within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this ISecretsOperations operations, string resourceGroupName, string profileName, string secretName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, secretName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByProfileNext(this ISecretsOperations operations, string nextPageLink) + { + return operations.ListByProfileNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists existing AzureFrontDoor secrets. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileNextAsync(this ISecretsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperations.cs new file mode 100644 index 000000000000..7886f7e03961 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperations.cs @@ -0,0 +1,1413 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecurityPoliciesOperations operations. + /// + internal partial class SecurityPoliciesOperations : IServiceOperations, ISecurityPoliciesOperations + { + /// + /// Initializes a new instance of the SecurityPoliciesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecurityPoliciesOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Lists security policies associated with the profile + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileWithHttpMessagesAsync(string resourceGroupName, string profileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfile", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an existing security policy within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (securityPolicyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "securityPolicyName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("securityPolicyName", securityPolicyName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{securityPolicyName}", System.Uri.EscapeDataString(securityPolicyName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> PatchWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginPatchWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, securityPolicyParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing security policy within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (securityPolicyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "securityPolicyName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + SecurityPolicy securityPolicy = new SecurityPolicy(); + if (parameters != null) + { + securityPolicy.Parameters = parameters; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("securityPolicyName", securityPolicyName); + tracingParameters.Add("securityPolicy", securityPolicy); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{securityPolicyName}", System.Uri.EscapeDataString(securityPolicyName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(securityPolicy != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(securityPolicy, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginPatchWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (securityPolicyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "securityPolicyName"); + } + if (securityPolicyParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "securityPolicyParameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("securityPolicyName", securityPolicyName); + tracingParameters.Add("securityPolicyParameters", securityPolicyParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginPatch", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{securityPolicyName}", System.Uri.EscapeDataString(securityPolicyName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(securityPolicyParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(securityPolicyParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an existing security policy within profile. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string profileName, string securityPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (profileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "profileName"); + } + if (securityPolicyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "securityPolicyName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("profileName", profileName); + tracingParameters.Add("securityPolicyName", securityPolicyName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{profileName}", System.Uri.EscapeDataString(profileName)); + _url = _url.Replace("{securityPolicyName}", System.Uri.EscapeDataString(securityPolicyName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists security policies associated with the profile + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByProfileNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByProfileNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperationsExtensions.cs new file mode 100644 index 000000000000..00804be60470 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/SecurityPoliciesOperationsExtensions.cs @@ -0,0 +1,439 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecurityPoliciesOperations. + /// + public static partial class SecurityPoliciesOperationsExtensions + { + /// + /// Lists security policies associated with the profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + public static IPage ListByProfile(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName) + { + return operations.ListByProfileAsync(resourceGroupName, profileName).GetAwaiter().GetResult(); + } + + /// + /// Lists security policies associated with the profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileWithHttpMessagesAsync(resourceGroupName, profileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets an existing security policy within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + public static SecurityPolicy Get(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName) + { + return operations.GetAsync(resourceGroupName, profileName, securityPolicyName).GetAwaiter().GetResult(); + } + + /// + /// Gets an existing security policy within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + public static SecurityPolicy Create(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters)) + { + return operations.CreateAsync(resourceGroupName, profileName, securityPolicyName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + public static SecurityPolicy Patch(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters) + { + return operations.PatchAsync(resourceGroupName, profileName, securityPolicyName, securityPolicyParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + /// + /// The cancellation token. + /// + public static async Task PatchAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PatchWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, securityPolicyParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing security policy within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + public static void Delete(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName) + { + operations.DeleteAsync(resourceGroupName, profileName, securityPolicyName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing security policy within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + public static SecurityPolicy BeginCreate(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters)) + { + return operations.BeginCreateAsync(resourceGroupName, profileName, securityPolicyName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates a new security policy within the specified profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// object which contains security policy parameters + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters parameters = default(SecurityPolicyWebApplicationFirewallParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + public static SecurityPolicy BeginPatch(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters) + { + return operations.BeginPatchAsync(resourceGroupName, profileName, securityPolicyName, securityPolicyParameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing Secret within a profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the security policy under the profile. + /// + /// + /// Security policy update properties + /// + /// + /// The cancellation token. + /// + public static async Task BeginPatchAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, SecurityPolicyWebApplicationFirewallParameters securityPolicyParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginPatchWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, securityPolicyParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an existing security policy within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + public static void BeginDelete(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName) + { + operations.BeginDeleteAsync(resourceGroupName, profileName, securityPolicyName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an existing security policy within profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// Name of the CDN profile which is unique within the resource group. + /// + /// + /// Name of the Secret under the profile. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this ISecurityPoliciesOperations operations, string resourceGroupName, string profileName, string securityPolicyName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, profileName, securityPolicyName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists security policies associated with the profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByProfileNext(this ISecurityPoliciesOperations operations, string nextPageLink) + { + return operations.ListByProfileNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists security policies associated with the profile + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByProfileNextAsync(this ISecurityPoliciesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByProfileNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperations.cs new file mode 100644 index 000000000000..2e37eba271c5 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperations.cs @@ -0,0 +1,255 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ValidateOperations operations. + /// + internal partial class ValidateOperations : IServiceOperations, IValidateOperations + { + /// + /// Initializes a new instance of the ValidateOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ValidateOperations(CdnManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CdnManagementClient + /// + public CdnManagementClient Client { get; private set; } + + /// + /// Validate a Secret in the profile. + /// + /// + /// The secret source. + /// + /// + /// The secret type. Possible values include: 'UrlSigningKey', + /// 'ManagedCertificate', 'CustomerCertificate' + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> SecretMethodWithHttpMessagesAsync(ResourceReference secretSource, string secretType, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (secretSource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secretSource"); + } + if (secretType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "secretType"); + } + ValidateSecretInput validateSecretInput = new ValidateSecretInput(); + if (secretSource != null || secretType != null) + { + validateSecretInput.SecretSource = secretSource; + validateSecretInput.SecretType = secretType; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("validateSecretInput", validateSecretInput); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "SecretMethod", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateSecret").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(validateSecretInput != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(validateSecretInput, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new AfdErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + AfdErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperationsExtensions.cs new file mode 100644 index 000000000000..2e950fbd4d5e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ValidateOperationsExtensions.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Cdn +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ValidateOperations. + /// + public static partial class ValidateOperationsExtensions + { + /// + /// Validate a Secret in the profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The secret source. + /// + /// + /// The secret type. Possible values include: 'UrlSigningKey', + /// 'ManagedCertificate', 'CustomerCertificate' + /// + public static ValidateSecretOutput SecretMethod(this IValidateOperations operations, ResourceReference secretSource, string secretType) + { + return operations.SecretMethodAsync(secretSource, secretType).GetAwaiter().GetResult(); + } + + /// + /// Validate a Secret in the profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The secret source. + /// + /// + /// The secret type. Possible values include: 'UrlSigningKey', + /// 'ManagedCertificate', 'CustomerCertificate' + /// + /// + /// The cancellation token. + /// + public static async Task SecretMethodAsync(this IValidateOperations operations, ResourceReference secretSource, string secretType, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.SecretMethodWithHttpMessagesAsync(secretSource, secretType, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}