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 758347f418a34..b5323258d04cf 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/CdnManagementClient.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/CdnManagementClient.cs @@ -59,6 +59,17 @@ public partial class CdnManagementClient : ServiceClient, I /// public string ApiVersion { get; private set; } + /// + /// Azure Subscription ID. + /// + public string SubscriptionId1 { get; set; } + + /// + /// Version of the API to be used with the client request. Current version is + /// 2017-04-02. + /// + public string ApiVersion1 { get; set; } + /// /// The preferred language for the response. /// @@ -112,6 +123,16 @@ public partial class CdnManagementClient : ServiceClient, I /// public virtual IEdgeNodesOperations EdgeNodes { get; private set; } + /// + /// Gets the IPoliciesOperations. + /// + public virtual IPoliciesOperations Policies { get; private set; } + + /// + /// Gets the IManagedRuleSetsOperations. + /// + public virtual IManagedRuleSetsOperations ManagedRuleSets { get; private set; } + /// /// Initializes a new instance of the CdnManagementClient class. /// @@ -360,8 +381,10 @@ private void Initialize() ResourceUsage = new ResourceUsageOperations(this); Operations = new Operations(this); EdgeNodes = new EdgeNodesOperations(this); + Policies = new PoliciesOperations(this); + ManagedRuleSets = new ManagedRuleSetsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2019-04-15"; + ApiVersion = "2019-06-15"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; 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 3e0151ba28afa..0f8ebff2f6cda 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ICdnManagementClient.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ICdnManagementClient.cs @@ -55,6 +55,17 @@ public partial interface ICdnManagementClient : System.IDisposable /// string ApiVersion { get; } + /// + /// Azure Subscription ID. + /// + string SubscriptionId1 { get; set; } + + /// + /// Version of the API to be used with the client request. Current + /// version is 2017-04-02. + /// + string ApiVersion1 { get; set; } + /// /// The preferred language for the response. /// @@ -109,6 +120,16 @@ public partial interface ICdnManagementClient : System.IDisposable /// IEdgeNodesOperations EdgeNodes { get; } + /// + /// Gets the IPoliciesOperations. + /// + IPoliciesOperations Policies { get; } + + /// + /// Gets the IManagedRuleSetsOperations. + /// + IManagedRuleSetsOperations ManagedRuleSets { get; } + /// /// Check the availability of a resource name. This is needed for /// resources where name is globally unique, such as a CDN endpoint. diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IManagedRuleSetsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IManagedRuleSetsOperations.cs new file mode 100644 index 0000000000000..05c9808d43f90 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IManagedRuleSetsOperations.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 +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ManagedRuleSetsOperations operations. + /// + public partial interface IManagedRuleSetsOperations + { + /// + /// Lists all available managed rule sets. + /// + /// + /// 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>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all available managed rule sets. + /// + /// + /// 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IPoliciesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IPoliciesOperations.cs new file mode 100644 index 0000000000000..770a556981728 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/IPoliciesOperations.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; + + /// + /// PoliciesOperations operations. + /// + public partial interface IPoliciesOperations + { + /// + /// Lists all of the protection policies within a resource group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// 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>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve protection policy with specified name within a resource + /// group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// 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 policyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update policy with specified rule set name within a + /// resource group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the + /// specified policy name under the specified subscription and resource + /// group + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + /// + /// 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 policyName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes Policy + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// 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 policyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update policy with specified rule set name within a + /// resource group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the + /// specified policy name under the specified subscription and resource + /// group + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + /// + /// 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 policyName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all of the protection policies within a resource 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ManagedRuleSetsOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ManagedRuleSetsOperations.cs new file mode 100644 index 0000000000000..2e2943428c721 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ManagedRuleSetsOperations.cs @@ -0,0 +1,395 @@ +// +// 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; + + /// + /// ManagedRuleSetsOperations operations. + /// + internal partial class ManagedRuleSetsOperations : IServiceOperations, IManagedRuleSetsOperations + { + /// + /// Initializes a new instance of the ManagedRuleSetsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ManagedRuleSetsOperations(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 available managed rule sets. + /// + /// + /// 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>> ListWithHttpMessagesAsync(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"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Cdn/CdnWebApplicationFirewallManagedRuleSets").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("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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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 all available managed rule sets. + /// + /// + /// 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>> ListNextWithHttpMessagesAsync(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, "ListNext", 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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/ManagedRuleSetsOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ManagedRuleSetsOperationsExtensions.cs new file mode 100644 index 0000000000000..ff64d37500b49 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/ManagedRuleSetsOperationsExtensions.cs @@ -0,0 +1,87 @@ +// +// 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 ManagedRuleSetsOperations. + /// + public static partial class ManagedRuleSetsOperationsExtensions + { + /// + /// Lists all available managed rule sets. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IManagedRuleSetsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all available managed rule sets. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IManagedRuleSetsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all available managed rule sets. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IManagedRuleSetsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all available managed rule sets. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IManagedRuleSetsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ActionType.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ActionType.cs new file mode 100644 index 0000000000000..4bb5f380aee81 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ActionType.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 ActionType. + /// + public static class ActionType + { + public const string Allow = "Allow"; + public const string Block = "Block"; + public const string Log = "Log"; + public const string Redirect = "Redirect"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnEndpoint.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnEndpoint.cs new file mode 100644 index 0000000000000..5846030d5434f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnEndpoint.cs @@ -0,0 +1,51 @@ +// +// 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; + + /// + /// Defines the ARM Resource ID for the linked endpoints + /// + public partial class CdnEndpoint + { + /// + /// Initializes a new instance of the CdnEndpoint class. + /// + public CdnEndpoint() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CdnEndpoint class. + /// + /// ARM Resource ID string. + public CdnEndpoint(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets ARM Resource ID string. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} 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 new file mode 100644 index 0000000000000..31d0d1e2215b3 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicy.cs @@ -0,0 +1,163 @@ +// +// 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; + + /// + /// Defines web application firewall policy for Azure CDN. + /// + [Rest.Serialization.JsonTransformation] + public partial class CdnWebApplicationFirewallPolicy : TrackedResource + { + /// + /// Initializes a new instance of the CdnWebApplicationFirewallPolicy + /// class. + /// + public CdnWebApplicationFirewallPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CdnWebApplicationFirewallPolicy + /// class. + /// + /// Resource location. + /// The pricing tier (defines a CDN provider, feature + /// list and rate) of the CdnWebApplicationFirewallPolicy. + /// Resource ID. + /// Resource name. + /// Resource type. + /// Resource tags. + /// Describes policySettings for + /// policy + /// Describes rate limit rules inside the + /// policy. + /// Describes custom rules inside the + /// policy. + /// Describes managed rules inside the + /// policy. + /// Describes Azure CDN endpoints + /// associated with this Web Application Firewall policy. + /// Provisioning state of the + /// WebApplicationFirewallPolicy. Possible values include: 'Creating', + /// 'Succeeded', 'Failed' + /// 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) + { + PolicySettings = policySettings; + RateLimitRules = rateLimitRules; + CustomRules = customRules; + ManagedRules = managedRules; + EndpointLinks = endpointLinks; + ProvisioningState = provisioningState; + ResourceState = resourceState; + Etag = etag; + Sku = sku; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets describes policySettings for policy + /// + [JsonProperty(PropertyName = "properties.policySettings")] + public PolicySettings PolicySettings { get; set; } + + /// + /// Gets or sets describes rate limit rules inside the policy. + /// + [JsonProperty(PropertyName = "properties.rateLimitRules")] + public RateLimitRuleList RateLimitRules { get; set; } + + /// + /// Gets or sets describes custom rules inside the policy. + /// + [JsonProperty(PropertyName = "properties.customRules")] + public CustomRuleList CustomRules { get; set; } + + /// + /// Gets or sets describes managed rules inside the policy. + /// + [JsonProperty(PropertyName = "properties.managedRules")] + public ManagedRuleSetList ManagedRules { get; set; } + + /// + /// Gets describes Azure CDN endpoints associated with this Web + /// Application Firewall policy. + /// + [JsonProperty(PropertyName = "properties.endpointLinks")] + public IList EndpointLinks { get; private set; } + + /// + /// Gets provisioning state of the WebApplicationFirewallPolicy. + /// Possible values include: 'Creating', 'Succeeded', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets resource status of the policy. + /// + /// + /// Possible values include: 'Creating', 'Enabling', 'Enabled', + /// 'Disabling', 'Disabled', 'Deleting' + /// + [JsonProperty(PropertyName = "properties.resourceState")] + public string ResourceState { get; private set; } + + /// + /// Gets a unique read-only string that changes whenever the resource + /// is updated. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; set; } + + /// + /// Gets or sets the pricing tier (defines a CDN provider, feature list + /// and rate) of the CdnWebApplicationFirewallPolicy. + /// + [JsonProperty(PropertyName = "sku")] + public Sku Sku { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Sku == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Sku"); + } + if (PolicySettings != null) + { + PolicySettings.Validate(); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicyPatchParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicyPatchParameters.cs new file mode 100644 index 0000000000000..418181bc96456 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CdnWebApplicationFirewallPolicyPatchParameters.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 Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties required to update a CdnWebApplicationFirewallPolicy. + /// + public partial class CdnWebApplicationFirewallPolicyPatchParameters : IResource + { + /// + /// Initializes a new instance of the + /// CdnWebApplicationFirewallPolicyPatchParameters class. + /// + public CdnWebApplicationFirewallPolicyPatchParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// CdnWebApplicationFirewallPolicyPatchParameters class. + /// + /// CdnWebApplicationFirewallPolicy tags + public CdnWebApplicationFirewallPolicyPatchParameters(IDictionary tags = default(IDictionary)) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets cdnWebApplicationFirewallPolicy tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomainHttpsParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomainHttpsParameters.cs index 4c85cd774edf2..90e83d3900671 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomainHttpsParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomDomainHttpsParameters.cs @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Management.Cdn.Models /// /// The JSON object that contains the properties to secure a custom domain. /// + [Newtonsoft.Json.JsonObject("CustomDomainHttpsParameters")] public partial class CustomDomainHttpsParameters { /// diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRule.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRule.cs new file mode 100644 index 0000000000000..8e45521c784a0 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRule.cs @@ -0,0 +1,135 @@ +// +// 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; + + /// + /// Defines the common attributes for a custom rule that can be included in + /// a waf policy + /// + public partial class CustomRule + { + /// + /// Initializes a new instance of the CustomRule class. + /// + public CustomRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomRule class. + /// + /// Defines the name of the custom rule + /// Defines in what order this rule be evaluated + /// in the overall list of custom rules + /// List of match conditions. + /// Describes what action to be applied when rule + /// matches. Possible values include: 'Allow', 'Block', 'Log', + /// 'Redirect' + /// Describes if the custom rule is in + /// enabled or disabled state. Defaults to Enabled if not specified. + /// Possible values include: 'Disabled', 'Enabled' + public CustomRule(string name, int priority, IList matchConditions, string action, string enabledState = default(string)) + { + Name = name; + EnabledState = enabledState; + Priority = priority; + MatchConditions = matchConditions; + Action = action; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the name of the custom rule + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets describes if the custom rule is in enabled or disabled + /// state. Defaults to Enabled if not specified. Possible values + /// include: 'Disabled', 'Enabled' + /// + [JsonProperty(PropertyName = "enabledState")] + public string EnabledState { get; set; } + + /// + /// Gets or sets defines in what order this rule be evaluated in the + /// overall list of custom rules + /// + [JsonProperty(PropertyName = "priority")] + public int Priority { get; set; } + + /// + /// Gets or sets list of match conditions. + /// + [JsonProperty(PropertyName = "matchConditions")] + public IList MatchConditions { get; set; } + + /// + /// Gets or sets describes what action to be applied when rule matches. + /// Possible values include: 'Allow', 'Block', 'Log', 'Redirect' + /// + [JsonProperty(PropertyName = "action")] + public string Action { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (MatchConditions == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MatchConditions"); + } + if (Action == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Action"); + } + if (Priority > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Priority", 1000); + } + if (Priority < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Priority", 0); + } + if (MatchConditions != null) + { + foreach (var element in MatchConditions) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRuleEnabledState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRuleEnabledState.cs new file mode 100644 index 0000000000000..b38f931179b1c --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRuleEnabledState.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 CustomRuleEnabledState. + /// + public static class CustomRuleEnabledState + { + public const string Disabled = "Disabled"; + public const string Enabled = "Enabled"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRuleList.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRuleList.cs new file mode 100644 index 0000000000000..7cf356bc65940 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/CustomRuleList.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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines contents of custom rules + /// + public partial class CustomRuleList + { + /// + /// Initializes a new instance of the CustomRuleList class. + /// + public CustomRuleList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomRuleList class. + /// + /// List of rules + public CustomRuleList(IList rules = default(IList)) + { + Rules = rules; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of rules + /// + [JsonProperty(PropertyName = "rules")] + public IList Rules { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleAction.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleAction.cs index f3bf8839a90d7..835c8320eb43f 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleAction.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleAction.cs @@ -10,11 +10,13 @@ namespace Microsoft.Azure.Management.Cdn.Models { + using Newtonsoft.Json; using System.Linq; /// /// An action for the delivery rule. /// + [Newtonsoft.Json.JsonObject("DeliveryRuleAction")] public partial class DeliveryRuleAction { /// diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleCondition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleCondition.cs index 6356a4e60bf08..dec4606dda258 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleCondition.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/DeliveryRuleCondition.cs @@ -10,11 +10,13 @@ namespace Microsoft.Azure.Management.Cdn.Models { + using Newtonsoft.Json; using System.Linq; /// /// A condition for the delivery rule. /// + [Newtonsoft.Json.JsonObject("DeliveryRuleCondition")] public partial class DeliveryRuleCondition { /// 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 e1f3d0ae41b83..da9e64c23694d 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 @@ -88,6 +88,9 @@ public Endpoint() /// /pictures/ /// A policy that specifies the delivery /// rules to be used for an endpoint. + /// Defines the Web + /// Application Firewall policy for the endpoint (if + /// applicable) /// The host name of the endpoint structured as /// {endpointName}.{DNSZone}, e.g. contoso.azureedge.net /// Resource status of the endpoint. @@ -95,7 +98,7 @@ 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 originHostHeader = default(string), string originPath = default(string), IList contentTypesToCompress = default(IList), 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), EndpointPropertiesUpdateParametersDeliveryPolicy deliveryPolicy = default(EndpointPropertiesUpdateParametersDeliveryPolicy), string hostName = default(string), string resourceState = default(string), string provisioningState = default(string)) + public Endpoint(string location, IList origins, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string originHostHeader = default(string), string originPath = default(string), IList contentTypesToCompress = default(IList), 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), EndpointPropertiesUpdateParametersDeliveryPolicy deliveryPolicy = default(EndpointPropertiesUpdateParametersDeliveryPolicy), EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink webApplicationFirewallPolicyLink = default(EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink), string hostName = default(string), string resourceState = default(string), string provisioningState = default(string)) : base(location, id, name, type, tags) { OriginHostHeader = originHostHeader; @@ -109,6 +112,7 @@ public Endpoint() ProbePath = probePath; GeoFilters = geoFilters; DeliveryPolicy = deliveryPolicy; + WebApplicationFirewallPolicyLink = webApplicationFirewallPolicyLink; HostName = hostName; Origins = origins; ResourceState = resourceState; @@ -216,6 +220,13 @@ public Endpoint() [JsonProperty(PropertyName = "properties.deliveryPolicy")] public EndpointPropertiesUpdateParametersDeliveryPolicy DeliveryPolicy { get; set; } + /// + /// Gets or sets defines the Web Application Firewall policy for the + /// endpoint (if applicable) + /// + [JsonProperty(PropertyName = "properties.webApplicationFirewallPolicyLink")] + public EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink WebApplicationFirewallPolicyLink { get; set; } + /// /// Gets the host name of the endpoint structured as /// {endpointName}.{DNSZone}, e.g. contoso.azureedge.net diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink.cs new file mode 100644 index 0000000000000..b44376d4edb0e --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink.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; + + /// + /// Defines the Web Application Firewall policy for the endpoint (if + /// applicable) + /// + public partial class EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink + { + /// + /// Initializes a new instance of the + /// EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink + /// class. + /// + public EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink + /// class. + /// + /// Resource ID. + public EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EndpointUpdateParameters.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EndpointUpdateParameters.cs index ebd9890d26ce6..ed16e5a2433d9 100644 --- a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EndpointUpdateParameters.cs +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/EndpointUpdateParameters.cs @@ -80,7 +80,10 @@ public EndpointUpdateParameters() /// /pictures/ /// A policy that specifies the delivery /// rules to be used for an endpoint. - public EndpointUpdateParameters(IDictionary tags = default(IDictionary), string originHostHeader = default(string), string originPath = default(string), IList contentTypesToCompress = default(IList), 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), EndpointPropertiesUpdateParametersDeliveryPolicy deliveryPolicy = default(EndpointPropertiesUpdateParametersDeliveryPolicy)) + /// Defines the Web + /// Application Firewall policy for the endpoint (if + /// applicable) + public EndpointUpdateParameters(IDictionary tags = default(IDictionary), string originHostHeader = default(string), string originPath = default(string), IList contentTypesToCompress = default(IList), 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), EndpointPropertiesUpdateParametersDeliveryPolicy deliveryPolicy = default(EndpointPropertiesUpdateParametersDeliveryPolicy), EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink webApplicationFirewallPolicyLink = default(EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink)) { Tags = tags; OriginHostHeader = originHostHeader; @@ -94,6 +97,7 @@ public EndpointUpdateParameters() ProbePath = probePath; GeoFilters = geoFilters; DeliveryPolicy = deliveryPolicy; + WebApplicationFirewallPolicyLink = webApplicationFirewallPolicyLink; CustomInit(); } @@ -203,6 +207,13 @@ public EndpointUpdateParameters() [JsonProperty(PropertyName = "properties.deliveryPolicy")] public EndpointPropertiesUpdateParametersDeliveryPolicy DeliveryPolicy { get; set; } + /// + /// Gets or sets defines the Web Application Firewall policy for the + /// endpoint (if applicable) + /// + [JsonProperty(PropertyName = "properties.webApplicationFirewallPolicyLink")] + public EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink WebApplicationFirewallPolicyLink { get; set; } + /// /// Validate the object. /// diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleDefinition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleDefinition.cs new file mode 100644 index 0000000000000..2b5b656283186 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleDefinition.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; + + /// + /// Describes a managed rule definition. + /// + public partial class ManagedRuleDefinition + { + /// + /// Initializes a new instance of the ManagedRuleDefinition class. + /// + public ManagedRuleDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedRuleDefinition class. + /// + /// Identifier for the managed rule. + /// Describes the functionality of the + /// managed rule. + public ManagedRuleDefinition(string ruleId = default(string), string description = default(string)) + { + RuleId = ruleId; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets identifier for the managed rule. + /// + [JsonProperty(PropertyName = "ruleId")] + public string RuleId { get; private set; } + + /// + /// Gets describes the functionality of the managed rule. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleEnabledState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleEnabledState.cs new file mode 100644 index 0000000000000..b727c237c94c4 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleEnabledState.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 ManagedRuleEnabledState. + /// + public static class ManagedRuleEnabledState + { + public const string Disabled = "Disabled"; + public const string Enabled = "Enabled"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleGroupDefinition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleGroupDefinition.cs new file mode 100644 index 0000000000000..35544dc88cb7b --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleGroupDefinition.cs @@ -0,0 +1,71 @@ +// +// 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; + + /// + /// Describes a managed rule group. + /// + public partial class ManagedRuleGroupDefinition + { + /// + /// Initializes a new instance of the ManagedRuleGroupDefinition class. + /// + public ManagedRuleGroupDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedRuleGroupDefinition class. + /// + /// Name of the managed rule group. + /// Description of the managed rule + /// group. + /// List of rules within the managed rule + /// group. + public ManagedRuleGroupDefinition(string ruleGroupName = default(string), string description = default(string), IList rules = default(IList)) + { + RuleGroupName = ruleGroupName; + Description = description; + Rules = rules; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets name of the managed rule group. + /// + [JsonProperty(PropertyName = "ruleGroupName")] + public string RuleGroupName { get; private set; } + + /// + /// Gets description of the managed rule group. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + /// + /// Gets list of rules within the managed rule group. + /// + [JsonProperty(PropertyName = "rules")] + public IList Rules { get; private set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleGroupOverride.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleGroupOverride.cs new file mode 100644 index 0000000000000..6160f230c6f4b --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleGroupOverride.cs @@ -0,0 +1,89 @@ +// +// 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; + + /// + /// Defines a managed rule group override setting. + /// + public partial class ManagedRuleGroupOverride + { + /// + /// Initializes a new instance of the ManagedRuleGroupOverride class. + /// + public ManagedRuleGroupOverride() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedRuleGroupOverride class. + /// + /// Describes the managed rule group within + /// the rule set to override + /// List of rules that will be disabled. If none + /// specified, all rules in the group will be disabled. + public ManagedRuleGroupOverride(string ruleGroupName, IList rules = default(IList)) + { + RuleGroupName = ruleGroupName; + Rules = rules; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets describes the managed rule group within the rule set + /// to override + /// + [JsonProperty(PropertyName = "ruleGroupName")] + public string RuleGroupName { get; set; } + + /// + /// Gets or sets list of rules that will be disabled. If none + /// specified, all rules in the group will be disabled. + /// + [JsonProperty(PropertyName = "rules")] + public IList Rules { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RuleGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RuleGroupName"); + } + if (Rules != null) + { + foreach (var element in Rules) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleOverride.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleOverride.cs new file mode 100644 index 0000000000000..6e843283c916f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleOverride.cs @@ -0,0 +1,89 @@ +// +// 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 a managed rule group override setting. + /// + public partial class ManagedRuleOverride + { + /// + /// Initializes a new instance of the ManagedRuleOverride class. + /// + public ManagedRuleOverride() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedRuleOverride class. + /// + /// Identifier for the managed rule. + /// Describes if the managed rule is in + /// enabled or disabled state. Defaults to Disabled if not specified. + /// Possible values include: 'Disabled', 'Enabled' + /// Describes the override action to be applied + /// when rule matches. Possible values include: 'Allow', 'Block', + /// 'Log', 'Redirect' + public ManagedRuleOverride(string ruleId, string enabledState = default(string), string action = default(string)) + { + RuleId = ruleId; + EnabledState = enabledState; + Action = action; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets identifier for the managed rule. + /// + [JsonProperty(PropertyName = "ruleId")] + public string RuleId { get; set; } + + /// + /// Gets or sets describes if the managed rule is in enabled or + /// disabled state. Defaults to Disabled if not specified. Possible + /// values include: 'Disabled', 'Enabled' + /// + [JsonProperty(PropertyName = "enabledState")] + public string EnabledState { get; set; } + + /// + /// Gets or sets describes the override action to be applied when rule + /// matches. Possible values include: 'Allow', 'Block', 'Log', + /// 'Redirect' + /// + [JsonProperty(PropertyName = "action")] + public string Action { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RuleId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RuleId"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSet.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSet.cs new file mode 100644 index 0000000000000..0c4fe4e2a6a03 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSet.cs @@ -0,0 +1,118 @@ +// +// 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; + + /// + /// Defines a managed rule set. + /// + public partial class ManagedRuleSet + { + /// + /// Initializes a new instance of the ManagedRuleSet class. + /// + public ManagedRuleSet() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedRuleSet class. + /// + /// Defines the rule set type to use. + /// Defines the version of the rule set to + /// use. + /// Verizon only : If the rule set supports + /// anomaly detection mode, this describes the threshold for blocking + /// requests. + /// Defines the rule overrides to + /// apply to the rule set. + public ManagedRuleSet(string ruleSetType, string ruleSetVersion, int? anomalyScore = default(int?), IList ruleGroupOverrides = default(IList)) + { + RuleSetType = ruleSetType; + RuleSetVersion = ruleSetVersion; + AnomalyScore = anomalyScore; + RuleGroupOverrides = ruleGroupOverrides; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines the rule set type to use. + /// + [JsonProperty(PropertyName = "ruleSetType")] + public string RuleSetType { get; set; } + + /// + /// Gets or sets defines the version of the rule set to use. + /// + [JsonProperty(PropertyName = "ruleSetVersion")] + public string RuleSetVersion { get; set; } + + /// + /// Gets or sets verizon only : If the rule set supports anomaly + /// detection mode, this describes the threshold for blocking requests. + /// + [JsonProperty(PropertyName = "anomalyScore")] + public int? AnomalyScore { get; set; } + + /// + /// Gets or sets defines the rule overrides to apply to the rule set. + /// + [JsonProperty(PropertyName = "ruleGroupOverrides")] + public IList RuleGroupOverrides { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RuleSetType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RuleSetType"); + } + if (RuleSetVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RuleSetVersion"); + } + if (AnomalyScore > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "AnomalyScore", 20); + } + if (AnomalyScore < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "AnomalyScore", 0); + } + if (RuleGroupOverrides != null) + { + foreach (var element in RuleGroupOverrides) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSetDefinition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSetDefinition.cs new file mode 100644 index 0000000000000..6e0c89d753913 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSetDefinition.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; + + /// + /// Describes a managed rule set definition. + /// + [Rest.Serialization.JsonTransformation] + public partial class ManagedRuleSetDefinition : Resource + { + /// + /// Initializes a new instance of the ManagedRuleSetDefinition class. + /// + public ManagedRuleSetDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedRuleSetDefinition class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// Provisioning state of the managed + /// rule set. + /// Type of the managed rule set. + /// Version of the managed rule set + /// type. + /// Rule groups of the managed rule + /// set. + /// The pricing tier (defines a CDN provider, feature + /// list and rate) of the CdnWebApplicationFirewallPolicy. + public ManagedRuleSetDefinition(string id = default(string), string name = default(string), string type = default(string), string provisioningState = default(string), string ruleSetType = default(string), string ruleSetVersion = default(string), IList ruleGroups = default(IList), Sku sku = default(Sku)) + : base(id, name, type) + { + ProvisioningState = provisioningState; + RuleSetType = ruleSetType; + RuleSetVersion = ruleSetVersion; + RuleGroups = ruleGroups; + Sku = sku; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning state of the managed rule set. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets type of the managed rule set. + /// + [JsonProperty(PropertyName = "properties.ruleSetType")] + public string RuleSetType { get; private set; } + + /// + /// Gets version of the managed rule set type. + /// + [JsonProperty(PropertyName = "properties.ruleSetVersion")] + public string RuleSetVersion { get; private set; } + + /// + /// Gets rule groups of the managed rule set. + /// + [JsonProperty(PropertyName = "properties.ruleGroups")] + public IList RuleGroups { get; private set; } + + /// + /// Gets or sets the pricing tier (defines a CDN provider, feature list + /// and rate) of the CdnWebApplicationFirewallPolicy. + /// + [JsonProperty(PropertyName = "sku")] + public Sku Sku { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSetList.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSetList.cs new file mode 100644 index 0000000000000..a7738658376fd --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ManagedRuleSetList.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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the list of managed rule sets for the policy. + /// + public partial class ManagedRuleSetList + { + /// + /// Initializes a new instance of the ManagedRuleSetList class. + /// + public ManagedRuleSetList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagedRuleSetList class. + /// + /// List of rule sets. + public ManagedRuleSetList(IList managedRuleSets = default(IList)) + { + ManagedRuleSets = managedRuleSets; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of rule sets. + /// + [JsonProperty(PropertyName = "managedRuleSets")] + public IList ManagedRuleSets { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchCondition.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchCondition.cs new file mode 100644 index 0000000000000..211e39fad7677 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchCondition.cs @@ -0,0 +1,131 @@ +// +// 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; + + /// + /// Define match conditions + /// + public partial class MatchCondition + { + /// + /// Initializes a new instance of the MatchCondition class. + /// + public MatchCondition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MatchCondition class. + /// + /// Match variable to compare against. + /// Possible values include: 'RemoteAddr', 'SocketAddr', + /// 'RequestMethod', 'RequestHeader', 'RequestUri', 'QueryString', + /// 'RequestBody', 'Cookies', 'PostArgs' + /// Describes operator to be matched. + /// Possible values include: 'Any', 'IPMatch', 'GeoMatch', 'Equal', + /// 'Contains', 'LessThan', 'GreaterThan', 'LessThanOrEqual', + /// 'GreaterThanOrEqual', 'BeginsWith', 'EndsWith', 'RegEx' + /// List of possible match values. + /// Selector can used to match a specific key + /// for QueryString, Cookies, RequestHeader or PostArgs. + /// Describes if the result of this + /// condition should be negated. + /// List of transforms. + public MatchCondition(string matchVariable, string operatorProperty, IList matchValue, string selector = default(string), bool? negateCondition = default(bool?), IList transforms = default(IList)) + { + MatchVariable = matchVariable; + Selector = selector; + OperatorProperty = operatorProperty; + NegateCondition = negateCondition; + MatchValue = matchValue; + Transforms = transforms; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets match variable to compare against. Possible values + /// include: 'RemoteAddr', 'SocketAddr', 'RequestMethod', + /// 'RequestHeader', 'RequestUri', 'QueryString', 'RequestBody', + /// 'Cookies', 'PostArgs' + /// + [JsonProperty(PropertyName = "matchVariable")] + public string MatchVariable { get; set; } + + /// + /// Gets or sets selector can used to match a specific key for + /// QueryString, Cookies, RequestHeader or PostArgs. + /// + [JsonProperty(PropertyName = "selector")] + public string Selector { get; set; } + + /// + /// Gets or sets describes operator to be matched. Possible values + /// include: 'Any', 'IPMatch', 'GeoMatch', 'Equal', 'Contains', + /// 'LessThan', 'GreaterThan', 'LessThanOrEqual', 'GreaterThanOrEqual', + /// 'BeginsWith', 'EndsWith', 'RegEx' + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets describes if the result of this condition should be + /// negated. + /// + [JsonProperty(PropertyName = "negateCondition")] + public bool? NegateCondition { get; set; } + + /// + /// Gets or sets list of possible match values. + /// + [JsonProperty(PropertyName = "matchValue")] + public IList MatchValue { get; set; } + + /// + /// Gets or sets list of transforms. + /// + [JsonProperty(PropertyName = "transforms")] + public IList Transforms { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (MatchVariable == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MatchVariable"); + } + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (MatchValue == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MatchValue"); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchVariable.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchVariable.cs new file mode 100644 index 0000000000000..41075c8d9d177 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/MatchVariable.cs @@ -0,0 +1,29 @@ +// +// 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 MatchVariable. + /// + public static class MatchVariable + { + public const string RemoteAddr = "RemoteAddr"; + public const string SocketAddr = "SocketAddr"; + public const string RequestMethod = "RequestMethod"; + public const string RequestHeader = "RequestHeader"; + public const string RequestUri = "RequestUri"; + public const string QueryString = "QueryString"; + public const string RequestBody = "RequestBody"; + public const string Cookies = "Cookies"; + public const string PostArgs = "PostArgs"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OperatorModel.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OperatorModel.cs new file mode 100644 index 0000000000000..2d41e739271d6 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/OperatorModel.cs @@ -0,0 +1,32 @@ +// +// 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 OperatorModel. + /// + public static class OperatorModel + { + public const string Any = "Any"; + public const string IPMatch = "IPMatch"; + public const string GeoMatch = "GeoMatch"; + public const string Equal = "Equal"; + public const string Contains = "Contains"; + public const string LessThan = "LessThan"; + public const string GreaterThan = "GreaterThan"; + public const string LessThanOrEqual = "LessThanOrEqual"; + public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string BeginsWith = "BeginsWith"; + public const string EndsWith = "EndsWith"; + public const string RegEx = "RegEx"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyEnabledState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyEnabledState.cs new file mode 100644 index 0000000000000..c1cf0d5205025 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyEnabledState.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 PolicyEnabledState. + /// + public static class PolicyEnabledState + { + public const string Disabled = "Disabled"; + public const string Enabled = "Enabled"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyMode.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyMode.cs new file mode 100644 index 0000000000000..44260954868c4 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyMode.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 PolicyMode. + /// + public static class PolicyMode + { + public const string Prevention = "Prevention"; + public const string Detection = "Detection"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyResourceState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyResourceState.cs new file mode 100644 index 0000000000000..4ee843e50f7cc --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicyResourceState.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 PolicyResourceState. + /// + public static class PolicyResourceState + { + public const string Creating = "Creating"; + public const string Enabling = "Enabling"; + public const string Enabled = "Enabled"; + public const string Disabling = "Disabling"; + public const string Disabled = "Disabled"; + public const string Deleting = "Deleting"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicySettings.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicySettings.cs new file mode 100644 index 0000000000000..93c3e141f6f60 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/PolicySettings.cs @@ -0,0 +1,115 @@ +// +// 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 contents of a web application firewall global configuration + /// + public partial class PolicySettings + { + /// + /// Initializes a new instance of the PolicySettings class. + /// + public PolicySettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PolicySettings class. + /// + /// describes if the policy is in enabled + /// state or disabled state. Possible values include: 'Disabled', + /// 'Enabled' + /// Describes if it is in detection mode or + /// prevention mode at policy level. Possible values include: + /// 'Prevention', 'Detection' + /// If action type is redirect, this + /// field represents the default redirect URL for the client. + /// If the action + /// type is block, this field defines the default customer overridable + /// http response status code. + /// If the action type is + /// block, customer can override the response body. The body must be + /// specified in base64 encoding. + public PolicySettings(string enabledState = default(string), string mode = default(string), string defaultRedirectUrl = default(string), int? defaultCustomBlockResponseStatusCode = default(int?), string defaultCustomBlockResponseBody = default(string)) + { + EnabledState = enabledState; + Mode = mode; + DefaultRedirectUrl = defaultRedirectUrl; + DefaultCustomBlockResponseStatusCode = defaultCustomBlockResponseStatusCode; + DefaultCustomBlockResponseBody = defaultCustomBlockResponseBody; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets describes if the policy is in enabled state or + /// disabled state. Possible values include: 'Disabled', 'Enabled' + /// + [JsonProperty(PropertyName = "enabledState")] + public string EnabledState { get; set; } + + /// + /// Gets or sets describes if it is in detection mode or prevention + /// mode at policy level. Possible values include: 'Prevention', + /// 'Detection' + /// + [JsonProperty(PropertyName = "mode")] + public string Mode { get; set; } + + /// + /// Gets or sets if action type is redirect, this field represents the + /// default redirect URL for the client. + /// + [JsonProperty(PropertyName = "defaultRedirectUrl")] + public string DefaultRedirectUrl { get; set; } + + /// + /// Gets or sets if the action type is block, this field defines the + /// default customer overridable http response status code. + /// + [JsonProperty(PropertyName = "defaultCustomBlockResponseStatusCode")] + public int? DefaultCustomBlockResponseStatusCode { get; set; } + + /// + /// Gets or sets if the action type is block, customer can override the + /// response body. The body must be specified in base64 encoding. + /// + [JsonProperty(PropertyName = "defaultCustomBlockResponseBody")] + public string DefaultCustomBlockResponseBody { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DefaultCustomBlockResponseBody != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(DefaultCustomBlockResponseBody, "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$")) + { + throw new ValidationException(ValidationRules.Pattern, "DefaultCustomBlockResponseBody", "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$"); + } + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ProvisioningState.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 0000000000000..9521ef36ce6c8 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/ProvisioningState.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 ProvisioningState. + /// + public static class ProvisioningState + { + public const string Creating = "Creating"; + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RateLimitRule.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RateLimitRule.cs new file mode 100644 index 0000000000000..e59b1af80c92f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RateLimitRule.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 Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines a rate limiting rule that can be included in a waf policy + /// + public partial class RateLimitRule : CustomRule + { + /// + /// Initializes a new instance of the RateLimitRule class. + /// + public RateLimitRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RateLimitRule class. + /// + /// Defines the name of the custom rule + /// Defines in what order this rule be evaluated + /// in the overall list of custom rules + /// List of match conditions. + /// Describes what action to be applied when rule + /// matches. Possible values include: 'Allow', 'Block', 'Log', + /// 'Redirect' + /// Defines rate limit + /// threshold. + /// Defines rate limit + /// duration. Default is 1 minute. + /// Describes if the custom rule is in + /// enabled or disabled state. Defaults to Enabled if not specified. + /// Possible values include: 'Disabled', 'Enabled' + public RateLimitRule(string name, int priority, IList matchConditions, string action, int rateLimitThreshold, int rateLimitDurationInMinutes, string enabledState = default(string)) + : base(name, priority, matchConditions, action, enabledState) + { + RateLimitThreshold = rateLimitThreshold; + RateLimitDurationInMinutes = rateLimitDurationInMinutes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets defines rate limit threshold. + /// + [JsonProperty(PropertyName = "rateLimitThreshold")] + public int RateLimitThreshold { get; set; } + + /// + /// Gets or sets defines rate limit duration. Default is 1 minute. + /// + [JsonProperty(PropertyName = "rateLimitDurationInMinutes")] + public int RateLimitDurationInMinutes { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (RateLimitThreshold < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "RateLimitThreshold", 0); + } + if (RateLimitDurationInMinutes > 60) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "RateLimitDurationInMinutes", 60); + } + if (RateLimitDurationInMinutes < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "RateLimitDurationInMinutes", 0); + } + } + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RateLimitRuleList.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RateLimitRuleList.cs new file mode 100644 index 0000000000000..a2a85ba8ebe48 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/RateLimitRuleList.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.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines contents of rate limit rules + /// + public partial class RateLimitRuleList + { + /// + /// Initializes a new instance of the RateLimitRuleList class. + /// + public RateLimitRuleList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RateLimitRuleList class. + /// + /// List of rules + public RateLimitRuleList(IList rules = default(IList)) + { + Rules = rules; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of rules + /// + [JsonProperty(PropertyName = "rules")] + public IList Rules { get; set; } + + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/TransformType.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/TransformType.cs new file mode 100644 index 0000000000000..a744473feefa2 --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/Models/TransformType.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 TransformType. + /// + public static class TransformType + { + public const string Lowercase = "Lowercase"; + public const string Uppercase = "Uppercase"; + public const string Trim = "Trim"; + public const string UrlDecode = "UrlDecode"; + public const string UrlEncode = "UrlEncode"; + public const string RemoveNulls = "RemoveNulls"; + } +} diff --git a/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperations.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperations.cs new file mode 100644 index 0000000000000..1c9e6902f3b4f --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperations.cs @@ -0,0 +1,1396 @@ +// +// 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; + + /// + /// PoliciesOperations operations. + /// + internal partial class PoliciesOperations : IServiceOperations, IPoliciesOperations + { + /// + /// Initializes a new instance of the PoliciesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PoliciesOperations(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 protection policies within a resource group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// 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>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 80) + { + 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, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); + } + } + 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("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", 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/CdnWebApplicationFirewallPolicies").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Retrieve protection policy with specified name within a resource group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// 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 policyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 80) + { + 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, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); + } + } + if (policyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyName"); + } + if (policyName != null) + { + if (policyName.Length > 128) + { + throw new ValidationException(ValidationRules.MaxLength, "policyName", 128); + } + } + 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("policyName", policyName); + 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/CdnWebApplicationFirewallPolicies/{policyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{policyName}", System.Uri.EscapeDataString(policyName)); + _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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Create or update policy with specified rule set name within a resource + /// group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, policyName, cdnWebApplicationFirewallPolicy, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the specified + /// policy name under the specified subscription and resource group + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string policyName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, policyName, tags, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes Policy + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string policyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 80) + { + 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, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); + } + } + if (policyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyName"); + } + if (policyName != null) + { + if (policyName.Length > 128) + { + throw new ValidationException(ValidationRules.MaxLength, "policyName", 128); + } + } + 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("policyName", policyName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", 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/CdnWebApplicationFirewallPolicies/{policyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{policyName}", System.Uri.EscapeDataString(policyName)); + _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 CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + 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; + } + + /// + /// Create or update policy with specified rule set name within a resource + /// group. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 80) + { + 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, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); + } + } + if (policyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyName"); + } + if (policyName != null) + { + if (policyName.Length > 128) + { + throw new ValidationException(ValidationRules.MaxLength, "policyName", 128); + } + } + 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 (cdnWebApplicationFirewallPolicy == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "cdnWebApplicationFirewallPolicy"); + } + if (cdnWebApplicationFirewallPolicy != null) + { + cdnWebApplicationFirewallPolicy.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("policyName", policyName); + tracingParameters.Add("cdnWebApplicationFirewallPolicy", cdnWebApplicationFirewallPolicy); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", 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/CdnWebApplicationFirewallPolicies/{policyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{policyName}", System.Uri.EscapeDataString(policyName)); + _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(cdnWebApplicationFirewallPolicy != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(cdnWebApplicationFirewallPolicy, 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 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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); + } + } + // 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; + } + + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the specified + /// policy name under the specified subscription and resource group + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + /// + /// 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 policyName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 80) + { + 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, "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[a-zA-Z0-9_\\-\\(\\)\\.]*[^\\.]$"); + } + } + if (policyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "policyName"); + } + if (policyName != null) + { + if (policyName.Length > 128) + { + throw new ValidationException(ValidationRules.MaxLength, "policyName", 128); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + CdnWebApplicationFirewallPolicyPatchParameters cdnWebApplicationFirewallPolicyPatchParameters = new CdnWebApplicationFirewallPolicyPatchParameters(); + if (tags != null) + { + cdnWebApplicationFirewallPolicyPatchParameters.Tags = tags; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("policyName", policyName); + tracingParameters.Add("cdnWebApplicationFirewallPolicyPatchParameters", cdnWebApplicationFirewallPolicyPatchParameters); + 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/CdnWebApplicationFirewallPolicies/{policyName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{policyName}", System.Uri.EscapeDataString(policyName)); + _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(cdnWebApplicationFirewallPolicyPatchParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(cdnWebApplicationFirewallPolicyPatchParameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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; + } + + /// + /// Lists all of the protection policies within a resource 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>> ListNextWithHttpMessagesAsync(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, "ListNext", 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _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/PoliciesOperationsExtensions.cs b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperationsExtensions.cs new file mode 100644 index 0000000000000..8975dd872ba9b --- /dev/null +++ b/sdk/cdn/Microsoft.Azure.Management.Cdn/src/Generated/PoliciesOperationsExtensions.cs @@ -0,0 +1,364 @@ +// +// 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 PoliciesOperations. + /// + public static partial class PoliciesOperationsExtensions + { + /// + /// Lists all of the protection policies within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + public static IPage List(this IPoliciesOperations operations, string resourceGroupName) + { + return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the protection policies within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPoliciesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve protection policy with specified name within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + public static CdnWebApplicationFirewallPolicy Get(this IPoliciesOperations operations, string resourceGroupName, string policyName) + { + return operations.GetAsync(resourceGroupName, policyName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve protection policy with specified name within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPoliciesOperations operations, string resourceGroupName, string policyName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, policyName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update policy with specified rule set name within a resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + public static CdnWebApplicationFirewallPolicy CreateOrUpdate(this IPoliciesOperations operations, string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy) + { + return operations.CreateOrUpdateAsync(resourceGroupName, policyName, cdnWebApplicationFirewallPolicy).GetAwaiter().GetResult(); + } + + /// + /// Create or update policy with specified rule set name within a resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPoliciesOperations operations, string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, policyName, cdnWebApplicationFirewallPolicy, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the specified + /// policy name under the specified subscription and resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + public static CdnWebApplicationFirewallPolicy Update(this IPoliciesOperations operations, string resourceGroupName, string policyName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, policyName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the specified + /// policy name under the specified subscription and resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPoliciesOperations operations, string resourceGroupName, string policyName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, policyName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes Policy + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + public static void Delete(this IPoliciesOperations operations, string resourceGroupName, string policyName) + { + operations.DeleteAsync(resourceGroupName, policyName).GetAwaiter().GetResult(); + } + + /// + /// Deletes Policy + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPoliciesOperations operations, string resourceGroupName, string policyName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, policyName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create or update policy with specified rule set name within a resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + public static CdnWebApplicationFirewallPolicy BeginCreateOrUpdate(this IPoliciesOperations operations, string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, policyName, cdnWebApplicationFirewallPolicy).GetAwaiter().GetResult(); + } + + /// + /// Create or update policy with specified rule set name within a resource + /// group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// Policy to be created. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPoliciesOperations operations, string resourceGroupName, string policyName, CdnWebApplicationFirewallPolicy cdnWebApplicationFirewallPolicy, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, policyName, cdnWebApplicationFirewallPolicy, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the specified + /// policy name under the specified subscription and resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + public static CdnWebApplicationFirewallPolicy BeginUpdate(this IPoliciesOperations operations, string resourceGroupName, string policyName, IDictionary tags = default(IDictionary)) + { + return operations.BeginUpdateAsync(resourceGroupName, policyName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update an existing CdnWebApplicationFirewallPolicy with the specified + /// policy name under the specified subscription and resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the Resource group within the Azure subscription. + /// + /// + /// The name of the CdnWebApplicationFirewallPolicy. + /// + /// + /// CdnWebApplicationFirewallPolicy tags + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IPoliciesOperations operations, string resourceGroupName, string policyName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, policyName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all of the protection policies within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IPoliciesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the protection policies within a resource 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> ListNextAsync(this IPoliciesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(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 fb13a771d0bfb..a1e95e0878ec9 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,29 +19,20 @@ public static IEnumerable> ApiInfo_CdnManagementCl { return new Tuple[] { - new Tuple("Cdn", "CheckNameAvailability", "2019-04-15"), - new Tuple("Cdn", "CheckNameAvailabilityWithSubscription", "2019-04-15"), - new Tuple("Cdn", "CustomDomains", "2019-04-15"), - new Tuple("Cdn", "EdgeNodes", "2019-04-15"), - new Tuple("Cdn", "Endpoints", "2019-04-15"), - new Tuple("Cdn", "Operations", "2019-04-15"), - new Tuple("Cdn", "Origins", "2019-04-15"), - new Tuple("Cdn", "Profiles", "2019-04-15"), - new Tuple("Cdn", "ResourceUsage", "2019-04-15"), - new Tuple("Cdn", "ValidateProbe", "2019-04-15"), + new Tuple("Cdn", "CheckNameAvailability", "2019-06-15"), + new Tuple("Cdn", "CheckNameAvailabilityWithSubscription", "2019-06-15"), + new Tuple("Cdn", "CustomDomains", "2019-06-15"), + new Tuple("Cdn", "EdgeNodes", "2019-06-15"), + new Tuple("Cdn", "Endpoints", "2019-06-15"), + new Tuple("Cdn", "ManagedRuleSets", "2019-06-15"), + new Tuple("Cdn", "Operations", "2019-06-15"), + new Tuple("Cdn", "Origins", "2019-06-15"), + new Tuple("Cdn", "Policies", "2019-06-15"), + new Tuple("Cdn", "Profiles", "2019-06-15"), + new Tuple("Cdn", "ResourceUsage", "2019-06-15"), + new Tuple("Cdn", "ValidateProbe", "2019-06-15"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "latest"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4407"; - 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=latest --reflect-api-versions --tag=package-2019-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 = "5e95a31678db88b8405e189df4aad8f9e9a24c45"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } -