diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ActiveConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ActiveConfigurationsOperations.cs new file mode 100644 index 0000000000000..1769ef59475a9 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ActiveConfigurationsOperations.cs @@ -0,0 +1,457 @@ +// +// 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.Network +{ + 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; + + /// + /// ActiveConfigurationsOperations operations. + /// + internal partial class ActiveConfigurationsOperations : IServiceOperations, IActiveConfigurationsOperations + { + /// + /// Initializes a new instance of the ActiveConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ActiveConfigurationsOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Lists active configurations in a network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// Location name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), string region = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("region", region); + 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.Network/networkManagers/{networkManagerName}/activeConfigurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (region != null) + { + _queryParameters.Add(string.Format("region={0}", System.Uri.EscapeDataString(region))); + } + 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 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(); + } + // 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 active configurations in a network manager. + /// + /// + /// 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 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/ActiveConfigurationsOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ActiveConfigurationsOperationsExtensions.cs new file mode 100644 index 0000000000000..f8510a3874b61 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ActiveConfigurationsOperationsExtensions.cs @@ -0,0 +1,125 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ActiveConfigurationsOperations. + /// + public static partial class ActiveConfigurationsOperationsExtensions + { + /// + /// Lists active configurations in a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// Location name + /// + public static IPage List(this IActiveConfigurationsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), string region = default(string)) + { + return operations.ListAsync(resourceGroupName, networkManagerName, top, skipToken, region).GetAwaiter().GetResult(); + } + + /// + /// Lists active configurations in a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// Location name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IActiveConfigurationsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), string region = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkManagerName, top, skipToken, region, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists active configurations in a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IActiveConfigurationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists active configurations in a network manager. + /// + /// + /// 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 IActiveConfigurationsOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/AdminRulesOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/AdminRulesOperations.cs new file mode 100644 index 0000000000000..c4e6aaf6871d8 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/AdminRulesOperations.cs @@ -0,0 +1,1109 @@ +// +// 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.Network +{ + 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; + + /// + /// AdminRulesOperations operations. + /// + internal partial class AdminRulesOperations : IServiceOperations, IAdminRulesOperations + { + /// + /// Initializes a new instance of the AdminRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AdminRulesOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/adminRules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a network manager security configuration admin rule in a subscription. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/adminRules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an admin rule. + /// + /// + /// The admin rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(AdminRule adminRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (adminRule == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "adminRule"); + } + if (adminRule != null) + { + adminRule.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("adminRule", adminRule); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/adminRules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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(adminRule != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(adminRule, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an admin rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("ruleName", ruleName); + 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/adminRules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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; + } + + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// 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 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/AdminRulesOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/AdminRulesOperationsExtensions.cs new file mode 100644 index 0000000000000..78a38925efd12 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/AdminRulesOperationsExtensions.cs @@ -0,0 +1,284 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AdminRulesOperations. + /// + public static partial class AdminRulesOperationsExtensions + { + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this IAdminRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, networkManagerName, configurationName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IAdminRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a network manager security configuration admin rule in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + public static AdminRule Get(this IAdminRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName) + { + return operations.GetAsync(resourceGroupName, networkManagerName, configurationName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Gets a network manager security configuration admin rule in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAdminRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an admin rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The admin rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + public static AdminRule CreateOrUpdate(this IAdminRulesOperations operations, AdminRule adminRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName) + { + return operations.CreateOrUpdateAsync(adminRule, resourceGroupName, networkManagerName, configurationName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an admin rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The admin rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IAdminRulesOperations operations, AdminRule adminRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(adminRule, resourceGroupName, networkManagerName, configurationName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an admin rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + public static void Delete(this IAdminRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName) + { + operations.DeleteAsync(resourceGroupName, networkManagerName, configurationName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an admin rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAdminRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IAdminRulesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// 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 IAdminRulesOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/ConnectivityConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ConnectivityConfigurationsOperations.cs new file mode 100644 index 0000000000000..08b672546e7d0 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ConnectivityConfigurationsOperations.cs @@ -0,0 +1,1078 @@ +// +// 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.Network +{ + 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; + + /// + /// ConnectivityConfigurationsOperations operations. + /// + internal partial class ConnectivityConfigurationsOperations : IServiceOperations, IConnectivityConfigurationsOperations + { + /// + /// Initializes a new instance of the ConnectivityConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ConnectivityConfigurationsOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Gets a Network Connectivity Configuration, specified by the resource group, + /// network manager name, and connectivity Configuration name + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + 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.Network/networkManagers/{networkManagerName}/connectivityConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates/Updates a new network manager connectivity configuration + /// + /// + /// Parameters supplied to create/update a network manager connectivity + /// configuration + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(ConnectivityConfiguration connectivityConfiguration, string resourceGroupName, string networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (connectivityConfiguration == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "connectivityConfiguration"); + } + if (connectivityConfiguration != null) + { + connectivityConfiguration.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("connectivityConfiguration", connectivityConfiguration); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Network/networkManagers/{networkManagerName}/connectivityConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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(connectivityConfiguration != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(connectivityConfiguration, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a network manager connectivity configuration, specified by the + /// resource group, network manager name, and connectivity configuration name + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + 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.Network/networkManagers/{networkManagerName}/connectivityConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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; + } + + /// + /// Lists all the network manager connectivity configuration in a specified + /// network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + 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.Network/networkManagers/{networkManagerName}/connectivityConfigurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // 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 the network manager connectivity configuration in a specified + /// network manager. + /// + /// + /// 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 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/ConnectivityConfigurationsOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ConnectivityConfigurationsOperationsExtensions.cs new file mode 100644 index 0000000000000..4985d5567c8e2 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ConnectivityConfigurationsOperationsExtensions.cs @@ -0,0 +1,270 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ConnectivityConfigurationsOperations. + /// + public static partial class ConnectivityConfigurationsOperationsExtensions + { + /// + /// Gets a Network Connectivity Configuration, specified by the resource group, + /// network manager name, and connectivity Configuration name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + public static ConnectivityConfiguration Get(this IConnectivityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName) + { + return operations.GetAsync(resourceGroupName, networkManagerName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Gets a Network Connectivity Configuration, specified by the resource group, + /// network manager name, and connectivity Configuration name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IConnectivityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates/Updates a new network manager connectivity configuration + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to create/update a network manager connectivity + /// configuration + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + public static ConnectivityConfiguration CreateOrUpdate(this IConnectivityConfigurationsOperations operations, ConnectivityConfiguration connectivityConfiguration, string resourceGroupName, string networkManagerName, string configurationName) + { + return operations.CreateOrUpdateAsync(connectivityConfiguration, resourceGroupName, networkManagerName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Creates/Updates a new network manager connectivity configuration + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to create/update a network manager connectivity + /// configuration + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IConnectivityConfigurationsOperations operations, ConnectivityConfiguration connectivityConfiguration, string resourceGroupName, string networkManagerName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(connectivityConfiguration, resourceGroupName, networkManagerName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a network manager connectivity configuration, specified by the + /// resource group, network manager name, and connectivity configuration name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + public static void Delete(this IConnectivityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName) + { + operations.DeleteAsync(resourceGroupName, networkManagerName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a network manager connectivity configuration, specified by the + /// resource group, network manager name, and connectivity configuration name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IConnectivityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all the network manager connectivity configuration in a specified + /// network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this IConnectivityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, networkManagerName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Lists all the network manager connectivity configuration in a specified + /// network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IConnectivityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkManagerName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all the network manager connectivity configuration in a specified + /// network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IConnectivityConfigurationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the network manager connectivity configuration in a specified + /// network manager. + /// + /// + /// 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 IConnectivityConfigurationsOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveConfigurationsOperations.cs new file mode 100644 index 0000000000000..8aad6a43e33ae --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveConfigurationsOperations.cs @@ -0,0 +1,449 @@ +// +// 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.Network +{ + 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; + + /// + /// EffectiveConfigurationsOperations operations. + /// + internal partial class EffectiveConfigurationsOperations : IServiceOperations, IEffectiveConfigurationsOperations + { + /// + /// Initializes a new instance of the EffectiveConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal EffectiveConfigurationsOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// List all configurations in a virtual network. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the virtual network. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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, string virtualNetworkName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (virtualNetworkName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("virtualNetworkName", virtualNetworkName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + 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.Network/virtualNetworks/{virtualNetworkName}/networkManagerEffectiveConfigurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // 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; + } + + /// + /// List all configurations in a virtual network. + /// + /// + /// 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 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveConfigurationsOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveConfigurationsOperationsExtensions.cs new file mode 100644 index 0000000000000..7eabc5cc28ab7 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveConfigurationsOperationsExtensions.cs @@ -0,0 +1,119 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for EffectiveConfigurationsOperations. + /// + public static partial class EffectiveConfigurationsOperationsExtensions + { + /// + /// List all configurations in a virtual network. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the virtual network. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this IEffectiveConfigurationsOperations operations, string resourceGroupName, string virtualNetworkName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, virtualNetworkName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// List all configurations in a virtual network. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the virtual network. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IEffectiveConfigurationsOperations operations, string resourceGroupName, string virtualNetworkName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all configurations in a virtual network. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IEffectiveConfigurationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all configurations in a virtual network. + /// + /// + /// 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 IEffectiveConfigurationsOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveVirtualNetworksOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveVirtualNetworksOperations.cs new file mode 100644 index 0000000000000..c8746d1be3e07 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveVirtualNetworksOperations.cs @@ -0,0 +1,863 @@ +// +// 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.Network +{ + 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; + + /// + /// EffectiveVirtualNetworksOperations operations. + /// + internal partial class EffectiveVirtualNetworksOperations : IServiceOperations, IEffectiveVirtualNetworksOperations + { + /// + /// Initializes a new instance of the EffectiveVirtualNetworksOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal EffectiveVirtualNetworksOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// List effective virtual networks in a network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// Effective Virtual Networks Parameter. + /// + /// + /// 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>> ListByNetworkManagerWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), EffectiveVirtualNetworksParameter parameters = default(EffectiveVirtualNetworksParameter), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByNetworkManager", 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.Network/networkManagers/{networkManagerName}/listEffectiveVirtualNetworks").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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 effective virtual networks by specified network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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>> ListByNetworkGroupWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string networkGroupName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (networkGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkGroupName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("networkGroupName", networkGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByNetworkGroup", 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.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}/listEffectiveVirtualNetworks").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{networkGroupName}", System.Uri.EscapeDataString(networkGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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; + } + + /// + /// List effective virtual networks in a network manager. + /// + /// + /// 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>> ListByNetworkManagerNextWithHttpMessagesAsync(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, "ListByNetworkManagerNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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 effective virtual networks by specified network 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>> ListByNetworkGroupNextWithHttpMessagesAsync(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, "ListByNetworkGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveVirtualNetworksOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveVirtualNetworksOperationsExtensions.cs new file mode 100644 index 0000000000000..281951b84aaa1 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/EffectiveVirtualNetworksOperationsExtensions.cs @@ -0,0 +1,225 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for EffectiveVirtualNetworksOperations. + /// + public static partial class EffectiveVirtualNetworksOperationsExtensions + { + /// + /// List effective virtual networks in a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// Effective Virtual Networks Parameter. + /// + public static IPage ListByNetworkManager(this IEffectiveVirtualNetworksOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), EffectiveVirtualNetworksParameter parameters = default(EffectiveVirtualNetworksParameter)) + { + return operations.ListByNetworkManagerAsync(resourceGroupName, networkManagerName, top, skipToken, parameters).GetAwaiter().GetResult(); + } + + /// + /// List effective virtual networks in a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// Effective Virtual Networks Parameter. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByNetworkManagerAsync(this IEffectiveVirtualNetworksOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), EffectiveVirtualNetworksParameter parameters = default(EffectiveVirtualNetworksParameter), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByNetworkManagerWithHttpMessagesAsync(resourceGroupName, networkManagerName, top, skipToken, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all effective virtual networks by specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage ListByNetworkGroup(this IEffectiveVirtualNetworksOperations operations, string resourceGroupName, string networkManagerName, string networkGroupName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListByNetworkGroupAsync(resourceGroupName, networkManagerName, networkGroupName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Lists all effective virtual networks by specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByNetworkGroupAsync(this IEffectiveVirtualNetworksOperations operations, string resourceGroupName, string networkManagerName, string networkGroupName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByNetworkGroupWithHttpMessagesAsync(resourceGroupName, networkManagerName, networkGroupName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List effective virtual networks in a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByNetworkManagerNext(this IEffectiveVirtualNetworksOperations operations, string nextPageLink) + { + return operations.ListByNetworkManagerNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List effective virtual networks in a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByNetworkManagerNextAsync(this IEffectiveVirtualNetworksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByNetworkManagerNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists all effective virtual networks by specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByNetworkGroupNext(this IEffectiveVirtualNetworksOperations operations, string nextPageLink) + { + return operations.ListByNetworkGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all effective virtual networks by specified network 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> ListByNetworkGroupNextAsync(this IEffectiveVirtualNetworksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByNetworkGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IActiveConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IActiveConfigurationsOperations.cs new file mode 100644 index 0000000000000..4d1d3f3b053e0 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IActiveConfigurationsOperations.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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ActiveConfigurationsOperations operations. + /// + public partial interface IActiveConfigurationsOperations + { + /// + /// Lists active configurations in a network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// Location name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), string region = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists active configurations in a network manager. + /// + /// + /// 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/network/Microsoft.Azure.Management.Network/src/Generated/IAdminRulesOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IAdminRulesOperations.cs new file mode 100644 index 0000000000000..07e79396ee3d0 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IAdminRulesOperations.cs @@ -0,0 +1,181 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AdminRulesOperations operations. + /// + public partial interface IAdminRulesOperations + { + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a network manager security configuration admin rule in a + /// subscription. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an admin rule. + /// + /// + /// The admin rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(AdminRule adminRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an admin rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a network manager security configuration admin rule. + /// + /// + /// 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/network/Microsoft.Azure.Management.Network/src/Generated/IConnectivityConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IConnectivityConfigurationsOperations.cs new file mode 100644 index 0000000000000..238d0e1b8e7f8 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IConnectivityConfigurationsOperations.cs @@ -0,0 +1,175 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ConnectivityConfigurationsOperations operations. + /// + public partial interface IConnectivityConfigurationsOperations + { + /// + /// Gets a Network Connectivity Configuration, specified by the + /// resource group, network manager name, and connectivity + /// Configuration name + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates/Updates a new network manager connectivity configuration + /// + /// + /// Parameters supplied to create/update a network manager connectivity + /// configuration + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// 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(ConnectivityConfiguration connectivityConfiguration, string resourceGroupName, string networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a network manager connectivity configuration, specified by + /// the resource group, network manager name, and connectivity + /// configuration name + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager connectivity configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the network manager connectivity configuration in a + /// specified network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the network manager connectivity configuration in a + /// specified network manager. + /// + /// + /// 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/network/Microsoft.Azure.Management.Network/src/Generated/IEffectiveConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IEffectiveConfigurationsOperations.cs new file mode 100644 index 0000000000000..144312d03bcbe --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IEffectiveConfigurationsOperations.cs @@ -0,0 +1,84 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EffectiveConfigurationsOperations operations. + /// + public partial interface IEffectiveConfigurationsOperations + { + /// + /// List all configurations in a virtual network. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the virtual network. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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, string virtualNetworkName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all configurations in a virtual network. + /// + /// + /// 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/network/Microsoft.Azure.Management.Network/src/Generated/IEffectiveVirtualNetworksOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IEffectiveVirtualNetworksOperations.cs new file mode 100644 index 0000000000000..41959031af2bc --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IEffectiveVirtualNetworksOperations.cs @@ -0,0 +1,147 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EffectiveVirtualNetworksOperations operations. + /// + public partial interface IEffectiveVirtualNetworksOperations + { + /// + /// List effective virtual networks in a network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// Effective Virtual Networks Parameter. + /// + /// + /// 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>> ListByNetworkManagerWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), EffectiveVirtualNetworksParameter parameters = default(EffectiveVirtualNetworksParameter), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all effective virtual networks by specified network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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>> ListByNetworkGroupWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string networkGroupName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List effective virtual networks in a network manager. + /// + /// + /// 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>> ListByNetworkManagerNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all effective virtual networks by specified network 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>> ListByNetworkGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkGroupsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkGroupsOperations.cs new file mode 100644 index 0000000000000..cfcf113ee4c4b --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkGroupsOperations.cs @@ -0,0 +1,174 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// NetworkGroupsOperations operations. + /// + public partial interface INetworkGroupsOperations + { + /// + /// Gets the specified network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// 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 networkManagerName, string networkGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a network group. + /// + /// + /// Parameters supplied to the specify which network group need to + /// create + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// The ETag of the transformation. Omit this value to always overwrite + /// the current resource. Specify the last-seen ETag value to prevent + /// accidentally overwriting concurrent changes. + /// + /// + /// 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(NetworkGroup parameters, string resourceGroupName, string networkManagerName, string networkGroupName, string ifMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// 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 networkManagerName, string networkGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the specified network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the specified network 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/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagementClient.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagementClient.cs index 180380243505a..2004c3dbc2752 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagementClient.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagementClient.cs @@ -295,6 +295,61 @@ public partial interface INetworkManagementClient : System.IDisposable /// INetworkInterfaceTapConfigurationsOperations NetworkInterfaceTapConfigurations { get; } + /// + /// Gets the INetworkManagersOperations. + /// + INetworkManagersOperations NetworkManagers { get; } + + /// + /// Gets the INetworkManagerCommitsOperations. + /// + INetworkManagerCommitsOperations NetworkManagerCommits { get; } + + /// + /// Gets the INetworkManagerDeploymentStatusOperations. + /// + INetworkManagerDeploymentStatusOperations NetworkManagerDeploymentStatus { get; } + + /// + /// Gets the IEffectiveVirtualNetworksOperations. + /// + IEffectiveVirtualNetworksOperations EffectiveVirtualNetworks { get; } + + /// + /// Gets the IActiveConfigurationsOperations. + /// + IActiveConfigurationsOperations ActiveConfigurations { get; } + + /// + /// Gets the IConnectivityConfigurationsOperations. + /// + IConnectivityConfigurationsOperations ConnectivityConfigurations { get; } + + /// + /// Gets the IEffectiveConfigurationsOperations. + /// + IEffectiveConfigurationsOperations EffectiveConfigurations { get; } + + /// + /// Gets the INetworkGroupsOperations. + /// + INetworkGroupsOperations NetworkGroups { get; } + + /// + /// Gets the ISecurityConfigurationsOperations. + /// + ISecurityConfigurationsOperations SecurityConfigurations { get; } + + /// + /// Gets the IAdminRulesOperations. + /// + IAdminRulesOperations AdminRules { get; } + + /// + /// Gets the IUserRulesOperations. + /// + IUserRulesOperations UserRules { get; } + /// /// Gets the INetworkProfilesOperations. /// diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagerCommitsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagerCommitsOperations.cs new file mode 100644 index 0000000000000..3e1953c21a527 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagerCommitsOperations.cs @@ -0,0 +1,52 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// NetworkManagerCommitsOperations operations. + /// + public partial interface INetworkManagerCommitsOperations + { + /// + /// Post a Network Manager Commit. + /// + /// + /// Parameters supplied to specify which Managed Network commit is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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 PostWithHttpMessagesAsync(NetworkManagerCommit parameters, string resourceGroupName, string networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagerDeploymentStatusOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagerDeploymentStatusOperations.cs new file mode 100644 index 0000000000000..6944a3e8bd6f0 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagerDeploymentStatusOperations.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// NetworkManagerDeploymentStatusOperations operations. + /// + public partial interface INetworkManagerDeploymentStatusOperations + { + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// Parameters supplied to specify which Managed Network deployment + /// status is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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(NetworkManagerDeploymentStatusParameter parameters, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// 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/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagersOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagersOperations.cs new file mode 100644 index 0000000000000..df3c60f9c203e --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/INetworkManagersOperations.cs @@ -0,0 +1,235 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// NetworkManagersOperations operations. + /// + public partial interface INetworkManagersOperations + { + /// + /// Gets the specified Network Manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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 networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a Network Manager. + /// + /// + /// Parameters supplied to specify which network manager is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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(NetworkManager parameters, string resourceGroupName, string networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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 networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Patch a NetworkManager Tags. + /// + /// + /// Parameters supplied to update network manager tags. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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> PatchTagsWithHttpMessagesAsync(TagsObject parameters, string resourceGroupName, string networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all network managers in a subscription. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List network managers in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all network managers in a subscription. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List network managers in 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/network/Microsoft.Azure.Management.Network/src/Generated/IPublicIpAddressesOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IPublicIPAddressesOperations.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/IPublicIpAddressesOperations.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/IPublicIPAddressesOperations.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ISecurityConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ISecurityConfigurationsOperations.cs new file mode 100644 index 0000000000000..680525b738c9c --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/ISecurityConfigurationsOperations.cs @@ -0,0 +1,264 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SecurityConfigurationsOperations operations. + /// + public partial interface ISecurityConfigurationsOperations + { + /// + /// Lists all the network manager security configurations in a network + /// manager, in a paginated format. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Imports network security rules to network manager security rules. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import Security configuration parameter + /// + /// + /// 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> ImportWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import security configuration parameter + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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>> EvaluateImportWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves a network manager security Configuration. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a network manager security Configuration. + /// + /// + /// The security configuration to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// 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(SecurityConfiguration securityConfiguration, string resourceGroupName, string networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a network manager security Configuration. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all the network manager security configurations in a network + /// manager, in a paginated format. + /// + /// + /// 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)); + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// 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>> EvaluateImportNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IUserRulesOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IUserRulesOperations.cs new file mode 100644 index 0000000000000..174717ab6cfe3 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IUserRulesOperations.cs @@ -0,0 +1,180 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// UserRulesOperations operations. + /// + public partial interface IUserRulesOperations + { + /// + /// Lists all user rules in a security configuration. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of + /// records to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial + /// result. If a previous response contains a nextLink element, the + /// value of the nextLink element will include a skipToken parameter + /// that specifies a starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a user rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates a user rule. + /// + /// + /// The user rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(UserRule userRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a user rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists all user rules in a security configuration. + /// + /// + /// 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/network/Microsoft.Azure.Management.Network/src/Generated/IVirtualWANsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/IVirtualWansOperations.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/IVirtualWANsOperations.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/IVirtualWansOperations.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ActiveConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ActiveConfiguration.cs new file mode 100644 index 0000000000000..25ae65bd2adbd --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ActiveConfiguration.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Active Configuration. + /// + public partial class ActiveConfiguration : EffectiveConfiguration + { + /// + /// Initializes a new instance of the ActiveConfiguration class. + /// + public ActiveConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ActiveConfiguration class. + /// + /// Effective configuration. Possible values + /// include: 'AdminPolicy', 'UserPolicy', 'Connectivity' + /// Connectivity configuration + /// object. + /// Security admin rule object. + /// Security user rule object. + /// Effective configuration + /// groups. + /// Deployment time string. + /// Deployment region. + public ActiveConfiguration(string configType = default(string), ConnectivityConfiguration connectivityConfiguration = default(ConnectivityConfiguration), AdminRule securityAdminRule = default(AdminRule), UserRule securityUserRule = default(UserRule), IList configurationGroups = default(IList), System.DateTime? commitTime = default(System.DateTime?), string region = default(string)) + : base(configType, connectivityConfiguration, securityAdminRule, securityUserRule, configurationGroups) + { + CommitTime = commitTime; + Region = region; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets deployment time string. + /// + [JsonProperty(PropertyName = "commitTime")] + public System.DateTime? CommitTime { get; set; } + + /// + /// Gets or sets deployment region. + /// + [JsonProperty(PropertyName = "region")] + public string Region { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AddressPrefixItem.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AddressPrefixItem.cs new file mode 100644 index 0000000000000..1874f1867c227 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AddressPrefixItem.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Address prefix item. + /// + public partial class AddressPrefixItem + { + /// + /// Initializes a new instance of the AddressPrefixItem class. + /// + public AddressPrefixItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AddressPrefixItem class. + /// + /// Address prefix. + /// Address prefix type. Possible + /// values include: 'IPPrefix', 'ServiceTag' + public AddressPrefixItem(string addressPrefix = default(string), string addressPrefixType = default(string)) + { + AddressPrefix = addressPrefix; + AddressPrefixType = addressPrefixType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets address prefix. + /// + [JsonProperty(PropertyName = "addressPrefix")] + public string AddressPrefix { get; set; } + + /// + /// Gets or sets address prefix type. Possible values include: + /// 'IPPrefix', 'ServiceTag' + /// + [JsonProperty(PropertyName = "addressPrefixType")] + public string AddressPrefixType { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AddressPrefixType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AddressPrefixType.cs new file mode 100644 index 0000000000000..c094c49264ca7 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AddressPrefixType.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.Network.Models +{ + + /// + /// Defines values for AddressPrefixType. + /// + public static class AddressPrefixType + { + public const string IPPrefix = "IPPrefix"; + public const string ServiceTag = "ServiceTag"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AdminRule.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AdminRule.cs new file mode 100644 index 0000000000000..1e55fd27276ee --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/AdminRule.cs @@ -0,0 +1,202 @@ +// +// 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.Network.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network admin rule. + /// + [Rest.Serialization.JsonTransformation] + public partial class AdminRule : ProxyResource + { + /// + /// Initializes a new instance of the AdminRule class. + /// + public AdminRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AdminRule class. + /// + /// Network protocol this rule applies to. + /// Possible values include: 'Tcp', 'Udp', 'Icmp', 'Esp', 'Any', + /// 'Ah' + /// Indicates the access allowed for this + /// particular rule. Possible values include: 'Allow', 'Deny', + /// 'AlwaysAllow' + /// Indicates if the traffic matched against + /// the rule in inbound or outbound. Possible values include: + /// 'Inbound', 'Outbound' + /// Resource ID. + /// Resource name. + /// Resource type. + /// A unique read-only string that changes whenever + /// the resource is updated. + /// A friendly name for the rule. + /// A description for this rule. + /// The CIDR or source IP ranges. + /// The destination address prefixes. CIDR or + /// destination IP ranges. + /// The source port ranges. + /// The destination port + /// ranges. + /// The priority of the rule. The value can be + /// between 1 and 4096. The priority number must be unique for each + /// rule in the collection. The lower the priority number, the higher + /// the priority of the rule. + /// The provisioning state of the + /// security Configuration resource. Possible values include: + /// 'Succeeded', 'Updating', 'Deleting', 'Failed' + /// Groups for configuration + /// The system metadata related to this + /// resource. + public AdminRule(string protocol, string access, string direction, string id = default(string), string name = default(string), string type = default(string), string etag = default(string), string displayName = default(string), string description = default(string), IList source = default(IList), IList destination = default(IList), IList sourcePortRanges = default(IList), IList destinationPortRanges = default(IList), int? priority = default(int?), string provisioningState = default(string), IList appliesToGroups = default(IList), SystemData systemData = default(SystemData)) + : base(id, name, type, etag) + { + DisplayName = displayName; + Description = description; + Protocol = protocol; + Source = source; + Destination = destination; + SourcePortRanges = sourcePortRanges; + DestinationPortRanges = destinationPortRanges; + Access = access; + Priority = priority; + Direction = direction; + ProvisioningState = provisioningState; + AppliesToGroups = appliesToGroups; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a friendly name for the rule. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets a description for this rule. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets network protocol this rule applies to. Possible values + /// include: 'Tcp', 'Udp', 'Icmp', 'Esp', 'Any', 'Ah' + /// + [JsonProperty(PropertyName = "properties.protocol")] + public string Protocol { get; set; } + + /// + /// Gets or sets the CIDR or source IP ranges. + /// + [JsonProperty(PropertyName = "properties.source")] + public IList Source { get; set; } + + /// + /// Gets or sets the destination address prefixes. CIDR or destination + /// IP ranges. + /// + [JsonProperty(PropertyName = "properties.destination")] + public IList Destination { get; set; } + + /// + /// Gets or sets the source port ranges. + /// + [JsonProperty(PropertyName = "properties.sourcePortRanges")] + public IList SourcePortRanges { get; set; } + + /// + /// Gets or sets the destination port ranges. + /// + [JsonProperty(PropertyName = "properties.destinationPortRanges")] + public IList DestinationPortRanges { get; set; } + + /// + /// Gets or sets indicates the access allowed for this particular rule. + /// Possible values include: 'Allow', 'Deny', 'AlwaysAllow' + /// + [JsonProperty(PropertyName = "properties.access")] + public string Access { get; set; } + + /// + /// Gets or sets the priority of the rule. The value can be between 1 + /// and 4096. The priority number must be unique for each rule in the + /// collection. The lower the priority number, the higher the priority + /// of the rule. + /// + [JsonProperty(PropertyName = "properties.priority")] + public int? Priority { get; set; } + + /// + /// Gets or sets indicates if the traffic matched against the rule in + /// inbound or outbound. Possible values include: 'Inbound', 'Outbound' + /// + [JsonProperty(PropertyName = "properties.direction")] + public string Direction { get; set; } + + /// + /// Gets the provisioning state of the security Configuration resource. + /// Possible values include: 'Succeeded', 'Updating', 'Deleting', + /// 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets groups for configuration + /// + [JsonProperty(PropertyName = "properties.appliesToGroups")] + public IList AppliesToGroups { get; set; } + + /// + /// Gets the system metadata related to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Protocol == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Protocol"); + } + if (Access == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Access"); + } + if (Direction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Direction"); + } + } + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayFrontendIpConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayFrontendIPConfiguration.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayFrontendIpConfiguration.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayFrontendIPConfiguration.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayIpConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayIPConfiguration.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayIpConfiguration.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ApplicationGatewayIPConfiguration.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/CommitType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/CommitType.cs new file mode 100644 index 0000000000000..773e81521b017 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/CommitType.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.Network.Models +{ + + /// + /// Defines values for CommitType. + /// + public static class CommitType + { + public const string AdminPolicy = "AdminPolicy"; + public const string UserPolicy = "UserPolicy"; + public const string Routing = "Routing"; + public const string Connectivity = "Connectivity"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConfigType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConfigType.cs new file mode 100644 index 0000000000000..6328f14fe8dc2 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConfigType.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.Network.Models +{ + + /// + /// Defines values for ConfigType. + /// + public static class ConfigType + { + public const string AdminPolicy = "AdminPolicy"; + public const string UserPolicy = "UserPolicy"; + public const string Connectivity = "Connectivity"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityConfiguration.cs new file mode 100644 index 0000000000000..f5b47405dd26b --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityConfiguration.cs @@ -0,0 +1,149 @@ +// +// 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.Network.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The network manager connectivity configuration resource + /// + [Rest.Serialization.JsonTransformation] + public partial class ConnectivityConfiguration : ProxyResource + { + /// + /// Initializes a new instance of the ConnectivityConfiguration class. + /// + public ConnectivityConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConnectivityConfiguration class. + /// + /// Connectivity topology type. + /// Possible values include: 'HubAndSpokeTopology', + /// 'MeshTopology' + /// Resource ID. + /// Resource name. + /// Resource type. + /// A unique read-only string that changes whenever + /// the resource is updated. + /// A friendly name for the resource. + /// A description of the connectivity + /// configuration. + /// The hub vnet Id. + /// Flag if global mesh is supported. + /// Groups for configuration + /// The provisioning state of the + /// connectivity configuration resource. Possible values include: + /// 'Succeeded', 'Updating', 'Deleting', 'Failed' + /// Flag if need to remove current + /// existing peerings. + /// The system metadata related to this + /// resource. + public ConnectivityConfiguration(string connectivityTopology, string id = default(string), string name = default(string), string type = default(string), string etag = default(string), string displayName = default(string), string description = default(string), string hubId = default(string), bool? isGlobal = default(bool?), IList appliesToGroups = default(IList), string provisioningState = default(string), bool? deleteExistingPeering = default(bool?), SystemData systemData = default(SystemData)) + : base(id, name, type, etag) + { + DisplayName = displayName; + Description = description; + ConnectivityTopology = connectivityTopology; + HubId = hubId; + IsGlobal = isGlobal; + AppliesToGroups = appliesToGroups; + ProvisioningState = provisioningState; + DeleteExistingPeering = deleteExistingPeering; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a friendly name for the resource. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets a description of the connectivity configuration. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets connectivity topology type. Possible values include: + /// 'HubAndSpokeTopology', 'MeshTopology' + /// + [JsonProperty(PropertyName = "properties.connectivityTopology")] + public string ConnectivityTopology { get; set; } + + /// + /// Gets or sets the hub vnet Id. + /// + [JsonProperty(PropertyName = "properties.hubId")] + public string HubId { get; set; } + + /// + /// Gets or sets flag if global mesh is supported. + /// + [JsonProperty(PropertyName = "properties.isGlobal")] + public bool? IsGlobal { get; set; } + + /// + /// Gets or sets groups for configuration + /// + [JsonProperty(PropertyName = "properties.appliesToGroups")] + public IList AppliesToGroups { get; set; } + + /// + /// Gets the provisioning state of the connectivity configuration + /// resource. Possible values include: 'Succeeded', 'Updating', + /// 'Deleting', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets flag if need to remove current existing peerings. + /// + [JsonProperty(PropertyName = "properties.deleteExistingPeering")] + public bool? DeleteExistingPeering { get; set; } + + /// + /// Gets the system metadata related to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ConnectivityTopology == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ConnectivityTopology"); + } + } + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityGroupItem.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityGroupItem.cs new file mode 100644 index 0000000000000..2fc3d891a1bec --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityGroupItem.cs @@ -0,0 +1,75 @@ +// +// 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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class ConnectivityGroupItem + { + /// + /// Initializes a new instance of the ConnectivityGroupItem class. + /// + public ConnectivityGroupItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ConnectivityGroupItem class. + /// + /// Network group Id. + /// Flag if need to use hub + /// gateway. + /// Flag if global is supported. + /// Group connectivity type. Possible + /// values include: 'None', 'DirectlyConnected' + public ConnectivityGroupItem(string networkGroupId = default(string), bool? useHubGateway = default(bool?), bool? isGlobal = default(bool?), string groupConnectivity = default(string)) + { + NetworkGroupId = networkGroupId; + UseHubGateway = useHubGateway; + IsGlobal = isGlobal; + GroupConnectivity = groupConnectivity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets network group Id. + /// + [JsonProperty(PropertyName = "networkGroupId")] + public string NetworkGroupId { get; set; } + + /// + /// Gets or sets flag if need to use hub gateway. + /// + [JsonProperty(PropertyName = "useHubGateway")] + public bool? UseHubGateway { get; set; } + + /// + /// Gets or sets flag if global is supported. + /// + [JsonProperty(PropertyName = "isGlobal")] + public bool? IsGlobal { get; set; } + + /// + /// Gets or sets group connectivity type. Possible values include: + /// 'None', 'DirectlyConnected' + /// + [JsonProperty(PropertyName = "groupConnectivity")] + public string GroupConnectivity { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityTopology.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityTopology.cs new file mode 100644 index 0000000000000..02a0a8272b420 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ConnectivityTopology.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.Network.Models +{ + + /// + /// Defines values for ConnectivityTopology. + /// + public static class ConnectivityTopology + { + public const string HubAndSpokeTopology = "HubAndSpokeTopology"; + public const string MeshTopology = "MeshTopology"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/CreatedByType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/CreatedByType.cs new file mode 100644 index 0000000000000..f360566a259fb --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/CreatedByType.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.Network.Models +{ + + /// + /// Defines values for CreatedByType. + /// + public static class CreatedByType + { + public const string User = "User"; + public const string Application = "Application"; + public const string ManagedIdentity = "ManagedIdentity"; + public const string Key = "Key"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Delegation.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Delegation.cs index 582412da8826a..f83b63c774aa5 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Delegation.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Delegation.cs @@ -46,7 +46,8 @@ public Delegation() /// subnet. This name can be used to access the resource. /// A unique read-only string that changes whenever /// the resource is updated. - public Delegation(string id = default(string), string serviceName = default(string), IList actions = default(IList), string provisioningState = default(string), string name = default(string), string etag = default(string)) + /// Resource type. + public Delegation(string id = default(string), string serviceName = default(string), IList actions = default(IList), string provisioningState = default(string), string name = default(string), string etag = default(string), string type = default(string)) : base(id) { ServiceName = serviceName; @@ -54,6 +55,7 @@ public Delegation() ProvisioningState = provisioningState; Name = name; Etag = etag; + Type = type; CustomInit(); } @@ -97,5 +99,11 @@ public Delegation() [JsonProperty(PropertyName = "etag")] public string Etag { get; private set; } + /// + /// Gets or sets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + } } diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/DeploymentStatus.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/DeploymentStatus.cs new file mode 100644 index 0000000000000..6386ef465c952 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/DeploymentStatus.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + + /// + /// Defines values for DeploymentStatus. + /// + public static class DeploymentStatus + { + public const string NotStarted = "NotStarted"; + public const string Deploying = "Deploying"; + public const string Deployed = "Deployed"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/DeploymentType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/DeploymentType.cs new file mode 100644 index 0000000000000..8bed0abc378e8 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/DeploymentType.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.Network.Models +{ + + /// + /// Defines values for DeploymentType. + /// + public static class DeploymentType + { + public const string AdminPolicy = "AdminPolicy"; + public const string UserPolicy = "UserPolicy"; + public const string Routing = "Routing"; + public const string Connectivity = "Connectivity"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveConfiguration.cs new file mode 100644 index 0000000000000..3ecf0bf2c568c --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveConfiguration.cs @@ -0,0 +1,110 @@ +// +// 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.Network.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The network manager effective configuration + /// + public partial class EffectiveConfiguration + { + /// + /// Initializes a new instance of the EffectiveConfiguration class. + /// + public EffectiveConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EffectiveConfiguration class. + /// + /// Effective configuration. Possible values + /// include: 'AdminPolicy', 'UserPolicy', 'Connectivity' + /// Connectivity configuration + /// object. + /// Security admin rule object. + /// Security user rule object. + /// Effective configuration + /// groups. + public EffectiveConfiguration(string configType = default(string), ConnectivityConfiguration connectivityConfiguration = default(ConnectivityConfiguration), AdminRule securityAdminRule = default(AdminRule), UserRule securityUserRule = default(UserRule), IList configurationGroups = default(IList)) + { + ConfigType = configType; + ConnectivityConfiguration = connectivityConfiguration; + SecurityAdminRule = securityAdminRule; + SecurityUserRule = securityUserRule; + ConfigurationGroups = configurationGroups; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets effective configuration. Possible values include: + /// 'AdminPolicy', 'UserPolicy', 'Connectivity' + /// + [JsonProperty(PropertyName = "configType")] + public string ConfigType { get; set; } + + /// + /// Gets or sets connectivity configuration object. + /// + [JsonProperty(PropertyName = "connectivityConfiguration")] + public ConnectivityConfiguration ConnectivityConfiguration { get; set; } + + /// + /// Gets or sets security admin rule object. + /// + [JsonProperty(PropertyName = "securityAdminRule")] + public AdminRule SecurityAdminRule { get; set; } + + /// + /// Gets or sets security user rule object. + /// + [JsonProperty(PropertyName = "securityUserRule")] + public UserRule SecurityUserRule { get; set; } + + /// + /// Gets or sets effective configuration groups. + /// + [JsonProperty(PropertyName = "configurationGroups")] + public IList ConfigurationGroups { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ConnectivityConfiguration != null) + { + ConnectivityConfiguration.Validate(); + } + if (SecurityAdminRule != null) + { + SecurityAdminRule.Validate(); + } + if (SecurityUserRule != null) + { + SecurityUserRule.Validate(); + } + } + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveVirtualNetwork.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveVirtualNetwork.cs new file mode 100644 index 0000000000000..4712f6cf0c389 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveVirtualNetwork.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Effective Virtual Network + /// + public partial class EffectiveVirtualNetwork + { + /// + /// Initializes a new instance of the EffectiveVirtualNetwork class. + /// + public EffectiveVirtualNetwork() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EffectiveVirtualNetwork class. + /// + /// Effective vnet Id. + /// Location of vnet. + /// Membership Type. Possible values + /// include: 'Static', 'Dynamic' + public EffectiveVirtualNetwork(string id = default(string), string location = default(string), string membershipType = default(string)) + { + Id = id; + Location = location; + MembershipType = membershipType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets effective vnet Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets location of vnet. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets membership Type. Possible values include: 'Static', + /// 'Dynamic' + /// + [JsonProperty(PropertyName = "membershipType")] + public string MembershipType { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveVirtualNetworksParameter.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveVirtualNetworksParameter.cs new file mode 100644 index 0000000000000..c8ef4a591ed44 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/EffectiveVirtualNetworksParameter.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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Effective Virtual Networks Parameter. + /// + public partial class EffectiveVirtualNetworksParameter + { + /// + /// Initializes a new instance of the EffectiveVirtualNetworksParameter + /// class. + /// + public EffectiveVirtualNetworksParameter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EffectiveVirtualNetworksParameter + /// class. + /// + /// Conditional Members. + public EffectiveVirtualNetworksParameter(string conditionalMembers = default(string)) + { + ConditionalMembers = conditionalMembers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets conditional Members. + /// + [JsonProperty(PropertyName = "conditionalMembers")] + public string ConditionalMembers { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/FailedImport.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/FailedImport.cs new file mode 100644 index 0000000000000..670ac026ac695 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/FailedImport.cs @@ -0,0 +1,59 @@ +// +// 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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Failed imports object. + /// + public partial class FailedImport + { + /// + /// Initializes a new instance of the FailedImport class. + /// + public FailedImport() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FailedImport class. + /// + /// Failure code. + /// Failure reason. + public FailedImport(string failureCode = default(string), string failureReason = default(string)) + { + FailureCode = failureCode; + FailureReason = failureReason; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets failure code. + /// + [JsonProperty(PropertyName = "failureCode")] + public string FailureCode { get; set; } + + /// + /// Gets or sets failure reason. + /// + [JsonProperty(PropertyName = "failureReason")] + public string FailureReason { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/FrontendIpConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/FrontendIPConfiguration.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/FrontendIpConfiguration.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/FrontendIPConfiguration.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/GroupConnectivity.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/GroupConnectivity.cs new file mode 100644 index 0000000000000..1887920ed5074 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/GroupConnectivity.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.Network.Models +{ + + /// + /// Defines values for GroupConnectivity. + /// + public static class GroupConnectivity + { + public const string None = "None"; + public const string DirectlyConnected = "DirectlyConnected"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/GroupMembersItem.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/GroupMembersItem.cs new file mode 100644 index 0000000000000..51e0ebe19d36c --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/GroupMembersItem.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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// GroupMembers Item. + /// + public partial class GroupMembersItem + { + /// + /// Initializes a new instance of the GroupMembersItem class. + /// + public GroupMembersItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GroupMembersItem class. + /// + /// Resource Id. + public GroupMembersItem(string resourceId = default(string)) + { + ResourceId = resourceId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource Id. + /// + [JsonProperty(PropertyName = "resourceId")] + public string ResourceId { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/IpAllocationMethod.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/IPAllocationMethod.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/IpAllocationMethod.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/IPAllocationMethod.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/MemberType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/MemberType.cs new file mode 100644 index 0000000000000..e390724e9e9b6 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/MemberType.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.Network.Models +{ + + /// + /// Defines values for MemberType. + /// + public static class MemberType + { + public const string VirtualNetwork = "VirtualNetwork"; + public const string Subnet = "Subnet"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/MembershipType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/MembershipType.cs new file mode 100644 index 0000000000000..4b0ba6401381b --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/MembershipType.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.Network.Models +{ + + /// + /// Defines values for MembershipType. + /// + public static class MembershipType + { + public const string Static = "Static"; + public const string Dynamic = "Dynamic"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkGroup.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkGroup.cs new file mode 100644 index 0000000000000..5b8198e2a5be4 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkGroup.cs @@ -0,0 +1,120 @@ +// +// 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.Network.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The network group resource + /// + [Rest.Serialization.JsonTransformation] + public partial class NetworkGroup : ProxyResource + { + /// + /// Initializes a new instance of the NetworkGroup class. + /// + public NetworkGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkGroup class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// A unique read-only string that changes whenever + /// the resource is updated. + /// A friendly name for the network + /// group. + /// A description of the network + /// group. + /// Group member type. Possible values + /// include: 'VirtualNetwork', 'Subnet' + /// Group members of network group. + /// Network group conditional + /// filter. + /// The provisioning state of the scope + /// assignment resource. Possible values include: 'Succeeded', + /// 'Updating', 'Deleting', 'Failed' + /// The system metadata related to this + /// resource. + public NetworkGroup(string id = default(string), string name = default(string), string type = default(string), string etag = default(string), string displayName = default(string), string description = default(string), string memberType = default(string), IList groupMembers = default(IList), string conditionalMembership = default(string), string provisioningState = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type, etag) + { + DisplayName = displayName; + Description = description; + MemberType = memberType; + GroupMembers = groupMembers; + ConditionalMembership = conditionalMembership; + ProvisioningState = provisioningState; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a friendly name for the network group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets a description of the network group. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets group member type. Possible values include: + /// 'VirtualNetwork', 'Subnet' + /// + [JsonProperty(PropertyName = "properties.memberType")] + public string MemberType { get; set; } + + /// + /// Gets or sets group members of network group. + /// + [JsonProperty(PropertyName = "properties.groupMembers")] + public IList GroupMembers { get; set; } + + /// + /// Gets or sets network group conditional filter. + /// + [JsonProperty(PropertyName = "properties.conditionalMembership")] + public string ConditionalMembership { get; set; } + + /// + /// Gets the provisioning state of the scope assignment resource. + /// Possible values include: 'Succeeded', 'Updating', 'Deleting', + /// 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the system metadata related to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkGroupsCreateOrUpdateHeaders.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkGroupsCreateOrUpdateHeaders.cs new file mode 100644 index 0000000000000..dde367cf19ede --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkGroupsCreateOrUpdateHeaders.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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOrUpdate operation. + /// + public partial class NetworkGroupsCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the + /// NetworkGroupsCreateOrUpdateHeaders class. + /// + public NetworkGroupsCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// NetworkGroupsCreateOrUpdateHeaders class. + /// + /// The current entity tag. + public NetworkGroupsCreateOrUpdateHeaders(string eTag = default(string)) + { + ETag = eTag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the current entity tag. + /// + [JsonProperty(PropertyName = "ETag")] + public string ETag { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterface.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterface.cs index e474934bfda70..9bedac0024b0e 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterface.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterface.cs @@ -70,9 +70,16 @@ public NetworkInterface() /// The provisioning state of the /// network interface resource. Possible values include: 'Succeeded', /// 'Updating', 'Deleting', 'Failed' + /// Type of Network Interface resource. Possible + /// values include: 'Standard', 'Elastic' + /// Privatelinkservice of the network + /// interface resource. + /// Migration phase of Network Interface + /// resource. Possible values include: 'None', 'Prepare', 'Commit', + /// 'Abort', 'Committed' /// A unique read-only string that changes whenever /// the resource is updated. - public NetworkInterface(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ExtendedLocation extendedLocation = default(ExtendedLocation), SubResource virtualMachine = default(SubResource), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), PrivateEndpoint privateEndpoint = default(PrivateEndpoint), IList ipConfigurations = default(IList), IList tapConfigurations = default(IList), NetworkInterfaceDnsSettings dnsSettings = default(NetworkInterfaceDnsSettings), string macAddress = default(string), bool? primary = default(bool?), bool? enableAcceleratedNetworking = default(bool?), bool? enableIPForwarding = default(bool?), IList hostedWorkloads = default(IList), SubResource dscpConfiguration = default(SubResource), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string)) + public NetworkInterface(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ExtendedLocation extendedLocation = default(ExtendedLocation), SubResource virtualMachine = default(SubResource), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), PrivateEndpoint privateEndpoint = default(PrivateEndpoint), IList ipConfigurations = default(IList), IList tapConfigurations = default(IList), NetworkInterfaceDnsSettings dnsSettings = default(NetworkInterfaceDnsSettings), string macAddress = default(string), bool? primary = default(bool?), bool? enableAcceleratedNetworking = default(bool?), bool? enableIPForwarding = default(bool?), IList hostedWorkloads = default(IList), SubResource dscpConfiguration = default(SubResource), string resourceGuid = default(string), string provisioningState = default(string), string nicType = default(string), PrivateLinkService privateLinkService = default(PrivateLinkService), string migrationPhase = default(string), string etag = default(string)) : base(id, name, type, location, tags) { ExtendedLocation = extendedLocation; @@ -90,6 +97,9 @@ public NetworkInterface() DscpConfiguration = dscpConfiguration; ResourceGuid = resourceGuid; ProvisioningState = provisioningState; + NicType = nicType; + PrivateLinkService = privateLinkService; + MigrationPhase = migrationPhase; Etag = etag; CustomInit(); } @@ -196,6 +206,27 @@ public NetworkInterface() [JsonProperty(PropertyName = "properties.provisioningState")] public string ProvisioningState { get; private set; } + /// + /// Gets or sets type of Network Interface resource. Possible values + /// include: 'Standard', 'Elastic' + /// + [JsonProperty(PropertyName = "properties.nicType")] + public string NicType { get; set; } + + /// + /// Gets or sets privatelinkservice of the network interface resource. + /// + [JsonProperty(PropertyName = "properties.privateLinkService")] + public PrivateLinkService PrivateLinkService { get; set; } + + /// + /// Gets or sets migration phase of Network Interface resource. + /// Possible values include: 'None', 'Prepare', 'Commit', 'Abort', + /// 'Committed' + /// + [JsonProperty(PropertyName = "properties.migrationPhase")] + public string MigrationPhase { get; set; } + /// /// Gets a unique read-only string that changes whenever the resource /// is updated. @@ -239,6 +270,10 @@ public virtual void Validate() } } } + if (PrivateLinkService != null) + { + PrivateLinkService.Validate(); + } } } } diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceIpConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceIPConfiguration.cs similarity index 97% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceIpConfiguration.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceIPConfiguration.cs index fc1d252e53dff..89f950d3af692 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceIpConfiguration.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceIPConfiguration.cs @@ -70,7 +70,8 @@ public NetworkInterfaceIPConfiguration() /// resource. /// A unique read-only string that changes whenever /// the resource is updated. - public NetworkInterfaceIPConfiguration(string id = default(string), IList virtualNetworkTaps = default(IList), IList applicationGatewayBackendAddressPools = default(IList), IList loadBalancerBackendAddressPools = default(IList), IList loadBalancerInboundNatRules = default(IList), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), string privateIPAddressVersion = default(string), Subnet subnet = default(Subnet), bool? primary = default(bool?), PublicIPAddress publicIPAddress = default(PublicIPAddress), IList applicationSecurityGroups = default(IList), string provisioningState = default(string), NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties privateLinkConnectionProperties = default(NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties), string name = default(string), string etag = default(string)) + /// Resource type. + public NetworkInterfaceIPConfiguration(string id = default(string), IList virtualNetworkTaps = default(IList), IList applicationGatewayBackendAddressPools = default(IList), IList loadBalancerBackendAddressPools = default(IList), IList loadBalancerInboundNatRules = default(IList), string privateIPAddress = default(string), string privateIPAllocationMethod = default(string), string privateIPAddressVersion = default(string), Subnet subnet = default(Subnet), bool? primary = default(bool?), PublicIPAddress publicIPAddress = default(PublicIPAddress), IList applicationSecurityGroups = default(IList), string provisioningState = default(string), NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties privateLinkConnectionProperties = default(NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties), string name = default(string), string etag = default(string), string type = default(string)) : base(id) { VirtualNetworkTaps = virtualNetworkTaps; @@ -88,6 +89,7 @@ public NetworkInterfaceIPConfiguration() PrivateLinkConnectionProperties = privateLinkConnectionProperties; Name = name; Etag = etag; + Type = type; CustomInit(); } @@ -196,6 +198,12 @@ public NetworkInterfaceIPConfiguration() [JsonProperty(PropertyName = "etag")] public string Etag { get; private set; } + /// + /// Gets or sets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + /// /// Validate the object. /// diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceMigrationPhase.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceMigrationPhase.cs new file mode 100644 index 0000000000000..8f4f991c47753 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceMigrationPhase.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + + /// + /// Defines values for NetworkInterfaceMigrationPhase. + /// + public static class NetworkInterfaceMigrationPhase + { + public const string None = "None"; + public const string Prepare = "Prepare"; + public const string Commit = "Commit"; + public const string Abort = "Abort"; + public const string Committed = "Committed"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceNicType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceNicType.cs new file mode 100644 index 0000000000000..0fc5b43dec795 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkInterfaceNicType.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.Network.Models +{ + + /// + /// Defines values for NetworkInterfaceNicType. + /// + public static class NetworkInterfaceNicType + { + public const string Standard = "Standard"; + public const string Elastic = "Elastic"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManager.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManager.cs new file mode 100644 index 0000000000000..4e4ac7a275b5d --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManager.cs @@ -0,0 +1,120 @@ +// +// 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.Network.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The Managed Network resource + /// + [Rest.Serialization.JsonTransformation] + public partial class NetworkManager : Resource + { + /// + /// Initializes a new instance of the NetworkManager class. + /// + public NetworkManager() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkManager class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// Resource location. + /// Resource tags. + /// A friendly name for the network + /// manager. + /// A description of the network + /// manager. + /// Scope of Network + /// Manager. + /// Scope Access. + /// The provisioning state of the scope + /// assignment resource. Possible values include: 'Succeeded', + /// 'Updating', 'Deleting', 'Failed' + /// A unique read-only string that changes whenever + /// the resource is updated. + /// The system metadata related to this + /// resource. + public NetworkManager(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string displayName = default(string), string description = default(string), NetworkManagerPropertiesNetworkManagerScopes networkManagerScopes = default(NetworkManagerPropertiesNetworkManagerScopes), IList networkManagerScopeAccesses = default(IList), string provisioningState = default(string), string etag = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type, location, tags) + { + DisplayName = displayName; + Description = description; + NetworkManagerScopes = networkManagerScopes; + NetworkManagerScopeAccesses = networkManagerScopeAccesses; + ProvisioningState = provisioningState; + Etag = etag; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a friendly name for the network manager. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets a description of the network manager. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets scope of Network Manager. + /// + [JsonProperty(PropertyName = "properties.networkManagerScopes")] + public NetworkManagerPropertiesNetworkManagerScopes NetworkManagerScopes { get; set; } + + /// + /// Gets or sets scope Access. + /// + [JsonProperty(PropertyName = "properties.networkManagerScopeAccesses")] + public IList NetworkManagerScopeAccesses { get; set; } + + /// + /// Gets the provisioning state of the scope assignment resource. + /// Possible values include: 'Succeeded', 'Updating', 'Deleting', + /// 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets a unique read-only string that changes whenever the resource + /// is updated. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + /// + /// Gets the system metadata related to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerCommit.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerCommit.cs new file mode 100644 index 0000000000000..eab2bf35c668b --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerCommit.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.Network.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network Manager Commit. + /// + public partial class NetworkManagerCommit + { + /// + /// Initializes a new instance of the NetworkManagerCommit class. + /// + public NetworkManagerCommit() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkManagerCommit class. + /// + /// List of target locations. + /// List of configuration ids. + /// Commit Type. Possible values include: + /// 'AdminPolicy', 'UserPolicy', 'Routing', 'Connectivity' + public NetworkManagerCommit(IList targetLocations = default(IList), IList configurationIds = default(IList), string commitType = default(string)) + { + TargetLocations = targetLocations; + ConfigurationIds = configurationIds; + CommitType = commitType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of target locations. + /// + [JsonProperty(PropertyName = "targetLocations")] + public IList TargetLocations { get; set; } + + /// + /// Gets or sets list of configuration ids. + /// + [JsonProperty(PropertyName = "configurationIds")] + public IList ConfigurationIds { get; set; } + + /// + /// Gets or sets commit Type. Possible values include: 'AdminPolicy', + /// 'UserPolicy', 'Routing', 'Connectivity' + /// + [JsonProperty(PropertyName = "commitType")] + public string CommitType { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerDeploymentStatus.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerDeploymentStatus.cs new file mode 100644 index 0000000000000..6718c24da0582 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerDeploymentStatus.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network Manager Deployment Status. + /// + public partial class NetworkManagerDeploymentStatus + { + /// + /// Initializes a new instance of the NetworkManagerDeploymentStatus + /// class. + /// + public NetworkManagerDeploymentStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkManagerDeploymentStatus + /// class. + /// + /// Commit Time. + /// Region Name. + /// Deployment Status. Possible values + /// include: 'NotStarted', 'Deploying', 'Deployed', 'Failed' + /// List of configuration ids. + /// Possible values include: + /// 'AdminPolicy', 'UserPolicy', 'Routing', 'Connectivity' + /// Error Message. + public NetworkManagerDeploymentStatus(System.DateTime? commitTime = default(System.DateTime?), string region = default(string), string deploymentStatus = default(string), IList configurationIds = default(IList), string deploymentType = default(string), string errorMessage = default(string)) + { + CommitTime = commitTime; + Region = region; + DeploymentStatus = deploymentStatus; + ConfigurationIds = configurationIds; + DeploymentType = deploymentType; + ErrorMessage = errorMessage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets commit Time. + /// + [JsonProperty(PropertyName = "commitTime")] + public System.DateTime? CommitTime { get; set; } + + /// + /// Gets or sets region Name. + /// + [JsonProperty(PropertyName = "region")] + public string Region { get; set; } + + /// + /// Gets or sets deployment Status. Possible values include: + /// 'NotStarted', 'Deploying', 'Deployed', 'Failed' + /// + [JsonProperty(PropertyName = "deploymentStatus")] + public string DeploymentStatus { get; set; } + + /// + /// Gets or sets list of configuration ids. + /// + [JsonProperty(PropertyName = "configurationIds")] + public IList ConfigurationIds { get; set; } + + /// + /// Gets or sets possible values include: 'AdminPolicy', 'UserPolicy', + /// 'Routing', 'Connectivity' + /// + [JsonProperty(PropertyName = "deploymentType")] + public string DeploymentType { get; set; } + + /// + /// Gets or sets error Message. + /// + [JsonProperty(PropertyName = "errorMessage")] + public string ErrorMessage { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerDeploymentStatusParameter.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerDeploymentStatusParameter.cs new file mode 100644 index 0000000000000..f4827bc64b1b7 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerDeploymentStatusParameter.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network Manager Deployment Status Parameter. + /// + public partial class NetworkManagerDeploymentStatusParameter + { + /// + /// Initializes a new instance of the + /// NetworkManagerDeploymentStatusParameter class. + /// + public NetworkManagerDeploymentStatusParameter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// NetworkManagerDeploymentStatusParameter class. + /// + /// List of locations. + /// List of configurations' deployment + /// types. + public NetworkManagerDeploymentStatusParameter(IList regions = default(IList), IList deploymentTypes = default(IList)) + { + Regions = regions; + DeploymentTypes = deploymentTypes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of locations. + /// + [JsonProperty(PropertyName = "regions")] + public IList Regions { get; set; } + + /// + /// Gets or sets list of configurations' deployment types. + /// + [JsonProperty(PropertyName = "deploymentTypes")] + public IList DeploymentTypes { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerPropertiesNetworkManagerScopes.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerPropertiesNetworkManagerScopes.cs new file mode 100644 index 0000000000000..0812942d9e555 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerPropertiesNetworkManagerScopes.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Scope of Network Manager. + /// + public partial class NetworkManagerPropertiesNetworkManagerScopes + { + /// + /// Initializes a new instance of the + /// NetworkManagerPropertiesNetworkManagerScopes class. + /// + public NetworkManagerPropertiesNetworkManagerScopes() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// NetworkManagerPropertiesNetworkManagerScopes class. + /// + /// List of management groups. + /// List of subscriptions. + public NetworkManagerPropertiesNetworkManagerScopes(IList managementGroups = default(IList), IList subscriptions = default(IList)) + { + ManagementGroups = managementGroups; + Subscriptions = subscriptions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of management groups. + /// + [JsonProperty(PropertyName = "managementGroups")] + public IList ManagementGroups { get; set; } + + /// + /// Gets or sets list of subscriptions. + /// + [JsonProperty(PropertyName = "subscriptions")] + public IList Subscriptions { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerSecurityConfigurationImport.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerSecurityConfigurationImport.cs new file mode 100644 index 0000000000000..5311279befb71 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerSecurityConfigurationImport.cs @@ -0,0 +1,110 @@ +// +// 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.Network.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network manager security configuration import parameters. + /// + public partial class NetworkManagerSecurityConfigurationImport + { + /// + /// Initializes a new instance of the + /// NetworkManagerSecurityConfigurationImport class. + /// + public NetworkManagerSecurityConfigurationImport() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// NetworkManagerSecurityConfigurationImport class. + /// + /// List of nsg uris. + /// Flag if import deny rules + /// as admin rules. + /// Admin security + /// configuration Uri. + /// Flag if need to remove + /// allow vnet inbound rule. + /// Flag if need + /// to remove allow azure load balancer inbound rule. + /// Flag if need to remove + /// allow vnet outbound rule. + /// Flag if need to + /// remove allow Internet outbound rule. + public NetworkManagerSecurityConfigurationImport(IList networkSecurityGroupImports = default(IList), bool? importDenyRulesAsAdminRules = default(bool?), string adminSecurityConfigurationUri = default(string), bool? removeAllowVnetInboundRule = default(bool?), bool? removeAllowAzureLoadBalancerInboundRule = default(bool?), bool? removeAllowVnetOutboundRule = default(bool?), bool? removeAllowInternetOutboundRule = default(bool?)) + { + NetworkSecurityGroupImports = networkSecurityGroupImports; + ImportDenyRulesAsAdminRules = importDenyRulesAsAdminRules; + AdminSecurityConfigurationUri = adminSecurityConfigurationUri; + RemoveAllowVnetInboundRule = removeAllowVnetInboundRule; + RemoveAllowAzureLoadBalancerInboundRule = removeAllowAzureLoadBalancerInboundRule; + RemoveAllowVnetOutboundRule = removeAllowVnetOutboundRule; + RemoveAllowInternetOutboundRule = removeAllowInternetOutboundRule; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of nsg uris. + /// + [JsonProperty(PropertyName = "networkSecurityGroupImports")] + public IList NetworkSecurityGroupImports { get; set; } + + /// + /// Gets or sets flag if import deny rules as admin rules. + /// + [JsonProperty(PropertyName = "importDenyRulesAsAdminRules")] + public bool? ImportDenyRulesAsAdminRules { get; set; } + + /// + /// Gets or sets admin security configuration Uri. + /// + [JsonProperty(PropertyName = "adminSecurityConfigurationUri")] + public string AdminSecurityConfigurationUri { get; set; } + + /// + /// Gets or sets flag if need to remove allow vnet inbound rule. + /// + [JsonProperty(PropertyName = "removeAllowVnetInboundRule")] + public bool? RemoveAllowVnetInboundRule { get; set; } + + /// + /// Gets or sets flag if need to remove allow azure load balancer + /// inbound rule. + /// + [JsonProperty(PropertyName = "removeAllowAzureLoadBalancerInboundRule")] + public bool? RemoveAllowAzureLoadBalancerInboundRule { get; set; } + + /// + /// Gets or sets flag if need to remove allow vnet outbound rule. + /// + [JsonProperty(PropertyName = "removeAllowVnetOutboundRule")] + public bool? RemoveAllowVnetOutboundRule { get; set; } + + /// + /// Gets or sets flag if need to remove allow Internet outbound rule. + /// + [JsonProperty(PropertyName = "removeAllowInternetOutboundRule")] + public bool? RemoveAllowInternetOutboundRule { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerSecurityGroupItem.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerSecurityGroupItem.cs new file mode 100644 index 0000000000000..a85140d0bd774 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkManagerSecurityGroupItem.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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Network manager security group item. + /// + public partial class NetworkManagerSecurityGroupItem + { + /// + /// Initializes a new instance of the NetworkManagerSecurityGroupItem + /// class. + /// + public NetworkManagerSecurityGroupItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkManagerSecurityGroupItem + /// class. + /// + /// Network manager group Id. + public NetworkManagerSecurityGroupItem(string networkGroupId = default(string)) + { + NetworkGroupId = networkGroupId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets network manager group Id. + /// + [JsonProperty(PropertyName = "networkGroupId")] + public string NetworkGroupId { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkSecurityGroupImport.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkSecurityGroupImport.cs new file mode 100644 index 0000000000000..6f7faf68a2f4d --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/NetworkSecurityGroupImport.cs @@ -0,0 +1,52 @@ +// +// 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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Network Security Group Import. + /// + public partial class NetworkSecurityGroupImport + { + /// + /// Initializes a new instance of the NetworkSecurityGroupImport class. + /// + public NetworkSecurityGroupImport() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkSecurityGroupImport class. + /// + /// Network Security Group + /// Uri. + public NetworkSecurityGroupImport(string networkSecurityGroupUri = default(string)) + { + NetworkSecurityGroupUri = networkSecurityGroupUri; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets network Security Group Uri. + /// + [JsonProperty(PropertyName = "networkSecurityGroupUri")] + public string NetworkSecurityGroupUri { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ProxyResource.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ProxyResource.cs new file mode 100644 index 0000000000000..8480d098c562f --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ProxyResource.cs @@ -0,0 +1,79 @@ +// +// 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.Network.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Proxy resource representation. + /// + public partial class ProxyResource : IResource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// A unique read-only string that changes whenever + /// the resource is updated. + public ProxyResource(string id = default(string), string name = default(string), string type = default(string), string etag = default(string)) + { + Id = id; + Name = name; + Type = type; + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource ID. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets a unique read-only string that changes whenever the resource + /// is updated. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddress.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPAddress.cs similarity index 79% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddress.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPAddress.cs index aea875128f697..b59e9ed195cc2 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddress.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPAddress.cs @@ -66,11 +66,20 @@ public PublicIPAddress() /// The provisioning state of the /// public IP address resource. Possible values include: 'Succeeded', /// 'Updating', 'Deleting', 'Failed' + /// The service public IP address + /// of the public IP address resource. + /// The NatGateway for the Public IP + /// address. + /// Migration phase of Public IP Address. + /// Possible values include: 'None', 'Prepare', 'Commit', 'Abort', + /// 'Committed' + /// The source Public IP Address + /// (IPv6) that links to this address (IPv4). /// A unique read-only string that changes whenever /// the resource is updated. /// A list of availability zones denoting the IP /// allocated for the resource needs to come from. - public PublicIPAddress(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ExtendedLocation extendedLocation = default(ExtendedLocation), PublicIPAddressSku sku = default(PublicIPAddressSku), string publicIPAllocationMethod = default(string), string publicIPAddressVersion = default(string), IPConfiguration ipConfiguration = default(IPConfiguration), PublicIPAddressDnsSettings dnsSettings = default(PublicIPAddressDnsSettings), DdosSettings ddosSettings = default(DdosSettings), IList ipTags = default(IList), string ipAddress = default(string), SubResource publicIPPrefix = default(SubResource), int? idleTimeoutInMinutes = default(int?), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string), IList zones = default(IList)) + public PublicIPAddress(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ExtendedLocation extendedLocation = default(ExtendedLocation), PublicIPAddressSku sku = default(PublicIPAddressSku), string publicIPAllocationMethod = default(string), string publicIPAddressVersion = default(string), IPConfiguration ipConfiguration = default(IPConfiguration), PublicIPAddressDnsSettings dnsSettings = default(PublicIPAddressDnsSettings), DdosSettings ddosSettings = default(DdosSettings), IList ipTags = default(IList), string ipAddress = default(string), SubResource publicIPPrefix = default(SubResource), int? idleTimeoutInMinutes = default(int?), string resourceGuid = default(string), string provisioningState = default(string), PublicIPAddress servicePublicIPAddress = default(PublicIPAddress), NatGateway natGateway = default(NatGateway), string migrationPhase = default(string), PublicIPAddress linkedPublicIPAddress = default(PublicIPAddress), string etag = default(string), IList zones = default(IList)) : base(id, name, type, location, tags) { ExtendedLocation = extendedLocation; @@ -86,6 +95,10 @@ public PublicIPAddress() IdleTimeoutInMinutes = idleTimeoutInMinutes; ResourceGuid = resourceGuid; ProvisioningState = provisioningState; + ServicePublicIPAddress = servicePublicIPAddress; + NatGateway = natGateway; + MigrationPhase = migrationPhase; + LinkedPublicIPAddress = linkedPublicIPAddress; Etag = etag; Zones = zones; CustomInit(); @@ -183,6 +196,33 @@ public PublicIPAddress() [JsonProperty(PropertyName = "properties.provisioningState")] public string ProvisioningState { get; private set; } + /// + /// Gets or sets the service public IP address of the public IP address + /// resource. + /// + [JsonProperty(PropertyName = "properties.servicePublicIPAddress")] + public PublicIPAddress ServicePublicIPAddress { get; set; } + + /// + /// Gets or sets the NatGateway for the Public IP address. + /// + [JsonProperty(PropertyName = "properties.natGateway")] + public NatGateway NatGateway { get; set; } + + /// + /// Gets or sets migration phase of Public IP Address. Possible values + /// include: 'None', 'Prepare', 'Commit', 'Abort', 'Committed' + /// + [JsonProperty(PropertyName = "properties.migrationPhase")] + public string MigrationPhase { get; set; } + + /// + /// Gets or sets the source Public IP Address (IPv6) that links to this + /// address (IPv4). + /// + [JsonProperty(PropertyName = "properties.linkedPublicIPAddress")] + public PublicIPAddress LinkedPublicIPAddress { get; set; } + /// /// Gets a unique read-only string that changes whenever the resource /// is updated. @@ -213,6 +253,14 @@ public virtual void Validate() { IpConfiguration.Validate(); } + if (ServicePublicIPAddress != null) + { + ServicePublicIPAddress.Validate(); + } + if (LinkedPublicIPAddress != null) + { + LinkedPublicIPAddress.Validate(); + } } } } diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddressDnsSettings.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPAddressDnsSettings.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddressDnsSettings.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPAddressDnsSettings.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPPrefix.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPPrefix.cs index c7a322fbc0be6..83118c047128e 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPPrefix.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIPPrefix.cs @@ -61,11 +61,12 @@ public PublicIPPrefix() /// The provisioning state of the /// public IP prefix resource. Possible values include: 'Succeeded', /// 'Updating', 'Deleting', 'Failed' + /// NatGateway of Public IP Prefix. /// A unique read-only string that changes whenever /// the resource is updated. /// A list of availability zones denoting the IP /// allocated for the resource needs to come from. - public PublicIPPrefix(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ExtendedLocation extendedLocation = default(ExtendedLocation), PublicIPPrefixSku sku = default(PublicIPPrefixSku), string publicIPAddressVersion = default(string), IList ipTags = default(IList), int? prefixLength = default(int?), string ipPrefix = default(string), IList publicIPAddresses = default(IList), SubResource loadBalancerFrontendIpConfiguration = default(SubResource), SubResource customIPPrefix = default(SubResource), string resourceGuid = default(string), string provisioningState = default(string), string etag = default(string), IList zones = default(IList)) + public PublicIPPrefix(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ExtendedLocation extendedLocation = default(ExtendedLocation), PublicIPPrefixSku sku = default(PublicIPPrefixSku), string publicIPAddressVersion = default(string), IList ipTags = default(IList), int? prefixLength = default(int?), string ipPrefix = default(string), IList publicIPAddresses = default(IList), SubResource loadBalancerFrontendIpConfiguration = default(SubResource), SubResource customIPPrefix = default(SubResource), string resourceGuid = default(string), string provisioningState = default(string), NatGateway natGateway = default(NatGateway), string etag = default(string), IList zones = default(IList)) : base(id, name, type, location, tags) { ExtendedLocation = extendedLocation; @@ -79,6 +80,7 @@ public PublicIPPrefix() CustomIPPrefix = customIPPrefix; ResourceGuid = resourceGuid; ProvisioningState = provisioningState; + NatGateway = natGateway; Etag = etag; Zones = zones; CustomInit(); @@ -160,6 +162,12 @@ public PublicIPPrefix() [JsonProperty(PropertyName = "properties.provisioningState")] public string ProvisioningState { get; private set; } + /// + /// Gets or sets natGateway of Public IP Prefix. + /// + [JsonProperty(PropertyName = "properties.natGateway")] + public NatGateway NatGateway { get; set; } + /// /// Gets a unique read-only string that changes whenever the resource /// is updated. diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddressMigrationPhase.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddressMigrationPhase.cs new file mode 100644 index 0000000000000..38fae4f60c8c7 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/PublicIpAddressMigrationPhase.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network.Models +{ + + /// + /// Defines values for PublicIpAddressMigrationPhase. + /// + public static class PublicIpAddressMigrationPhase + { + public const string None = "None"; + public const string Prepare = "Prepare"; + public const string Commit = "Commit"; + public const string Abort = "Abort"; + public const string Committed = "Committed"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ScopeAccesses.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ScopeAccesses.cs new file mode 100644 index 0000000000000..0db8bdcfa0fc6 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/ScopeAccesses.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.Network.Models +{ + + /// + /// Defines values for ScopeAccesses. + /// + public static class ScopeAccesses + { + public const string Security = "Security"; + public const string Routing = "Routing"; + public const string Connectivity = "Connectivity"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfiguration.cs new file mode 100644 index 0000000000000..9f865d8056199 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfiguration.cs @@ -0,0 +1,121 @@ +// +// 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.Network.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the security Configuration + /// + [Rest.Serialization.JsonTransformation] + public partial class SecurityConfiguration : ProxyResource + { + /// + /// Initializes a new instance of the SecurityConfiguration class. + /// + public SecurityConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecurityConfiguration class. + /// + /// Resource ID. + /// Resource name. + /// Resource type. + /// A unique read-only string that changes whenever + /// the resource is updated. + /// A display name of the security + /// Configuration. + /// A description of the security + /// Configuration. + /// Security Type. Possible values include: + /// 'AdminPolicy', 'UserPolicy' + /// Flag if need to delete existing + /// network security groups. + /// Groups for configuration + /// The provisioning state of the scope + /// assignment resource. Possible values include: 'Succeeded', + /// 'Updating', 'Deleting', 'Failed' + /// The system metadata related to this + /// resource. + public SecurityConfiguration(string id = default(string), string name = default(string), string type = default(string), string etag = default(string), string displayName = default(string), string description = default(string), string securityType = default(string), bool? deleteExistingNSGs = default(bool?), IList appliesToGroups = default(IList), string provisioningState = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type, etag) + { + DisplayName = displayName; + Description = description; + SecurityType = securityType; + DeleteExistingNSGs = deleteExistingNSGs; + AppliesToGroups = appliesToGroups; + ProvisioningState = provisioningState; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a display name of the security Configuration. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets a description of the security Configuration. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets security Type. Possible values include: 'AdminPolicy', + /// 'UserPolicy' + /// + [JsonProperty(PropertyName = "properties.securityType")] + public string SecurityType { get; set; } + + /// + /// Gets or sets flag if need to delete existing network security + /// groups. + /// + [JsonProperty(PropertyName = "properties.deleteExistingNSGs")] + public bool? DeleteExistingNSGs { get; set; } + + /// + /// Gets or sets groups for configuration + /// + [JsonProperty(PropertyName = "properties.appliesToGroups")] + public IList AppliesToGroups { get; set; } + + /// + /// Gets the provisioning state of the scope assignment resource. + /// Possible values include: 'Succeeded', 'Updating', 'Deleting', + /// 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the system metadata related to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationImportResult.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationImportResult.cs new file mode 100644 index 0000000000000..e4ef3eb4145c2 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationImportResult.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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Security configuration import Result. + /// + public partial class SecurityConfigurationImportResult + { + /// + /// Initializes a new instance of the SecurityConfigurationImportResult + /// class. + /// + public SecurityConfigurationImportResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecurityConfigurationImportResult + /// class. + /// + /// User security configuration + /// Id. + /// Admin security + /// configuration Id. + /// failed imports code and reason + public SecurityConfigurationImportResult(string userSecurityConfiguration = default(string), string adminSecurityConfiguration = default(string), FailedImport failedImport = default(FailedImport)) + { + UserSecurityConfiguration = userSecurityConfiguration; + AdminSecurityConfiguration = adminSecurityConfiguration; + FailedImport = failedImport; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets user security configuration Id. + /// + [JsonProperty(PropertyName = "userSecurityConfiguration")] + public string UserSecurityConfiguration { get; set; } + + /// + /// Gets or sets admin security configuration Id. + /// + [JsonProperty(PropertyName = "adminSecurityConfiguration")] + public string AdminSecurityConfiguration { get; set; } + + /// + /// Gets or sets failed imports code and reason + /// + [JsonProperty(PropertyName = "failedImport")] + public FailedImport FailedImport { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRule.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRule.cs new file mode 100644 index 0000000000000..ac9af71ac1368 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRule.cs @@ -0,0 +1,86 @@ +// +// 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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// General security configuration Rule. + /// + public partial class SecurityConfigurationRule + { + /// + /// Initializes a new instance of the SecurityConfigurationRule class. + /// + public SecurityConfigurationRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SecurityConfigurationRule class. + /// + /// Commit Type. Possible values include: + /// 'AdminPolicy', 'UserPolicy' + /// Security admin rule. + /// Security user rule. + public SecurityConfigurationRule(string securityType = default(string), AdminRule securityAdminRule = default(AdminRule), UserRule securityUserRule = default(UserRule)) + { + SecurityType = securityType; + SecurityAdminRule = securityAdminRule; + SecurityUserRule = securityUserRule; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets commit Type. Possible values include: 'AdminPolicy', + /// 'UserPolicy' + /// + [JsonProperty(PropertyName = "securityType")] + public string SecurityType { get; set; } + + /// + /// Gets or sets security admin rule. + /// + [JsonProperty(PropertyName = "securityAdminRule")] + public AdminRule SecurityAdminRule { get; set; } + + /// + /// Gets or sets security user rule. + /// + [JsonProperty(PropertyName = "securityUserRule")] + public UserRule SecurityUserRule { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SecurityAdminRule != null) + { + SecurityAdminRule.Validate(); + } + if (SecurityUserRule != null) + { + SecurityUserRule.Validate(); + } + } + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleAccess.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleAccess.cs new file mode 100644 index 0000000000000..8fa24ddae16e1 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleAccess.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.Network.Models +{ + + /// + /// Defines values for SecurityConfigurationRuleAccess. + /// + public static class SecurityConfigurationRuleAccess + { + public const string Allow = "Allow"; + public const string Deny = "Deny"; + public const string AlwaysAllow = "AlwaysAllow"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleDirection.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleDirection.cs new file mode 100644 index 0000000000000..266a50b5281a9 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleDirection.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.Network.Models +{ + + /// + /// Defines values for SecurityConfigurationRuleDirection. + /// + public static class SecurityConfigurationRuleDirection + { + public const string Inbound = "Inbound"; + public const string Outbound = "Outbound"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleProtocol.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleProtocol.cs new file mode 100644 index 0000000000000..d4ca62c2e1b87 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityConfigurationRuleProtocol.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.Network.Models +{ + + /// + /// Defines values for SecurityConfigurationRuleProtocol. + /// + public static class SecurityConfigurationRuleProtocol + { + public const string Tcp = "Tcp"; + public const string Udp = "Udp"; + public const string Icmp = "Icmp"; + public const string Esp = "Esp"; + public const string Any = "Any"; + public const string Ah = "Ah"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityType.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityType.cs new file mode 100644 index 0000000000000..917cef4ae48fc --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SecurityType.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.Network.Models +{ + + /// + /// Defines values for SecurityType. + /// + public static class SecurityType + { + public const string AdminPolicy = "AdminPolicy"; + public const string UserPolicy = "UserPolicy"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Subnet.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Subnet.cs index a035ab6a11592..08c3259eef45b 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Subnet.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/Subnet.cs @@ -70,16 +70,20 @@ public Subnet() /// subnet resource. Possible values include: 'Succeeded', 'Updating', /// 'Deleting', 'Failed' /// Enable or Disable - /// apply network policies on private end point in the subnet. + /// apply network policies on private end point in the subnet. Possible + /// values include: 'Enabled', 'Disabled' /// Enable or Disable - /// apply network policies on private link service in the - /// subnet. + /// apply network policies on private link service in the subnet. + /// Possible values include: 'Enabled', 'Disabled' + /// Application + /// gateway IP configurations of virtual network resource. /// The name of the resource that is unique within a /// resource group. This name can be used to access the /// resource. /// A unique read-only string that changes whenever /// the resource is updated. - public Subnet(string id = default(string), string addressPrefix = default(string), IList addressPrefixes = default(IList), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), RouteTable routeTable = default(RouteTable), SubResource natGateway = default(SubResource), IList serviceEndpoints = default(IList), IList serviceEndpointPolicies = default(IList), IList privateEndpoints = default(IList), IList ipConfigurations = default(IList), IList ipConfigurationProfiles = default(IList), IList ipAllocations = default(IList), IList resourceNavigationLinks = default(IList), IList serviceAssociationLinks = default(IList), IList delegations = default(IList), string purpose = default(string), string provisioningState = default(string), string privateEndpointNetworkPolicies = default(string), string privateLinkServiceNetworkPolicies = default(string), string name = default(string), string etag = default(string)) + /// Resource type. + public Subnet(string id = default(string), string addressPrefix = default(string), IList addressPrefixes = default(IList), NetworkSecurityGroup networkSecurityGroup = default(NetworkSecurityGroup), RouteTable routeTable = default(RouteTable), SubResource natGateway = default(SubResource), IList serviceEndpoints = default(IList), IList serviceEndpointPolicies = default(IList), IList privateEndpoints = default(IList), IList ipConfigurations = default(IList), IList ipConfigurationProfiles = default(IList), IList ipAllocations = default(IList), IList resourceNavigationLinks = default(IList), IList serviceAssociationLinks = default(IList), IList delegations = default(IList), string purpose = default(string), string provisioningState = default(string), string privateEndpointNetworkPolicies = default(string), string privateLinkServiceNetworkPolicies = default(string), IList applicationGatewayIpConfigurations = default(IList), string name = default(string), string etag = default(string), string type = default(string)) : base(id) { AddressPrefix = addressPrefix; @@ -100,8 +104,10 @@ public Subnet() ProvisioningState = provisioningState; PrivateEndpointNetworkPolicies = privateEndpointNetworkPolicies; PrivateLinkServiceNetworkPolicies = privateLinkServiceNetworkPolicies; + ApplicationGatewayIpConfigurations = applicationGatewayIpConfigurations; Name = name; Etag = etag; + Type = type; CustomInit(); } @@ -213,18 +219,27 @@ public Subnet() /// /// Gets or sets enable or Disable apply network policies on private - /// end point in the subnet. + /// end point in the subnet. Possible values include: 'Enabled', + /// 'Disabled' /// [JsonProperty(PropertyName = "properties.privateEndpointNetworkPolicies")] public string PrivateEndpointNetworkPolicies { get; set; } /// /// Gets or sets enable or Disable apply network policies on private - /// link service in the subnet. + /// link service in the subnet. Possible values include: 'Enabled', + /// 'Disabled' /// [JsonProperty(PropertyName = "properties.privateLinkServiceNetworkPolicies")] public string PrivateLinkServiceNetworkPolicies { get; set; } + /// + /// Gets or sets application gateway IP configurations of virtual + /// network resource. + /// + [JsonProperty(PropertyName = "properties.applicationGatewayIpConfigurations")] + public IList ApplicationGatewayIpConfigurations { get; set; } + /// /// Gets or sets the name of the resource that is unique within a /// resource group. This name can be used to access the resource. @@ -239,5 +254,11 @@ public Subnet() [JsonProperty(PropertyName = "etag")] public string Etag { get; private set; } + /// + /// Gets or sets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + } } diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SystemData.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SystemData.cs new file mode 100644 index 0000000000000..c8f4a089574cf --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/SystemData.cs @@ -0,0 +1,103 @@ +// +// 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.Network.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metadata pertaining to creation and last modification of the resource. + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// The identity that created the + /// resource. + /// The type of identity that created the + /// resource. Possible values include: 'User', 'Application', + /// 'ManagedIdentity', 'Key' + /// The timestamp of resource creation + /// (UTC). + /// The identity that last modified the + /// resource. + /// The type of identity that last + /// modified the resource. Possible values include: 'User', + /// 'Application', 'ManagedIdentity', 'Key' + /// The type of identity that last + /// modified the resource. + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity that created the resource. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC). + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets the identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/UserRule.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/UserRule.cs new file mode 100644 index 0000000000000..3fa0fa32321be --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/UserRule.cs @@ -0,0 +1,166 @@ +// +// 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.Network.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network security admin rule. + /// + [Rest.Serialization.JsonTransformation] + public partial class UserRule : ProxyResource + { + /// + /// Initializes a new instance of the UserRule class. + /// + public UserRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UserRule class. + /// + /// Network protocol this rule applies to. + /// Possible values include: 'Tcp', 'Udp', 'Icmp', 'Esp', 'Any', + /// 'Ah' + /// Indicates if the traffic matched against + /// the rule in inbound or outbound. Possible values include: + /// 'Inbound', 'Outbound' + /// Resource ID. + /// Resource name. + /// Resource type. + /// A unique read-only string that changes whenever + /// the resource is updated. + /// A friendly name for the rule. + /// A description for this rule. Restricted + /// to 140 chars. + /// The CIDR or source IP ranges. + /// The destination address prefixes. CIDR or + /// destination IP ranges. + /// The source port ranges. + /// The destination port + /// ranges. + /// The provisioning state of the + /// security Configuration resource. Possible values include: + /// 'Succeeded', 'Updating', 'Deleting', 'Failed' + /// The system metadata related to this + /// resource. + public UserRule(string protocol, string direction, string id = default(string), string name = default(string), string type = default(string), string etag = default(string), string displayName = default(string), string description = default(string), IList source = default(IList), IList destination = default(IList), IList sourcePortRanges = default(IList), IList destinationPortRanges = default(IList), string provisioningState = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type, etag) + { + DisplayName = displayName; + Description = description; + Protocol = protocol; + Source = source; + Destination = destination; + SourcePortRanges = sourcePortRanges; + DestinationPortRanges = destinationPortRanges; + Direction = direction; + ProvisioningState = provisioningState; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a friendly name for the rule. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets a description for this rule. Restricted to 140 chars. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets network protocol this rule applies to. Possible values + /// include: 'Tcp', 'Udp', 'Icmp', 'Esp', 'Any', 'Ah' + /// + [JsonProperty(PropertyName = "properties.protocol")] + public string Protocol { get; set; } + + /// + /// Gets or sets the CIDR or source IP ranges. + /// + [JsonProperty(PropertyName = "properties.source")] + public IList Source { get; set; } + + /// + /// Gets or sets the destination address prefixes. CIDR or destination + /// IP ranges. + /// + [JsonProperty(PropertyName = "properties.destination")] + public IList Destination { get; set; } + + /// + /// Gets or sets the source port ranges. + /// + [JsonProperty(PropertyName = "properties.sourcePortRanges")] + public IList SourcePortRanges { get; set; } + + /// + /// Gets or sets the destination port ranges. + /// + [JsonProperty(PropertyName = "properties.destinationPortRanges")] + public IList DestinationPortRanges { get; set; } + + /// + /// Gets or sets indicates if the traffic matched against the rule in + /// inbound or outbound. Possible values include: 'Inbound', 'Outbound' + /// + [JsonProperty(PropertyName = "properties.direction")] + public string Direction { get; set; } + + /// + /// Gets the provisioning state of the security Configuration resource. + /// Possible values include: 'Succeeded', 'Updating', 'Deleting', + /// 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the system metadata related to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Protocol == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Protocol"); + } + if (Direction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Direction"); + } + } + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkGatewayIpConfiguration.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkGatewayIPConfiguration.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkGatewayIpConfiguration.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkGatewayIPConfiguration.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPeering.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPeering.cs index 68807c1c41368..7749cc3707a9c 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPeering.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPeering.cs @@ -62,12 +62,17 @@ public VirtualNetworkPeering() /// The provisioning state of the /// virtual network peering resource. Possible values include: /// 'Succeeded', 'Updating', 'Deleting', 'Failed' + /// If we need to verify the + /// provisioning state of the remote gateway. + /// The resourceGuid property of the Virtual + /// Network Peering resource. /// The name of the resource that is unique within a /// resource group. This name can be used to access the /// resource. /// A unique read-only string that changes whenever /// the resource is updated. - public VirtualNetworkPeering(string id = default(string), bool? allowVirtualNetworkAccess = default(bool?), bool? allowForwardedTraffic = default(bool?), bool? allowGatewayTransit = default(bool?), bool? useRemoteGateways = default(bool?), SubResource remoteVirtualNetwork = default(SubResource), AddressSpace remoteAddressSpace = default(AddressSpace), VirtualNetworkBgpCommunities remoteBgpCommunities = default(VirtualNetworkBgpCommunities), string peeringState = default(string), string provisioningState = default(string), string name = default(string), string etag = default(string)) + /// Resource type. + public VirtualNetworkPeering(string id = default(string), bool? allowVirtualNetworkAccess = default(bool?), bool? allowForwardedTraffic = default(bool?), bool? allowGatewayTransit = default(bool?), bool? useRemoteGateways = default(bool?), SubResource remoteVirtualNetwork = default(SubResource), AddressSpace remoteAddressSpace = default(AddressSpace), VirtualNetworkBgpCommunities remoteBgpCommunities = default(VirtualNetworkBgpCommunities), string peeringState = default(string), string provisioningState = default(string), bool? doNotVerifyRemoteGateways = default(bool?), string resourceGuid = default(string), string name = default(string), string etag = default(string), string type = default(string)) : base(id) { AllowVirtualNetworkAccess = allowVirtualNetworkAccess; @@ -79,8 +84,11 @@ public VirtualNetworkPeering() RemoteBgpCommunities = remoteBgpCommunities; PeeringState = peeringState; ProvisioningState = provisioningState; + DoNotVerifyRemoteGateways = doNotVerifyRemoteGateways; + ResourceGuid = resourceGuid; Name = name; Etag = etag; + Type = type; CustomInit(); } @@ -160,6 +168,20 @@ public VirtualNetworkPeering() [JsonProperty(PropertyName = "properties.provisioningState")] public string ProvisioningState { get; private set; } + /// + /// Gets or sets if we need to verify the provisioning state of the + /// remote gateway. + /// + [JsonProperty(PropertyName = "properties.doNotVerifyRemoteGateways")] + public bool? DoNotVerifyRemoteGateways { get; set; } + + /// + /// Gets the resourceGuid property of the Virtual Network Peering + /// resource. + /// + [JsonProperty(PropertyName = "properties.resourceGuid")] + public string ResourceGuid { get; private set; } + /// /// Gets or sets the name of the resource that is unique within a /// resource group. This name can be used to access the resource. @@ -174,6 +196,12 @@ public VirtualNetworkPeering() [JsonProperty(PropertyName = "etag")] public string Etag { get; private set; } + /// + /// Gets or sets resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + /// /// Validate the object. /// diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPrivateEndpointNetworkPolicies.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPrivateEndpointNetworkPolicies.cs new file mode 100644 index 0000000000000..f163072d5afd6 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPrivateEndpointNetworkPolicies.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.Network.Models +{ + + /// + /// Defines values for VirtualNetworkPrivateEndpointNetworkPolicies. + /// + public static class VirtualNetworkPrivateEndpointNetworkPolicies + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPrivateLinkServiceNetworkPolicies.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPrivateLinkServiceNetworkPolicies.cs new file mode 100644 index 0000000000000..0abd6c551a888 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/Models/VirtualNetworkPrivateLinkServiceNetworkPolicies.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.Network.Models +{ + + /// + /// Defines values for VirtualNetworkPrivateLinkServiceNetworkPolicies. + /// + public static class VirtualNetworkPrivateLinkServiceNetworkPolicies + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkGroupsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkGroupsOperations.cs new file mode 100644 index 0000000000000..6b2ce397b763f --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkGroupsOperations.cs @@ -0,0 +1,1096 @@ +// +// 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.Network +{ + 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; + + /// + /// NetworkGroupsOperations operations. + /// + internal partial class NetworkGroupsOperations : IServiceOperations, INetworkGroupsOperations + { + /// + /// Initializes a new instance of the NetworkGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal NetworkGroupsOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Gets the specified network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// 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 networkManagerName, string networkGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (networkGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkGroupName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("networkGroupName", networkGroupName); + tracingParameters.Add("apiVersion", apiVersion); + 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.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{networkGroupName}", System.Uri.EscapeDataString(networkGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates a network group. + /// + /// + /// Parameters supplied to the specify which network group need to create + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// The ETag of the transformation. Omit this value to always overwrite the + /// current resource. Specify the last-seen ETag value to prevent accidentally + /// overwriting concurrent changes. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(NetworkGroup parameters, string resourceGroupName, string networkManagerName, string networkGroupName, string ifMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (networkGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkGroupName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("ifMatch", ifMatch); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("networkGroupName", networkGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{networkGroupName}", System.Uri.EscapeDataString(networkGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 (ifMatch != null) + { + if (_httpRequest.Headers.Contains("If-Match")) + { + _httpRequest.Headers.Remove("If-Match"); + } + _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); + } + 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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new 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(); + } + // 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); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// 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 networkManagerName, string networkGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (networkGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkGroupName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("networkGroupName", networkGroupName); + tracingParameters.Add("apiVersion", apiVersion); + 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.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{networkGroupName}", System.Uri.EscapeDataString(networkGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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; + } + + /// + /// Lists the specified network group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + 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.Network/networkManagers/{networkManagerName}/networkGroups").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // 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 the specified network 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 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/NetworkGroupsOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkGroupsOperationsExtensions.cs new file mode 100644 index 0000000000000..c3edfff097ebe --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkGroupsOperationsExtensions.cs @@ -0,0 +1,270 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for NetworkGroupsOperations. + /// + public static partial class NetworkGroupsOperationsExtensions + { + /// + /// Gets the specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + public static NetworkGroup Get(this INetworkGroupsOperations operations, string resourceGroupName, string networkManagerName, string networkGroupName) + { + return operations.GetAsync(resourceGroupName, networkManagerName, networkGroupName).GetAwaiter().GetResult(); + } + + /// + /// Gets the specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this INetworkGroupsOperations operations, string resourceGroupName, string networkManagerName, string networkGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkManagerName, networkGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to the specify which network group need to create + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// The ETag of the transformation. Omit this value to always overwrite the + /// current resource. Specify the last-seen ETag value to prevent accidentally + /// overwriting concurrent changes. + /// + public static NetworkGroup CreateOrUpdate(this INetworkGroupsOperations operations, NetworkGroup parameters, string resourceGroupName, string networkManagerName, string networkGroupName, string ifMatch = default(string)) + { + return operations.CreateOrUpdateAsync(parameters, resourceGroupName, networkManagerName, networkGroupName, ifMatch).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to the specify which network group need to create + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// The ETag of the transformation. Omit this value to always overwrite the + /// current resource. Specify the last-seen ETag value to prevent accidentally + /// overwriting concurrent changes. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this INetworkGroupsOperations operations, NetworkGroup parameters, string resourceGroupName, string networkManagerName, string networkGroupName, string ifMatch = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(parameters, resourceGroupName, networkManagerName, networkGroupName, ifMatch, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + public static void Delete(this INetworkGroupsOperations operations, string resourceGroupName, string networkManagerName, string networkGroupName) + { + operations.DeleteAsync(resourceGroupName, networkManagerName, networkGroupName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network group to get. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this INetworkGroupsOperations operations, string resourceGroupName, string networkManagerName, string networkGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkManagerName, networkGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists the specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this INetworkGroupsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, networkManagerName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Lists the specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this INetworkGroupsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkManagerName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the specified network group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this INetworkGroupsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the specified network 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 INetworkGroupsOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagementClient.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagementClient.cs index a13b7b153371d..bf1d8617de774 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagementClient.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagementClient.cs @@ -298,6 +298,61 @@ public partial class NetworkManagementClient : ServiceClient public virtual INetworkInterfaceTapConfigurationsOperations NetworkInterfaceTapConfigurations { get; private set; } + /// + /// Gets the INetworkManagersOperations. + /// + public virtual INetworkManagersOperations NetworkManagers { get; private set; } + + /// + /// Gets the INetworkManagerCommitsOperations. + /// + public virtual INetworkManagerCommitsOperations NetworkManagerCommits { get; private set; } + + /// + /// Gets the INetworkManagerDeploymentStatusOperations. + /// + public virtual INetworkManagerDeploymentStatusOperations NetworkManagerDeploymentStatus { get; private set; } + + /// + /// Gets the IEffectiveVirtualNetworksOperations. + /// + public virtual IEffectiveVirtualNetworksOperations EffectiveVirtualNetworks { get; private set; } + + /// + /// Gets the IActiveConfigurationsOperations. + /// + public virtual IActiveConfigurationsOperations ActiveConfigurations { get; private set; } + + /// + /// Gets the IConnectivityConfigurationsOperations. + /// + public virtual IConnectivityConfigurationsOperations ConnectivityConfigurations { get; private set; } + + /// + /// Gets the IEffectiveConfigurationsOperations. + /// + public virtual IEffectiveConfigurationsOperations EffectiveConfigurations { get; private set; } + + /// + /// Gets the INetworkGroupsOperations. + /// + public virtual INetworkGroupsOperations NetworkGroups { get; private set; } + + /// + /// Gets the ISecurityConfigurationsOperations. + /// + public virtual ISecurityConfigurationsOperations SecurityConfigurations { get; private set; } + + /// + /// Gets the IAdminRulesOperations. + /// + public virtual IAdminRulesOperations AdminRules { get; private set; } + + /// + /// Gets the IUserRulesOperations. + /// + public virtual IUserRulesOperations UserRules { get; private set; } + /// /// Gets the INetworkProfilesOperations. /// @@ -893,6 +948,17 @@ private void Initialize() NetworkInterfaceIPConfigurations = new NetworkInterfaceIPConfigurationsOperations(this); NetworkInterfaceLoadBalancers = new NetworkInterfaceLoadBalancersOperations(this); NetworkInterfaceTapConfigurations = new NetworkInterfaceTapConfigurationsOperations(this); + NetworkManagers = new NetworkManagersOperations(this); + NetworkManagerCommits = new NetworkManagerCommitsOperations(this); + NetworkManagerDeploymentStatus = new NetworkManagerDeploymentStatusOperations(this); + EffectiveVirtualNetworks = new EffectiveVirtualNetworksOperations(this); + ActiveConfigurations = new ActiveConfigurationsOperations(this); + ConnectivityConfigurations = new ConnectivityConfigurationsOperations(this); + EffectiveConfigurations = new EffectiveConfigurationsOperations(this); + NetworkGroups = new NetworkGroupsOperations(this); + SecurityConfigurations = new SecurityConfigurationsOperations(this); + AdminRules = new AdminRulesOperations(this); + UserRules = new UserRulesOperations(this); NetworkProfiles = new NetworkProfilesOperations(this); NetworkSecurityGroups = new NetworkSecurityGroupsOperations(this); SecurityRules = new SecurityRulesOperations(this); diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerCommitsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerCommitsOperations.cs new file mode 100644 index 0000000000000..e4439f1ad0a94 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerCommitsOperations.cs @@ -0,0 +1,241 @@ +// +// 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.Network +{ + 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; + + /// + /// NetworkManagerCommitsOperations operations. + /// + internal partial class NetworkManagerCommitsOperations : IServiceOperations, INetworkManagerCommitsOperations + { + /// + /// Initializes a new instance of the NetworkManagerCommitsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal NetworkManagerCommitsOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Post a Network Manager Commit. + /// + /// + /// Parameters supplied to specify which Managed Network commit is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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 PostWithHttpMessagesAsync(NetworkManagerCommit parameters, string resourceGroupName, string networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Post", 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.Network/networkManagers/{networkManagerName}/commit").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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; + } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerCommitsOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerCommitsOperationsExtensions.cs new file mode 100644 index 0000000000000..b3093a1bf602d --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerCommitsOperationsExtensions.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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for NetworkManagerCommitsOperations. + /// + public static partial class NetworkManagerCommitsOperationsExtensions + { + /// + /// Post a Network Manager Commit. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to specify which Managed Network commit is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + public static void Post(this INetworkManagerCommitsOperations operations, NetworkManagerCommit parameters, string resourceGroupName, string networkManagerName) + { + operations.PostAsync(parameters, resourceGroupName, networkManagerName).GetAwaiter().GetResult(); + } + + /// + /// Post a Network Manager Commit. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to specify which Managed Network commit is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The cancellation token. + /// + public static async Task PostAsync(this INetworkManagerCommitsOperations operations, NetworkManagerCommit parameters, string resourceGroupName, string networkManagerName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.PostWithHttpMessagesAsync(parameters, resourceGroupName, networkManagerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerDeploymentStatusOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerDeploymentStatusOperations.cs new file mode 100644 index 0000000000000..efcfe83d1ec4b --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerDeploymentStatusOperations.cs @@ -0,0 +1,463 @@ +// +// 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.Network +{ + 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; + + /// + /// NetworkManagerDeploymentStatusOperations operations. + /// + internal partial class NetworkManagerDeploymentStatusOperations : IServiceOperations, INetworkManagerDeploymentStatusOperations + { + /// + /// Initializes a new instance of the NetworkManagerDeploymentStatusOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal NetworkManagerDeploymentStatusOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// Parameters supplied to specify which Managed Network deployment status is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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(NetworkManagerDeploymentStatusParameter parameters, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + 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.Network/networkManagers/{networkManagerName}/listDeploymentStatus").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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; + } + + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// 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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerDeploymentStatusOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerDeploymentStatusOperationsExtensions.cs new file mode 100644 index 0000000000000..e6392be593e03 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagerDeploymentStatusOperationsExtensions.cs @@ -0,0 +1,125 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for NetworkManagerDeploymentStatusOperations. + /// + public static partial class NetworkManagerDeploymentStatusOperationsExtensions + { + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to specify which Managed Network deployment status is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this INetworkManagerDeploymentStatusOperations operations, NetworkManagerDeploymentStatusParameter parameters, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(parameters, resourceGroupName, networkManagerName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to specify which Managed Network deployment status is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this INetworkManagerDeploymentStatusOperations operations, NetworkManagerDeploymentStatusParameter parameters, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(parameters, resourceGroupName, networkManagerName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this INetworkManagerDeploymentStatusOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Post List of Network Manager Deployment Status. + /// + /// + /// 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 INetworkManagerDeploymentStatusOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagersOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagersOperations.cs new file mode 100644 index 0000000000000..35b89b5796547 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagersOperations.cs @@ -0,0 +1,1618 @@ +// +// 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.Network +{ + 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; + + /// + /// NetworkManagersOperations operations. + /// + internal partial class NetworkManagersOperations : IServiceOperations, INetworkManagersOperations + { + /// + /// Initializes a new instance of the NetworkManagersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal NetworkManagersOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Gets the specified Network Manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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 networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + 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.Network/networkManagers/{networkManagerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates a Network Manager. + /// + /// + /// Parameters supplied to specify which network manager is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(NetworkManager parameters, string resourceGroupName, string networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Network/networkManagers/{networkManagerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a network manager. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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 networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + 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.Network/networkManagers/{networkManagerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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; + } + + /// + /// Patch a NetworkManager Tags. + /// + /// + /// Parameters supplied to update network manager tags. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// 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> PatchTagsWithHttpMessagesAsync(TagsObject parameters, string resourceGroupName, string networkManagerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "PatchTags", 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.Network/networkManagers/{networkManagerName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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; + } + + /// + /// List all network managers in a subscription. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Network/networkManagers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // 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; + } + + /// + /// List network managers in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + 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.Network/networkManagers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // 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; + } + + /// + /// List all network managers in a subscription. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(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, "ListBySubscriptionNext", 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 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(); + } + // 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; + } + + /// + /// List network managers in 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 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagersOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagersOperationsExtensions.cs new file mode 100644 index 0000000000000..496cd644173f2 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/NetworkManagersOperationsExtensions.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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for NetworkManagersOperations. + /// + public static partial class NetworkManagersOperationsExtensions + { + /// + /// Gets the specified Network Manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + public static NetworkManager Get(this INetworkManagersOperations operations, string resourceGroupName, string networkManagerName) + { + return operations.GetAsync(resourceGroupName, networkManagerName).GetAwaiter().GetResult(); + } + + /// + /// Gets the specified Network Manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this INetworkManagersOperations operations, string resourceGroupName, string networkManagerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkManagerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a Network Manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to specify which network manager is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + public static NetworkManager CreateOrUpdate(this INetworkManagersOperations operations, NetworkManager parameters, string resourceGroupName, string networkManagerName) + { + return operations.CreateOrUpdateAsync(parameters, resourceGroupName, networkManagerName).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a Network Manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to specify which network manager is. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this INetworkManagersOperations operations, NetworkManager parameters, string resourceGroupName, string networkManagerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(parameters, resourceGroupName, networkManagerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + public static void Delete(this INetworkManagersOperations operations, string resourceGroupName, string networkManagerName) + { + operations.DeleteAsync(resourceGroupName, networkManagerName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a network manager. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this INetworkManagersOperations operations, string resourceGroupName, string networkManagerName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkManagerName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Patch a NetworkManager Tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to update network manager tags. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + public static NetworkManager PatchTags(this INetworkManagersOperations operations, TagsObject parameters, string resourceGroupName, string networkManagerName) + { + return operations.PatchTagsAsync(parameters, resourceGroupName, networkManagerName).GetAwaiter().GetResult(); + } + + /// + /// Patch a NetworkManager Tags. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Parameters supplied to update network manager tags. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The cancellation token. + /// + public static async Task PatchTagsAsync(this INetworkManagersOperations operations, TagsObject parameters, string resourceGroupName, string networkManagerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.PatchTagsWithHttpMessagesAsync(parameters, resourceGroupName, networkManagerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all network managers in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage ListBySubscription(this INetworkManagersOperations operations, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListBySubscriptionAsync(top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// List all network managers in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this INetworkManagersOperations operations, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List network managers in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this INetworkManagersOperations operations, string resourceGroupName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// List network managers in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this INetworkManagersOperations operations, string resourceGroupName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all network managers in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this INetworkManagersOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all network managers in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this INetworkManagersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List network managers in 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 INetworkManagersOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List network managers in 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 INetworkManagersOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/PublicIpAddressesOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/PublicIPAddressesOperations.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/PublicIpAddressesOperations.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/PublicIPAddressesOperations.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/PublicIpAddressesOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/PublicIPAddressesOperationsExtensions.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/PublicIpAddressesOperationsExtensions.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/PublicIPAddressesOperationsExtensions.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SdkInfo_NetworkManagementClient.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SdkInfo_NetworkManagementClient.cs index ab9e4f76798a4..c4c4ba5285856 100644 --- a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SdkInfo_NetworkManagementClient.cs +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SdkInfo_NetworkManagementClient.cs @@ -23,6 +23,8 @@ public static IEnumerable> ApiInfo_NetworkManageme new Tuple("Compute", "NetworkInterfaces", "2020-08-01"), new Tuple("Compute", "PublicIPAddresses", "2018-10-01"), new Tuple("Compute", "PublicIPAddresses", "2020-08-01"), + new Tuple("Network", "ActiveConfigurations", "2021-02-01-preview"), + new Tuple("Network", "AdminRules", "2021-02-01-preview"), new Tuple("Network", "ApplicationGatewayPrivateEndpointConnections", "2020-08-01"), new Tuple("Network", "ApplicationGatewayPrivateLinkResources", "2020-08-01"), new Tuple("Network", "ApplicationGateways", "2020-08-01"), @@ -38,6 +40,7 @@ public static IEnumerable> ApiInfo_NetworkManageme new Tuple("Network", "BgpServiceCommunities", "2020-08-01"), new Tuple("Network", "CheckDnsNameAvailability", "2020-08-01"), new Tuple("Network", "ConnectionMonitors", "2020-08-01"), + new Tuple("Network", "ConnectivityConfigurations", "2021-02-01-preview"), new Tuple("Network", "CustomIPPrefixes", "2020-08-01"), new Tuple("Network", "DdosCustomPolicies", "2020-08-01"), new Tuple("Network", "DdosProtectionPlans", "2020-08-01"), @@ -45,6 +48,8 @@ public static IEnumerable> ApiInfo_NetworkManageme new Tuple("Network", "DeleteBastionShareableLink", "2020-08-01"), new Tuple("Network", "DisconnectActiveSessions", "2020-08-01"), new Tuple("Network", "DscpConfiguration", "2020-08-01"), + new Tuple("Network", "EffectiveConfigurations", "2021-02-01-preview"), + new Tuple("Network", "EffectiveVirtualNetworks", "2021-02-01-preview"), new Tuple("Network", "ExpressRouteCircuitAuthorizations", "2020-08-01"), new Tuple("Network", "ExpressRouteCircuitConnections", "2020-08-01"), new Tuple("Network", "ExpressRouteCircuitPeerings", "2020-08-01"), @@ -78,10 +83,14 @@ public static IEnumerable> ApiInfo_NetworkManageme new Tuple("Network", "LocalNetworkGateways", "2020-08-01"), new Tuple("Network", "NatGateways", "2020-08-01"), new Tuple("Network", "NatRules", "2020-08-01"), + new Tuple("Network", "NetworkGroups", "2021-02-01-preview"), new Tuple("Network", "NetworkInterfaceIPConfigurations", "2020-08-01"), new Tuple("Network", "NetworkInterfaceLoadBalancers", "2020-08-01"), new Tuple("Network", "NetworkInterfaceTapConfigurations", "2020-08-01"), new Tuple("Network", "NetworkInterfaces", "2020-08-01"), + new Tuple("Network", "NetworkManagerCommits", "2021-02-01-preview"), + new Tuple("Network", "NetworkManagerDeploymentStatus", "2021-02-01-preview"), + new Tuple("Network", "NetworkManagers", "2021-02-01-preview"), new Tuple("Network", "NetworkProfiles", "2020-08-01"), new Tuple("Network", "NetworkSecurityGroups", "2020-08-01"), new Tuple("Network", "NetworkVirtualAppliances", "2020-08-01"), @@ -102,6 +111,7 @@ public static IEnumerable> ApiInfo_NetworkManageme new Tuple("Network", "RouteFilters", "2020-08-01"), new Tuple("Network", "RouteTables", "2020-08-01"), new Tuple("Network", "Routes", "2020-08-01"), + new Tuple("Network", "SecurityConfigurations", "2021-02-01-preview"), new Tuple("Network", "SecurityPartnerProviders", "2020-08-01"), new Tuple("Network", "SecurityRules", "2020-08-01"), new Tuple("Network", "ServiceAssociationLinks", "2020-08-01"), @@ -111,6 +121,7 @@ public static IEnumerable> ApiInfo_NetworkManageme new Tuple("Network", "Subnets", "2020-08-01"), new Tuple("Network", "SupportedSecurityProviders", "2020-08-01"), new Tuple("Network", "Usages", "2020-08-01"), + new Tuple("Network", "UserRules", "2021-02-01-preview"), new Tuple("Network", "VirtualApplianceSites", "2020-08-01"), new Tuple("Network", "VirtualApplianceSkus", "2020-08-01"), new Tuple("Network", "VirtualHubBgpConnection", "2020-08-01"), @@ -141,16 +152,5 @@ public static IEnumerable> ApiInfo_NetworkManageme }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/network/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\\Projects\\Generator\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "34f7a6a94a5edfe32bc914f56443b980f582e599"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SecurityConfigurationsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SecurityConfigurationsOperations.cs new file mode 100644 index 0000000000000..c69b7e446919d --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SecurityConfigurationsOperations.cs @@ -0,0 +1,1706 @@ +// +// 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.Network +{ + 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; + + /// + /// SecurityConfigurationsOperations operations. + /// + internal partial class SecurityConfigurationsOperations : IServiceOperations, ISecurityConfigurationsOperations + { + /// + /// Initializes a new instance of the SecurityConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SecurityConfigurationsOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Lists all the network manager security configurations in a network manager, + /// in a paginated format. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + 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.Network/networkManagers/{networkManagerName}/securityConfigurations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // 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; + } + + /// + /// Imports network security rules to network manager security rules. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import Security configuration parameter + /// + /// + /// 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> ImportWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Import", 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/import").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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; + } + + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import security configuration parameter + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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>> EvaluateImportWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "EvaluateImport", 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/evaluateImport").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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; + } + + /// + /// Retrieves a network manager security Configuration. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates a network manager security Configuration. + /// + /// + /// The security configuration to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(SecurityConfiguration securityConfiguration, string resourceGroupName, string networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (securityConfiguration == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "securityConfiguration"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("securityConfiguration", securityConfiguration); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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(securityConfiguration != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(securityConfiguration, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a network manager security Configuration. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// 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 networkManagerName, string configurationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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; + } + + /// + /// Lists all the network manager security configurations in a network manager, + /// in a paginated format. + /// + /// + /// 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 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(); + } + // 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; + } + + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// 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>> EvaluateImportNextWithHttpMessagesAsync(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, "EvaluateImportNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/SecurityConfigurationsOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SecurityConfigurationsOperationsExtensions.cs new file mode 100644 index 0000000000000..1675fa1ae11b4 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/SecurityConfigurationsOperationsExtensions.cs @@ -0,0 +1,422 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SecurityConfigurationsOperations. + /// + public static partial class SecurityConfigurationsOperationsExtensions + { + /// + /// Lists all the network manager security configurations in a network manager, + /// in a paginated format. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, networkManagerName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Lists all the network manager security configurations in a network manager, + /// in a paginated format. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkManagerName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Imports network security rules to network manager security rules. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import Security configuration parameter + /// + public static SecurityConfigurationImportResult Import(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters) + { + return operations.ImportAsync(resourceGroupName, networkManagerName, configurationName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Imports network security rules to network manager security rules. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import Security configuration parameter + /// + /// + /// The cancellation token. + /// + public static async Task ImportAsync(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ImportWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import security configuration parameter + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage EvaluateImport(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters, int? top = default(int?), string skipToken = default(string)) + { + return operations.EvaluateImportAsync(resourceGroupName, networkManagerName, configurationName, parameters, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// Import security configuration parameter + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> EvaluateImportAsync(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, NetworkManagerSecurityConfigurationImport parameters, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.EvaluateImportWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, parameters, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves a network manager security Configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + public static SecurityConfiguration Get(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName) + { + return operations.GetAsync(resourceGroupName, networkManagerName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Retrieves a network manager security Configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a network manager security Configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The security configuration to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + public static SecurityConfiguration CreateOrUpdate(this ISecurityConfigurationsOperations operations, SecurityConfiguration securityConfiguration, string resourceGroupName, string networkManagerName, string configurationName) + { + return operations.CreateOrUpdateAsync(securityConfiguration, resourceGroupName, networkManagerName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a network manager security Configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The security configuration to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ISecurityConfigurationsOperations operations, SecurityConfiguration securityConfiguration, string resourceGroupName, string networkManagerName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(securityConfiguration, resourceGroupName, networkManagerName, configurationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a network manager security Configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + public static void Delete(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName) + { + operations.DeleteAsync(resourceGroupName, networkManagerName, configurationName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a network manager security Configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISecurityConfigurationsOperations operations, string resourceGroupName, string networkManagerName, string configurationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all the network manager security configurations in a network manager, + /// in a paginated format. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISecurityConfigurationsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all the network manager security configurations in a network manager, + /// in a paginated format. + /// + /// + /// 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 ISecurityConfigurationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage EvaluateImportNext(this ISecurityConfigurationsOperations operations, string nextPageLink) + { + return operations.EvaluateImportNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// The operation to evaluate import NSG to security configurations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> EvaluateImportNextAsync(this ISecurityConfigurationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.EvaluateImportNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/UserRulesOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/UserRulesOperations.cs new file mode 100644 index 0000000000000..4bcac5bc61b91 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/UserRulesOperations.cs @@ -0,0 +1,1109 @@ +// +// 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.Network +{ + 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; + + /// + /// UserRulesOperations operations. + /// + internal partial class UserRulesOperations : IServiceOperations, IUserRulesOperations + { + /// + /// Initializes a new instance of the UserRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal UserRulesOperations(NetworkManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the NetworkManagementClient + /// + public NetworkManagementClient Client { get; private set; } + + /// + /// Lists all user rules in a security configuration. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// 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, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (top > 20) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "top", 20); + } + if (top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "top", 1); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/userRules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a user rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/userRules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates a user rule. + /// + /// + /// The user rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(UserRule userRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userRule == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userRule"); + } + if (userRule != null) + { + userRule.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("userRule", userRule); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/userRules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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(userRule != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(userRule, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new 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(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a user rule. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string networkManagerName, string configurationName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (networkManagerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "networkManagerName"); + } + if (configurationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "configurationName"); + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2021-02-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("networkManagerName", networkManagerName); + tracingParameters.Add("configurationName", configurationName); + tracingParameters.Add("ruleName", ruleName); + 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.Network/networkManagers/{networkManagerName}/securityConfigurations/{configurationName}/userRules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{networkManagerName}", System.Uri.EscapeDataString(networkManagerName)); + _url = _url.Replace("{configurationName}", System.Uri.EscapeDataString(configurationName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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; + } + + /// + /// Lists all user rules in a security configuration. + /// + /// + /// 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 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(); + } + // 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/network/Microsoft.Azure.Management.Network/src/Generated/UserRulesOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/UserRulesOperationsExtensions.cs new file mode 100644 index 0000000000000..3c543cecc0a59 --- /dev/null +++ b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/UserRulesOperationsExtensions.cs @@ -0,0 +1,284 @@ +// +// 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.Network +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for UserRulesOperations. + /// + public static partial class UserRulesOperationsExtensions + { + /// + /// Lists all user rules in a security configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + public static IPage List(this IUserRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string)) + { + return operations.ListAsync(resourceGroupName, networkManagerName, configurationName, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Lists all user rules in a security configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// An optional query parameter which specifies the maximum number of records + /// to be returned by the server. + /// + /// + /// SkipToken is only used if a previous operation returned a partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a skipToken parameter that specifies a + /// starting point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IUserRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a user rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + public static UserRule Get(this IUserRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName) + { + return operations.GetAsync(resourceGroupName, networkManagerName, configurationName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Gets a user rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IUserRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates a user rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The user rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + public static UserRule CreateOrUpdate(this IUserRulesOperations operations, UserRule userRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName) + { + return operations.CreateOrUpdateAsync(userRule, resourceGroupName, networkManagerName, configurationName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a user rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The user rule to create or update + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IUserRulesOperations operations, UserRule userRule, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(userRule, resourceGroupName, networkManagerName, configurationName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a user rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + public static void Delete(this IUserRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName) + { + operations.DeleteAsync(resourceGroupName, networkManagerName, configurationName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a user rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the network manager. + /// + /// + /// The name of the network manager security Configuration. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IUserRulesOperations operations, string resourceGroupName, string networkManagerName, string configurationName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, networkManagerName, configurationName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Lists all user rules in a security configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IUserRulesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all user rules in a security configuration. + /// + /// + /// 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 IUserRulesOperations 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/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWANsOperations.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWansOperations.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWANsOperations.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWansOperations.cs diff --git a/sdk/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWANsOperationsExtensions.cs b/sdk/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWansOperationsExtensions.cs similarity index 100% rename from sdk/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWANsOperationsExtensions.cs rename to sdk/network/Microsoft.Azure.Management.Network/src/Generated/VirtualWansOperationsExtensions.cs