diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/CustomizationPoliciesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/CustomizationPoliciesOperations.cs new file mode 100644 index 000000000000..3f15178eac24 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/CustomizationPoliciesOperations.cs @@ -0,0 +1,631 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// CustomizationPoliciesOperations operations. + /// + internal partial class CustomizationPoliciesOperations : IServiceOperations, ICustomizationPoliciesOperations + { + /// + /// Initializes a new instance of the CustomizationPoliciesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal CustomizationPoliciesOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// The filter to apply on the list operation. only type is allowed here as a + /// filter e.g. $filter=type eq 'xxxx' + /// + /// + /// 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 regionId, string pcName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/customizationPolicies").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements get of customization policy + /// + /// + /// Returns customization policy by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// customization policy 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> GetWithHttpMessagesAsync(string regionId, string pcName, string customizationPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (customizationPolicyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "customizationPolicyName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("customizationPolicyName", customizationPolicyName); + 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}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/customizationPolicies/{customizationPolicyName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + _url = _url.Replace("{customizationPolicyName}", System.Uri.EscapeDataString(customizationPolicyName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/CustomizationPoliciesOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/CustomizationPoliciesOperationsExtensions.cs new file mode 100644 index 000000000000..f9b40d2c71a4 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/CustomizationPoliciesOperationsExtensions.cs @@ -0,0 +1,171 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for CustomizationPoliciesOperations. + /// + public static partial class CustomizationPoliciesOperationsExtensions + { + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// The filter to apply on the list operation. only type is allowed here as a + /// filter e.g. $filter=type eq 'xxxx' + /// + public static IPage List(this ICustomizationPoliciesOperations operations, string regionId, string pcName, string filter = default(string)) + { + return operations.ListAsync(regionId, pcName, filter).GetAwaiter().GetResult(); + } + + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// The filter to apply on the list operation. only type is allowed here as a + /// filter e.g. $filter=type eq 'xxxx' + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ICustomizationPoliciesOperations operations, string regionId, string pcName, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(regionId, pcName, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements get of customization policy + /// + /// + /// Returns customization policy by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// customization policy name + /// + public static CustomizationPolicy Get(this ICustomizationPoliciesOperations operations, string regionId, string pcName, string customizationPolicyName) + { + return operations.GetAsync(regionId, pcName, customizationPolicyName).GetAwaiter().GetResult(); + } + + /// + /// Implements get of customization policy + /// + /// + /// Returns customization policy by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// customization policy name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ICustomizationPoliciesOperations operations, string regionId, string pcName, string customizationPolicyName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(regionId, pcName, customizationPolicyName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ICustomizationPoliciesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// 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 ICustomizationPoliciesOperations 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudNodesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudNodesOperations.cs new file mode 100644 index 000000000000..c7c358300adc --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudNodesOperations.cs @@ -0,0 +1,1694 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// DedicatedCloudNodesOperations operations. + /// + internal partial class DedicatedCloudNodesOperations : IServiceOperations, IDedicatedCloudNodesOperations + { + /// + /// Initializes a new instance of the DedicatedCloudNodesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DedicatedCloudNodesOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within subscription + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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(string filter = default(string), 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + 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.VMwareCloudSimple/dedicatedCloudNodes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within resource group + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", 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.VMwareCloudSimple/dedicatedCloudNodes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements dedicated cloud node GET method + /// + /// + /// Returns dedicated cloud node + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node 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> GetWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudNodeName, 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 (dedicatedCloudNodeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudNodeName"); + } + if (dedicatedCloudNodeName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(dedicatedCloudNodeName, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "dedicatedCloudNodeName", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("dedicatedCloudNodeName", dedicatedCloudNodeName); + 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.VMwareCloudSimple/dedicatedCloudNodes/{dedicatedCloudNodeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudNodeName}", System.Uri.EscapeDataString(dedicatedCloudNodeName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, referer, dedicatedCloudNodeName, dedicatedCloudNodeRequest, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements dedicated cloud node DELETE method + /// + /// + /// Delete dedicated cloud node + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// 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 dedicatedCloudNodeName, 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 (dedicatedCloudNodeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudNodeName"); + } + if (dedicatedCloudNodeName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(dedicatedCloudNodeName, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "dedicatedCloudNodeName", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("dedicatedCloudNodeName", dedicatedCloudNodeName); + 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.VMwareCloudSimple/dedicatedCloudNodes/{dedicatedCloudNodeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudNodeName}", System.Uri.EscapeDataString(dedicatedCloudNodeName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + 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; + } + + /// + /// Implements dedicated cloud node PATCH method + /// + /// + /// Patches dedicated node properties + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// The tags key:value pairs + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudNodeName, IDictionary tags = default(IDictionary), 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 (dedicatedCloudNodeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudNodeName"); + } + if (dedicatedCloudNodeName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(dedicatedCloudNodeName, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "dedicatedCloudNodeName", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + PatchPayload dedicatedCloudNodeRequest = new PatchPayload(); + if (tags != null) + { + dedicatedCloudNodeRequest.Tags = tags; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("dedicatedCloudNodeName", dedicatedCloudNodeName); + tracingParameters.Add("dedicatedCloudNodeRequest", dedicatedCloudNodeRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.VMwareCloudSimple/dedicatedCloudNodes/{dedicatedCloudNodeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudNodeName}", System.Uri.EscapeDataString(dedicatedCloudNodeName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(dedicatedCloudNodeRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(dedicatedCloudNodeRequest, 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest, 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 (referer == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "referer"); + } + if (dedicatedCloudNodeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudNodeName"); + } + if (dedicatedCloudNodeName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(dedicatedCloudNodeName, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "dedicatedCloudNodeName", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (dedicatedCloudNodeRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudNodeRequest"); + } + if (dedicatedCloudNodeRequest != null) + { + dedicatedCloudNodeRequest.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("referer", referer); + tracingParameters.Add("dedicatedCloudNodeName", dedicatedCloudNodeName); + tracingParameters.Add("dedicatedCloudNodeRequest", dedicatedCloudNodeRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/{dedicatedCloudNodeName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudNodeName}", System.Uri.EscapeDataString(dedicatedCloudNodeName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (referer != null) + { + if (_httpRequest.Headers.Contains("Referer")) + { + _httpRequest.Headers.Remove("Referer"); + } + _httpRequest.Headers.TryAddWithoutValidation("Referer", referer); + } + 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(dedicatedCloudNodeRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(dedicatedCloudNodeRequest, 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + 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; + } + + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within 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>> ListByResourceGroupNextWithHttpMessagesAsync(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, "ListByResourceGroupNext", 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudNodesOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudNodesOperationsExtensions.cs new file mode 100644 index 000000000000..755570c9fe6e --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudNodesOperationsExtensions.cs @@ -0,0 +1,477 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DedicatedCloudNodesOperations. + /// + public static partial class DedicatedCloudNodesOperationsExtensions + { + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + public static IPage ListBySubscription(this IDedicatedCloudNodesOperations operations, string filter = default(string), int? top = default(int?), string skipToken = default(string)) + { + return operations.ListBySubscriptionAsync(filter, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IDedicatedCloudNodesOperations operations, string filter = default(string), int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(filter, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + public static IPage ListByResourceGroup(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicated cloud node GET method + /// + /// + /// Returns dedicated cloud node + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + public static DedicatedCloudNode Get(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string dedicatedCloudNodeName) + { + return operations.GetAsync(resourceGroupName, dedicatedCloudNodeName).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicated cloud node GET method + /// + /// + /// Returns dedicated cloud node + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string dedicatedCloudNodeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, dedicatedCloudNodeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + public static DedicatedCloudNode CreateOrUpdate(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest) + { + return operations.CreateOrUpdateAsync(resourceGroupName, referer, dedicatedCloudNodeName, dedicatedCloudNodeRequest).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, referer, dedicatedCloudNodeName, dedicatedCloudNodeRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicated cloud node DELETE method + /// + /// + /// Delete dedicated cloud node + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + public static DedicatedCloudNodesDeleteHeaders Delete(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string dedicatedCloudNodeName) + { + return operations.DeleteAsync(resourceGroupName, dedicatedCloudNodeName).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicated cloud node DELETE method + /// + /// + /// Delete dedicated cloud node + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string dedicatedCloudNodeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, dedicatedCloudNodeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements dedicated cloud node PATCH method + /// + /// + /// Patches dedicated node properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// The tags key:value pairs + /// + public static DedicatedCloudNode Update(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string dedicatedCloudNodeName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, dedicatedCloudNodeName, tags).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicated cloud node PATCH method + /// + /// + /// Patches dedicated node properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// The tags key:value pairs + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string dedicatedCloudNodeName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, dedicatedCloudNodeName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + public static DedicatedCloudNode BeginCreateOrUpdate(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, referer, dedicatedCloudNodeName, dedicatedCloudNodeRequest).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IDedicatedCloudNodesOperations operations, string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, referer, dedicatedCloudNodeName, dedicatedCloudNodeRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IDedicatedCloudNodesOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within 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 IDedicatedCloudNodesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IDedicatedCloudNodesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within 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> ListByResourceGroupNextAsync(this IDedicatedCloudNodesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudServicesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudServicesOperations.cs new file mode 100644 index 000000000000..6dbaccdeb020 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudServicesOperations.cs @@ -0,0 +1,1638 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// DedicatedCloudServicesOperations operations. + /// + internal partial class DedicatedCloudServicesOperations : IServiceOperations, IDedicatedCloudServicesOperations + { + /// + /// Initializes a new instance of the DedicatedCloudServicesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DedicatedCloudServicesOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements list of dedicatedCloudService objects within subscription method + /// + /// + /// Returns list of dedicated cloud services within a subscription + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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(string filter = default(string), 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + 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.VMwareCloudSimple/dedicatedCloudServices").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", 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.VMwareCloudSimple/dedicatedCloudServices").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements dedicatedCloudService GET method + /// + /// + /// Returns Dedicate Cloud Service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service 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> GetWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, 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 (dedicatedCloudServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudServiceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("dedicatedCloudServiceName", dedicatedCloudServiceName); + 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.VMwareCloudSimple/dedicatedCloudServices/{dedicatedCloudServiceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudServiceName}", System.Uri.EscapeDataString(dedicatedCloudServiceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements dedicated cloud service PUT method + /// + /// + /// Create dedicate cloud service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service name + /// + /// + /// Create Dedicated Cloud Service request + /// + /// + /// 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(string resourceGroupName, string dedicatedCloudServiceName, DedicatedCloudService dedicatedCloudServiceRequest, 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 (dedicatedCloudServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudServiceName"); + } + if (dedicatedCloudServiceName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(dedicatedCloudServiceName, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "dedicatedCloudServiceName", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (dedicatedCloudServiceRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudServiceRequest"); + } + if (dedicatedCloudServiceRequest != null) + { + dedicatedCloudServiceRequest.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("dedicatedCloudServiceName", dedicatedCloudServiceName); + tracingParameters.Add("dedicatedCloudServiceRequest", dedicatedCloudServiceRequest); + 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.VMwareCloudSimple/dedicatedCloudServices/{dedicatedCloudServiceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudServiceName}", System.Uri.EscapeDataString(dedicatedCloudServiceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(dedicatedCloudServiceRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(dedicatedCloudServiceRequest, 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, dedicatedCloudServiceName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements dedicatedCloudService PATCH method + /// + /// + /// Patch dedicated cloud service's properties + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The tags key:value pairs + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, IDictionary tags = default(IDictionary), 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 (dedicatedCloudServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudServiceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + PatchPayload dedicatedCloudServiceRequest = new PatchPayload(); + if (tags != null) + { + dedicatedCloudServiceRequest.Tags = tags; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("dedicatedCloudServiceName", dedicatedCloudServiceName); + tracingParameters.Add("dedicatedCloudServiceRequest", dedicatedCloudServiceRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.VMwareCloudSimple/dedicatedCloudServices/{dedicatedCloudServiceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudServiceName}", System.Uri.EscapeDataString(dedicatedCloudServiceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(dedicatedCloudServiceRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(dedicatedCloudServiceRequest, 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, 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 (dedicatedCloudServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "dedicatedCloudServiceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("dedicatedCloudServiceName", dedicatedCloudServiceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/{dedicatedCloudServiceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{dedicatedCloudServiceName}", System.Uri.EscapeDataString(dedicatedCloudServiceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + 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; + } + + /// + /// Implements list of dedicatedCloudService objects within subscription method + /// + /// + /// Returns list of dedicated cloud services within 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupNextWithHttpMessagesAsync(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, "ListByResourceGroupNext", 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudServicesOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudServicesOperationsExtensions.cs new file mode 100644 index 000000000000..5986f3e7406c --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/DedicatedCloudServicesOperationsExtensions.cs @@ -0,0 +1,459 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DedicatedCloudServicesOperations. + /// + public static partial class DedicatedCloudServicesOperationsExtensions + { + /// + /// Implements list of dedicatedCloudService objects within subscription method + /// + /// + /// Returns list of dedicated cloud services within a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + public static IPage ListBySubscription(this IDedicatedCloudServicesOperations operations, string filter = default(string), int? top = default(int?), string skipToken = default(string)) + { + return operations.ListBySubscriptionAsync(filter, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicatedCloudService objects within subscription method + /// + /// + /// Returns list of dedicated cloud services within a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IDedicatedCloudServicesOperations operations, string filter = default(string), int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(filter, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + public static IPage ListByResourceGroup(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicatedCloudService GET method + /// + /// + /// Returns Dedicate Cloud Service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service name + /// + public static DedicatedCloudService Get(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName) + { + return operations.GetAsync(resourceGroupName, dedicatedCloudServiceName).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicatedCloudService GET method + /// + /// + /// Returns Dedicate Cloud Service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, dedicatedCloudServiceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicated cloud service PUT method + /// + /// + /// Create dedicate cloud service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service name + /// + /// + /// Create Dedicated Cloud Service request + /// + public static DedicatedCloudService CreateOrUpdate(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName, DedicatedCloudService dedicatedCloudServiceRequest) + { + return operations.CreateOrUpdateAsync(resourceGroupName, dedicatedCloudServiceName, dedicatedCloudServiceRequest).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicated cloud service PUT method + /// + /// + /// Create dedicate cloud service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service name + /// + /// + /// Create Dedicated Cloud Service request + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName, DedicatedCloudService dedicatedCloudServiceRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, dedicatedCloudServiceName, dedicatedCloudServiceRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + public static DedicatedCloudServicesDeleteHeaders Delete(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName) + { + return operations.DeleteAsync(resourceGroupName, dedicatedCloudServiceName).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, dedicatedCloudServiceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements dedicatedCloudService PATCH method + /// + /// + /// Patch dedicated cloud service's properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The tags key:value pairs + /// + public static DedicatedCloudService Update(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, dedicatedCloudServiceName, tags).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicatedCloudService PATCH method + /// + /// + /// Patch dedicated cloud service's properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The tags key:value pairs + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, dedicatedCloudServiceName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + public static DedicatedCloudServicesDeleteHeaders BeginDelete(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName) + { + return operations.BeginDeleteAsync(resourceGroupName, dedicatedCloudServiceName).GetAwaiter().GetResult(); + } + + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IDedicatedCloudServicesOperations operations, string resourceGroupName, string dedicatedCloudServiceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, dedicatedCloudServiceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements list of dedicatedCloudService objects within subscription method + /// + /// + /// Returns list of dedicated cloud services within a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IDedicatedCloudServicesOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicatedCloudService objects within subscription method + /// + /// + /// Returns list of dedicated cloud services within 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 IDedicatedCloudServicesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IDedicatedCloudServicesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IDedicatedCloudServicesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ICustomizationPoliciesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ICustomizationPoliciesOperations.cs new file mode 100644 index 000000000000..5802f25b7641 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ICustomizationPoliciesOperations.cs @@ -0,0 +1,115 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// CustomizationPoliciesOperations operations. + /// + public partial interface ICustomizationPoliciesOperations + { + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// The filter to apply on the list operation. only type is allowed + /// here as a filter e.g. $filter=type eq 'xxxx' + /// + /// + /// 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 regionId, string pcName, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements get of customization policy + /// + /// + /// Returns customization policy by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// customization policy 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> GetWithHttpMessagesAsync(string regionId, string pcName, string customizationPolicyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements get of customization policies list + /// + /// + /// Returns list of customization policies in region for private cloud + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IDedicatedCloudNodesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IDedicatedCloudNodesOperations.cs new file mode 100644 index 000000000000..de311e9188b5 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IDedicatedCloudNodesOperations.cs @@ -0,0 +1,294 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DedicatedCloudNodesOperations operations. + /// + public partial interface IDedicatedCloudNodesOperations + { + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within subscription + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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(string filter = default(string), int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within resource group + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicated cloud node GET method + /// + /// + /// Returns dedicated cloud node + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node 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> GetWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudNodeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicated cloud node DELETE method + /// + /// + /// Delete dedicated cloud node + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// 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 dedicatedCloudNodeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicated cloud node PATCH method + /// + /// + /// Patches dedicated node properties + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud node name + /// + /// + /// The tags key:value pairs + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudNodeName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicated cloud node PUT method + /// + /// + /// Returns dedicated cloud node by its name + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// dedicated cloud node name + /// + /// + /// Create Dedicated Cloud Node request + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string dedicatedCloudNodeName, DedicatedCloudNode dedicatedCloudNodeRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list of dedicated cloud nodes within subscription method + /// + /// + /// Returns list of dedicate cloud nodes within 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)); + /// + /// Implements list of dedicated cloud nodes within RG method + /// + /// + /// Returns list of dedicate cloud nodes within 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>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IDedicatedCloudServicesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IDedicatedCloudServicesOperations.cs new file mode 100644 index 000000000000..84bb6ec0ead1 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IDedicatedCloudServicesOperations.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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DedicatedCloudServicesOperations operations. + /// + public partial interface IDedicatedCloudServicesOperations + { + /// + /// Implements list of dedicatedCloudService objects within + /// subscription method + /// + /// + /// Returns list of dedicated cloud services within a subscription + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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(string filter = default(string), int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicatedCloudService GET method + /// + /// + /// Returns Dedicate Cloud Service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service 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> GetWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicated cloud service PUT method + /// + /// + /// Create dedicate cloud service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud Service name + /// + /// + /// Create Dedicated Cloud Service request + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, DedicatedCloudService dedicatedCloudServiceRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// 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 dedicatedCloudServiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicatedCloudService PATCH method + /// + /// + /// Patch dedicated cloud service's properties + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The tags key:value pairs + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements dedicatedCloudService DELETE method + /// + /// + /// Delete dedicate cloud service + /// + /// + /// The name of the resource group + /// + /// + /// dedicated cloud service name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string dedicatedCloudServiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list of dedicatedCloudService objects within + /// subscription method + /// + /// + /// Returns list of dedicated cloud services within 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)); + /// + /// Implements list of dedicatedCloudService objects within RG method + /// + /// + /// Returns list of dedicated cloud services within a resource group + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IOperations.cs new file mode 100644 index 000000000000..110f04017f65 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IOperations.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements get of async operation + /// + /// + /// Return an async operation + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// referer url + /// + /// + /// operation id + /// + /// + /// 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 regionId, string referer, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IPrivateCloudsOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IPrivateCloudsOperations.cs new file mode 100644 index 000000000000..c638946147cd --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IPrivateCloudsOperations.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateCloudsOperations operations. + /// + public partial interface IPrivateCloudsOperations + { + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// 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 regionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements private cloud GET method + /// + /// + /// Returns private cloud by its name + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// 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 pcName, string regionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IResourcePoolsOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IResourcePoolsOperations.cs new file mode 100644 index 000000000000..8242b5d5eafd --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IResourcePoolsOperations.cs @@ -0,0 +1,111 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ResourcePoolsOperations operations. + /// + public partial interface IResourcePoolsOperations + { + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud 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 regionId, string pcName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements get of resource pool + /// + /// + /// Returns resource pool templates by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// resource pool id (vsphereId) + /// + /// + /// 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 regionId, string pcName, string resourcePoolName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ISkusAvailabilityOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ISkusAvailabilityOperations.cs new file mode 100644 index 000000000000..75a2c4ce220f --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ISkusAvailabilityOperations.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SkusAvailabilityOperations operations. + /// + public partial interface ISkusAvailabilityOperations + { + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// sku id, if no sku is passed availability for all skus will be + /// returned + /// + /// + /// 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 regionId, string skuId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IUsagesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IUsagesOperations.cs new file mode 100644 index 000000000000..8bcf6f9a2892 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IUsagesOperations.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// UsagesOperations operations. + /// + public partial interface IUsagesOperations + { + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The filter to apply on the list operation. only name.value is + /// allowed here as a filter e.g. $filter=name.value eq 'xxxx' + /// + /// + /// 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 regionId, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVMwareCloudSimpleClient.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVMwareCloudSimpleClient.cs new file mode 100644 index 000000000000..435ffda7a489 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVMwareCloudSimpleClient.cs @@ -0,0 +1,128 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Description of the new service + /// + public partial interface IVMwareCloudSimpleClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// The subscription ID. + /// + string SubscriptionId { get; set; } + + /// + /// Client API version. + /// + string ApiVersion { get; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IDedicatedCloudNodesOperations. + /// + IDedicatedCloudNodesOperations DedicatedCloudNodes { get; } + + /// + /// Gets the IDedicatedCloudServicesOperations. + /// + IDedicatedCloudServicesOperations DedicatedCloudServices { get; } + + /// + /// Gets the ISkusAvailabilityOperations. + /// + ISkusAvailabilityOperations SkusAvailability { get; } + + /// + /// Gets the IPrivateCloudsOperations. + /// + IPrivateCloudsOperations PrivateClouds { get; } + + /// + /// Gets the ICustomizationPoliciesOperations. + /// + ICustomizationPoliciesOperations CustomizationPolicies { get; } + + /// + /// Gets the IResourcePoolsOperations. + /// + IResourcePoolsOperations ResourcePools { get; } + + /// + /// Gets the IVirtualMachineTemplatesOperations. + /// + IVirtualMachineTemplatesOperations VirtualMachineTemplates { get; } + + /// + /// Gets the IVirtualNetworksOperations. + /// + IVirtualNetworksOperations VirtualNetworks { get; } + + /// + /// Gets the IUsagesOperations. + /// + IUsagesOperations Usages { get; } + + /// + /// Gets the IVirtualMachinesOperations. + /// + IVirtualMachinesOperations VirtualMachines { get; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualMachineTemplatesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualMachineTemplatesOperations.cs new file mode 100644 index 000000000000..ec734ae8d9a8 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualMachineTemplatesOperations.cs @@ -0,0 +1,117 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// VirtualMachineTemplatesOperations operations. + /// + public partial interface IVirtualMachineTemplatesOperations + { + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private + /// cloud + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// Resource pool used to derive vSphere cluster which contains VM + /// templates + /// + /// + /// 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 pcName, string regionId, string resourcePoolName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine template GET method + /// + /// + /// Returns virtual machine templates by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual machine template id (vsphereId) + /// + /// + /// 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 regionId, string pcName, string virtualMachineTemplateName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private + /// cloud + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualMachinesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualMachinesOperations.cs new file mode 100644 index 000000000000..cbab6d7f908a --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualMachinesOperations.cs @@ -0,0 +1,488 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// VirtualMachinesOperations operations. + /// + public partial interface IVirtualMachinesOperations + { + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within subscription + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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(string filter = default(string), int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within resource group + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine GET method + /// + /// + /// Get virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine 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> GetWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// 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 referer, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// 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> StartWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements shutdown, poweroff, and suspend method for a virtual + /// machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible + /// values include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown + /// or power-off. Possible values include: 'reboot', 'suspend', + /// 'shutdown', 'poweroff' + /// + /// + /// 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> StopWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// 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> BeginStartWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements shutdown, poweroff, and suspend method for a virtual + /// machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible + /// values include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown + /// or power-off. Possible values include: 'reboot', 'suspend', + /// 'shutdown', 'poweroff' + /// + /// + /// 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> BeginStopWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within 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)); + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within 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>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualNetworksOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualNetworksOperations.cs new file mode 100644 index 000000000000..030cc47f3563 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/IVirtualNetworksOperations.cs @@ -0,0 +1,117 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// VirtualNetworksOperations operations. + /// + public partial interface IVirtualNetworksOperations + { + /// + /// Implements list available virtual networks within a subscription + /// method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// Resource pool used to derive vSphere cluster which contains virtual + /// networks + /// + /// + /// 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 regionId, string pcName, string resourcePoolName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual network GET method + /// + /// + /// Return virtual network by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual network id (vsphereId) + /// + /// + /// 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 regionId, string pcName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements list available virtual networks within a subscription + /// method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AggregationType.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AggregationType.cs new file mode 100644 index 000000000000..8f2735b5855a --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AggregationType.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for AggregationType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum AggregationType + { + [EnumMember(Value = "Average")] + Average, + [EnumMember(Value = "Total")] + Total + } + internal static class AggregationTypeEnumExtension + { + internal static string ToSerializedValue(this AggregationType? value) + { + return value == null ? null : ((AggregationType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this AggregationType value) + { + switch( value ) + { + case AggregationType.Average: + return "Average"; + case AggregationType.Total: + return "Total"; + } + return null; + } + + internal static AggregationType? ParseAggregationType(this string value) + { + switch( value ) + { + case "Average": + return AggregationType.Average; + case "Total": + return AggregationType.Total; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperation.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperation.cs new file mode 100644 index 000000000000..bcff1061bceb --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperation.cs @@ -0,0 +1,93 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource provider available operation model + /// + [Rest.Serialization.JsonTransformation] + public partial class AvailableOperation + { + /// + /// Initializes a new instance of the AvailableOperation class. + /// + public AvailableOperation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AvailableOperation class. + /// + /// The list of operations + /// Indicating whether the operation is a + /// data action or not + /// {resourceProviderNamespace}/{resourceType}/{read|write|delete|action} + /// The origin of operation. Possible values + /// include: 'user', 'system', 'user,system' + /// The list of specification's + /// service metrics + public AvailableOperation(AvailableOperationDisplay display = default(AvailableOperationDisplay), bool? isDataAction = default(bool?), string name = default(string), OperationOrigin? origin = default(OperationOrigin?), AvailableOperationDisplayPropertyServiceSpecificationMetricsList serviceSpecification = default(AvailableOperationDisplayPropertyServiceSpecificationMetricsList)) + { + Display = display; + IsDataAction = isDataAction; + Name = name; + Origin = origin; + ServiceSpecification = serviceSpecification; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of operations + /// + [JsonProperty(PropertyName = "display")] + public AvailableOperationDisplay Display { get; set; } + + /// + /// Gets or sets indicating whether the operation is a data action or + /// not + /// + [JsonProperty(PropertyName = "isDataAction")] + public bool? IsDataAction { get; set; } + + /// + /// Gets or sets + /// {resourceProviderNamespace}/{resourceType}/{read|write|delete|action} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the origin of operation. Possible values include: + /// 'user', 'system', 'user,system' + /// + [JsonProperty(PropertyName = "origin")] + public OperationOrigin? Origin { get; set; } + + /// + /// Gets or sets the list of specification's service metrics + /// + [JsonProperty(PropertyName = "properties.serviceSpecification")] + public AvailableOperationDisplayPropertyServiceSpecificationMetricsList ServiceSpecification { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplay.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplay.cs new file mode 100644 index 000000000000..fb1039039147 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplay.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource provider available operation display model + /// + public partial class AvailableOperationDisplay + { + /// + /// Initializes a new instance of the AvailableOperationDisplay class. + /// + public AvailableOperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AvailableOperationDisplay class. + /// + /// Description of the operation for display + /// purposes + /// Name of the operation for display + /// purposes + /// Name of the provider for display + /// purposes + /// Name of the resource type for display + /// purposes + public AvailableOperationDisplay(string description = default(string), string operation = default(string), string provider = default(string), string resource = default(string)) + { + Description = description; + Operation = operation; + Provider = provider; + Resource = resource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets description of the operation for display purposes + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets name of the operation for display purposes + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets name of the provider for display purposes + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets name of the resource type for display purposes + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplayPropertyServiceSpecificationMetricsItem.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplayPropertyServiceSpecificationMetricsItem.cs new file mode 100644 index 000000000000..0d1394110135 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplayPropertyServiceSpecificationMetricsItem.cs @@ -0,0 +1,116 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Available operation display property service specification metrics item + /// + public partial class AvailableOperationDisplayPropertyServiceSpecificationMetricsItem + { + /// + /// Initializes a new instance of the + /// AvailableOperationDisplayPropertyServiceSpecificationMetricsItem + /// class. + /// + public AvailableOperationDisplayPropertyServiceSpecificationMetricsItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// AvailableOperationDisplayPropertyServiceSpecificationMetricsItem + /// class. + /// + /// Metric's aggregation type for e.g. + /// (Average, Total). Possible values include: 'Average', + /// 'Total' + /// Metric's description + /// Human readable metric's name + /// Metric's name/id + /// Metric's unit + public AvailableOperationDisplayPropertyServiceSpecificationMetricsItem(AggregationType aggregationType, string displayDescription, string displayName, string name, string unit) + { + AggregationType = aggregationType; + DisplayDescription = displayDescription; + DisplayName = displayName; + Name = name; + Unit = unit; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets metric's aggregation type for e.g. (Average, Total). + /// Possible values include: 'Average', 'Total' + /// + [JsonProperty(PropertyName = "aggregationType")] + public AggregationType AggregationType { get; set; } + + /// + /// Gets or sets metric's description + /// + [JsonProperty(PropertyName = "displayDescription")] + public string DisplayDescription { get; set; } + + /// + /// Gets or sets human readable metric's name + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets metric's name/id + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets metric's unit + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DisplayDescription == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DisplayDescription"); + } + if (DisplayName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DisplayName"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Unit == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Unit"); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplayPropertyServiceSpecificationMetricsList.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplayPropertyServiceSpecificationMetricsList.cs new file mode 100644 index 000000000000..a01879dc8d8e --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/AvailableOperationDisplayPropertyServiceSpecificationMetricsList.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// List of available operation display property service specification + /// metrics + /// + public partial class AvailableOperationDisplayPropertyServiceSpecificationMetricsList + { + /// + /// Initializes a new instance of the + /// AvailableOperationDisplayPropertyServiceSpecificationMetricsList + /// class. + /// + public AvailableOperationDisplayPropertyServiceSpecificationMetricsList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// AvailableOperationDisplayPropertyServiceSpecificationMetricsList + /// class. + /// + /// Metric specifications of + /// operation + public AvailableOperationDisplayPropertyServiceSpecificationMetricsList(IList metricSpecifications = default(IList)) + { + MetricSpecifications = metricSpecifications; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets metric specifications of operation + /// + [JsonProperty(PropertyName = "metricSpecifications")] + public IList MetricSpecifications { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPError.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPError.cs new file mode 100644 index 000000000000..0861c370e198 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPError.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// General error model + /// + public partial class CSRPError + { + /// + /// Initializes a new instance of the CSRPError class. + /// + public CSRPError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CSRPError class. + /// + /// Error's body + public CSRPError(CSRPErrorBody error = default(CSRPErrorBody)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error's body + /// + [JsonProperty(PropertyName = "error")] + public CSRPErrorBody Error { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPErrorBody.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPErrorBody.cs new file mode 100644 index 000000000000..488e07331981 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPErrorBody.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error properties + /// + public partial class CSRPErrorBody + { + /// + /// Initializes a new instance of the CSRPErrorBody class. + /// + public CSRPErrorBody() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CSRPErrorBody class. + /// + /// Error's code + /// Error's details + /// Error's message + /// Error's target + public CSRPErrorBody(string code = default(string), IList details = default(IList), string message = default(string), string target = default(string)) + { + Code = code; + Details = details; + Message = message; + Target = target; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets error's code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets error's details + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; private set; } + + /// + /// Gets error's message + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets or sets error's target + /// + [JsonProperty(PropertyName = "target")] + public string Target { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPErrorException.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPErrorException.cs new file mode 100644 index 000000000000..8aba3a9dd968 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CSRPErrorException.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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with CSRPError information. + /// + public partial class CSRPErrorException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public CSRPError Body { get; set; } + + /// + /// Initializes a new instance of the CSRPErrorException class. + /// + public CSRPErrorException() + { + } + + /// + /// Initializes a new instance of the CSRPErrorException class. + /// + /// The exception message. + public CSRPErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the CSRPErrorException class. + /// + /// The exception message. + /// Inner exception. + public CSRPErrorException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationHostName.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationHostName.cs new file mode 100644 index 000000000000..1c367346a8f8 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationHostName.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Host name model + /// + public partial class CustomizationHostName + { + /// + /// Initializes a new instance of the CustomizationHostName class. + /// + public CustomizationHostName() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationHostName class. + /// + /// Hostname + /// Type of host name. Possible values include: + /// 'USER_DEFINED', 'PREFIX_BASED', 'FIXED', 'VIRTUAL_MACHINE_NAME', + /// 'CUSTOM_NAME' + public CustomizationHostName(string name = default(string), string type = default(string)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets hostname + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets type of host name. Possible values include: + /// 'USER_DEFINED', 'PREFIX_BASED', 'FIXED', 'VIRTUAL_MACHINE_NAME', + /// 'CUSTOM_NAME' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIPAddress.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIPAddress.cs new file mode 100644 index 000000000000..2ede2d6bd0eb --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIPAddress.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class CustomizationIPAddress + { + /// + /// Initializes a new instance of the CustomizationIPAddress class. + /// + public CustomizationIPAddress() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationIPAddress class. + /// + /// Argument when Custom ip type is + /// selected + /// Defined Ip Address when Fixed ip type is + /// selected + /// Customization Specification ip type. Possible + /// values include: 'CUSTOM', 'DHCP_IP', 'FIXED_IP', + /// 'USER_DEFINED' + public CustomizationIPAddress(string argument = default(string), string ipAddress = default(string), string type = default(string)) + { + Argument = argument; + IpAddress = ipAddress; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets argument when Custom ip type is selected + /// + [JsonProperty(PropertyName = "argument")] + public string Argument { get; set; } + + /// + /// Gets or sets defined Ip Address when Fixed ip type is selected + /// + [JsonProperty(PropertyName = "ipAddress")] + public string IpAddress { get; set; } + + /// + /// Gets or sets customization Specification ip type. Possible values + /// include: 'CUSTOM', 'DHCP_IP', 'FIXED_IP', 'USER_DEFINED' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIPSettings.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIPSettings.cs new file mode 100644 index 000000000000..af61d0c2e667 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIPSettings.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class CustomizationIPSettings + { + /// + /// Initializes a new instance of the CustomizationIPSettings class. + /// + public CustomizationIPSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationIPSettings class. + /// + /// The list of gateways + /// Ip address customization settings + /// Adapter subnet mask + public CustomizationIPSettings(IList gateway = default(IList), CustomizationIPAddress ip = default(CustomizationIPAddress), string subnetMask = default(string)) + { + Gateway = gateway; + Ip = ip; + SubnetMask = subnetMask; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of gateways + /// + [JsonProperty(PropertyName = "gateway")] + public IList Gateway { get; set; } + + /// + /// Gets or sets ip address customization settings + /// + [JsonProperty(PropertyName = "ip")] + public CustomizationIPAddress Ip { get; set; } + + /// + /// Gets or sets adapter subnet mask + /// + [JsonProperty(PropertyName = "subnetMask")] + public string SubnetMask { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIdentity.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIdentity.cs new file mode 100644 index 000000000000..019483551185 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIdentity.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class CustomizationIdentity + { + /// + /// Initializes a new instance of the CustomizationIdentity class. + /// + public CustomizationIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationIdentity class. + /// + /// Windows Text Identity. Prepared data + /// Virtual machine host name settings + /// Identity type. Possible values include: + /// 'WINDOWS_TEXT', 'WINDOWS', 'LINUX' + /// Windows Identity. User data + /// customization + public CustomizationIdentity(string data = default(string), CustomizationHostName hostName = default(CustomizationHostName), string type = default(string), CustomizationIdentityUserData userData = default(CustomizationIdentityUserData)) + { + Data = data; + HostName = hostName; + Type = type; + UserData = userData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets windows Text Identity. Prepared data + /// + [JsonProperty(PropertyName = "data")] + public string Data { get; set; } + + /// + /// Gets or sets virtual machine host name settings + /// + [JsonProperty(PropertyName = "hostName")] + public CustomizationHostName HostName { get; set; } + + /// + /// Gets or sets identity type. Possible values include: + /// 'WINDOWS_TEXT', 'WINDOWS', 'LINUX' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets windows Identity. User data customization + /// + [JsonProperty(PropertyName = "userData")] + public CustomizationIdentityUserData UserData { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIdentityUserData.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIdentityUserData.cs new file mode 100644 index 000000000000..c0f2ddfb1243 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationIdentityUserData.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Windows Identity. User data customization + /// + public partial class CustomizationIdentityUserData + { + /// + /// Initializes a new instance of the CustomizationIdentityUserData + /// class. + /// + public CustomizationIdentityUserData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationIdentityUserData + /// class. + /// + /// Is password predefined in + /// customization policy + public CustomizationIdentityUserData(bool? isPasswordPredefined = default(bool?)) + { + IsPasswordPredefined = isPasswordPredefined; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets is password predefined in customization policy + /// + [JsonProperty(PropertyName = "isPasswordPredefined")] + public bool? IsPasswordPredefined { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationNicSetting.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationNicSetting.cs new file mode 100644 index 000000000000..83764475b056 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationNicSetting.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class CustomizationNicSetting + { + /// + /// Initializes a new instance of the CustomizationNicSetting class. + /// + public CustomizationNicSetting() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationNicSetting class. + /// + /// The list of adapters' settings + /// NIC mac address + public CustomizationNicSetting(CustomizationIPSettings adapter = default(CustomizationIPSettings), string macAddress = default(string)) + { + Adapter = adapter; + MacAddress = macAddress; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of adapters' settings + /// + [JsonProperty(PropertyName = "adapter")] + public CustomizationIPSettings Adapter { get; set; } + + /// + /// Gets or sets NIC mac address + /// + [JsonProperty(PropertyName = "macAddress")] + public string MacAddress { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationPolicy.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationPolicy.cs new file mode 100644 index 000000000000..cceb3cc78763 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationPolicy.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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The virtual machine customization policy + /// + [Rest.Serialization.JsonTransformation] + public partial class CustomizationPolicy + { + /// + /// Initializes a new instance of the CustomizationPolicy class. + /// + public CustomizationPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationPolicy class. + /// + /// Customization policy azure id + /// Azure region + /// Customization policy name + /// Policy description + /// The Private cloud id + /// Detailed customization policy + /// specification + /// The type of + /// customization (Linux or Windows). Possible values include: 'LINUX', + /// 'WINDOWS' + /// Policy version + public CustomizationPolicy(string id = default(string), string location = default(string), string name = default(string), string description = default(string), string privateCloudId = default(string), CustomizationSpecification specification = default(CustomizationSpecification), string customizationPolicyPropertiesType = default(string), string version = default(string), string type = default(string)) + { + Id = id; + Location = location; + Name = name; + Description = description; + PrivateCloudId = privateCloudId; + Specification = specification; + CustomizationPolicyPropertiesType = customizationPolicyPropertiesType; + Version = version; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets customization policy azure id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets azure region + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets customization policy name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets policy description + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the Private cloud id + /// + [JsonProperty(PropertyName = "properties.privateCloudId")] + public string PrivateCloudId { get; set; } + + /// + /// Gets or sets detailed customization policy specification + /// + [JsonProperty(PropertyName = "properties.specification")] + public CustomizationSpecification Specification { get; set; } + + /// + /// Gets or sets the type of customization (Linux or Windows). Possible + /// values include: 'LINUX', 'WINDOWS' + /// + [JsonProperty(PropertyName = "properties.type")] + public string CustomizationPolicyPropertiesType { get; set; } + + /// + /// Gets or sets policy version + /// + [JsonProperty(PropertyName = "properties.version")] + public string Version { get; set; } + + /// + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationSpecification.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationSpecification.cs new file mode 100644 index 000000000000..dd23528219cc --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/CustomizationSpecification.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The specification for Customization Policy + /// + public partial class CustomizationSpecification + { + /// + /// Initializes a new instance of the CustomizationSpecification class. + /// + public CustomizationSpecification() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CustomizationSpecification class. + /// + /// Customization Identity. It contains data + /// about user and hostname + /// Network interface settings + public CustomizationSpecification(CustomizationIdentity identity = default(CustomizationIdentity), IList nicSettings = default(IList)) + { + Identity = identity; + NicSettings = nicSettings; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets customization Identity. It contains data about user + /// and hostname + /// + [JsonProperty(PropertyName = "identity")] + public CustomizationIdentity Identity { get; set; } + + /// + /// Gets or sets network interface settings + /// + [JsonProperty(PropertyName = "nicSettings")] + public IList NicSettings { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNode.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNode.cs new file mode 100644 index 000000000000..df837f4e4444 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNode.cs @@ -0,0 +1,268 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Dedicated cloud node model + /// + [Rest.Serialization.JsonTransformation] + public partial class DedicatedCloudNode : IResource + { + /// + /// Initializes a new instance of the DedicatedCloudNode class. + /// + public DedicatedCloudNode() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DedicatedCloudNode class. + /// + /// Azure region + /// Availability Zone id, e.g. + /// "az1" + /// count of nodes to create + /// Placement Group id, e.g. + /// "n1" + /// purchase id + /// SKU's id + /// SKU's name + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/dedicatedCloudNodes/{dedicatedCloudNodeName} + /// {dedicatedCloudNodeName} + /// Availability Zone name, e.g. + /// "Availability Zone 1" + /// VMWare Cloud Rack Name + /// date time the resource was created + /// Placement Name, e.g. "Placement + /// Group 1" + /// Private Cloud Id + /// Resource Pool Name + /// The provisioning status of the + /// resource + /// Node status, indicates is private cloud set up + /// on this node or not. Possible values include: 'unused', + /// 'used' + /// VMWare Cluster Name + /// Dedicated Cloud Nodes SKU + /// Dedicated Cloud Nodes tags + /// {resourceProviderNamespace}/{resourceType} + public DedicatedCloudNode(string location, string availabilityZoneId, int nodesCount, string placementGroupId, System.Guid purchaseId, string id1, string name1, string id = default(string), string name = default(string), string availabilityZoneName = default(string), string cloudRackName = default(string), System.DateTime? created = default(System.DateTime?), string placementGroupName = default(string), string privateCloudId = default(string), string privateCloudName = default(string), string provisioningState = default(string), NodeStatus? status = default(NodeStatus?), string vmwareClusterName = default(string), Sku sku = default(Sku), IDictionary tags = default(IDictionary), string type = default(string)) + { + Id = id; + Location = location; + Name = name; + AvailabilityZoneId = availabilityZoneId; + AvailabilityZoneName = availabilityZoneName; + CloudRackName = cloudRackName; + Created = created; + NodesCount = nodesCount; + PlacementGroupId = placementGroupId; + PlacementGroupName = placementGroupName; + PrivateCloudId = privateCloudId; + PrivateCloudName = privateCloudName; + ProvisioningState = provisioningState; + PurchaseId = purchaseId; + Id1 = id1; + Name1 = name1; + Status = status; + VmwareClusterName = vmwareClusterName; + Sku = sku; + Tags = tags; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/dedicatedCloudNodes/{dedicatedCloudNodeName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets azure region + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets {dedicatedCloudNodeName} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets availability Zone id, e.g. "az1" + /// + [JsonProperty(PropertyName = "properties.availabilityZoneId")] + public string AvailabilityZoneId { get; set; } + + /// + /// Gets availability Zone name, e.g. "Availability Zone 1" + /// + [JsonProperty(PropertyName = "properties.availabilityZoneName")] + public string AvailabilityZoneName { get; private set; } + + /// + /// Gets vMWare Cloud Rack Name + /// + [JsonProperty(PropertyName = "properties.cloudRackName")] + public string CloudRackName { get; private set; } + + /// + /// Gets date time the resource was created + /// + [JsonProperty(PropertyName = "properties.created")] + public System.DateTime? Created { get; private set; } + + /// + /// Gets or sets count of nodes to create + /// + [JsonProperty(PropertyName = "properties.nodesCount")] + public int NodesCount { get; set; } + + /// + /// Gets or sets placement Group id, e.g. "n1" + /// + [JsonProperty(PropertyName = "properties.placementGroupId")] + public string PlacementGroupId { get; set; } + + /// + /// Gets placement Name, e.g. "Placement Group 1" + /// + [JsonProperty(PropertyName = "properties.placementGroupName")] + public string PlacementGroupName { get; private set; } + + /// + /// Gets private Cloud Id + /// + [JsonProperty(PropertyName = "properties.privateCloudId")] + public string PrivateCloudId { get; private set; } + + /// + /// Gets resource Pool Name + /// + [JsonProperty(PropertyName = "properties.privateCloudName")] + public string PrivateCloudName { get; private set; } + + /// + /// Gets the provisioning status of the resource + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets purchase id + /// + [JsonProperty(PropertyName = "properties.purchaseId")] + public System.Guid PurchaseId { get; set; } + + /// + /// Gets or sets sKU's id + /// + [JsonProperty(PropertyName = "properties.skuDescription.id")] + public string Id1 { get; set; } + + /// + /// Gets or sets sKU's name + /// + [JsonProperty(PropertyName = "properties.skuDescription.name")] + public string Name1 { get; set; } + + /// + /// Gets node status, indicates is private cloud set up on this node or + /// not. Possible values include: 'unused', 'used' + /// + [JsonProperty(PropertyName = "properties.status")] + public NodeStatus? Status { get; private set; } + + /// + /// Gets vMWare Cluster Name + /// + [JsonProperty(PropertyName = "properties.vmwareClusterName")] + public string VmwareClusterName { get; private set; } + + /// + /// Gets or sets dedicated Cloud Nodes SKU + /// + [JsonProperty(PropertyName = "sku")] + public Sku Sku { get; set; } + + /// + /// Gets or sets dedicated Cloud Nodes tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets {resourceProviderNamespace}/{resourceType} + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (AvailabilityZoneId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AvailabilityZoneId"); + } + if (PlacementGroupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PlacementGroupId"); + } + if (Id1 == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id1"); + } + if (Name1 == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name1"); + } + if (Name != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Name, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "Name", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (Sku != null) + { + Sku.Validate(); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNodesCreateOrUpdateHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNodesCreateOrUpdateHeaders.cs new file mode 100644 index 000000000000..f90b6ef724b6 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNodesCreateOrUpdateHeaders.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOrUpdate operation. + /// + public partial class DedicatedCloudNodesCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the + /// DedicatedCloudNodesCreateOrUpdateHeaders class. + /// + public DedicatedCloudNodesCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DedicatedCloudNodesCreateOrUpdateHeaders class. + /// + public DedicatedCloudNodesCreateOrUpdateHeaders(string azureAsyncOperation = default(string), string location = default(string), int? retryAfter = default(int?)) + { + AzureAsyncOperation = azureAsyncOperation; + Location = location; + RetryAfter = retryAfter; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNodesDeleteHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNodesDeleteHeaders.cs new file mode 100644 index 000000000000..0e577826d5cd --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudNodesDeleteHeaders.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class DedicatedCloudNodesDeleteHeaders + { + /// + /// Initializes a new instance of the DedicatedCloudNodesDeleteHeaders + /// class. + /// + public DedicatedCloudNodesDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DedicatedCloudNodesDeleteHeaders + /// class. + /// + public DedicatedCloudNodesDeleteHeaders(string contentType = default(string)) + { + ContentType = contentType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Content-Type")] + public string ContentType { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudService.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudService.cs new file mode 100644 index 000000000000..691c67aa0e1f --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudService.cs @@ -0,0 +1,156 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Dedicated cloud service model + /// + [Rest.Serialization.JsonTransformation] + public partial class DedicatedCloudService : IResource + { + /// + /// Initializes a new instance of the DedicatedCloudService class. + /// + public DedicatedCloudService() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DedicatedCloudService class. + /// + /// Azure region + /// gateway Subnet for the account. It will + /// collect the subnet address and always treat it as /28 + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/dedicatedCloudServices/{dedicatedCloudServiceName} + /// {dedicatedCloudServiceName} + /// indicates whether account + /// onboarded or not in a given region. Possible values include: + /// 'notOnBoarded', 'onBoarded', 'onBoardingFailed', + /// 'onBoarding' + /// total nodes purchased + /// link to a service management web + /// portal + /// The list of tags + /// {resourceProviderNamespace}/{resourceType} + public DedicatedCloudService(string location, string gatewaySubnet, string id = default(string), string name = default(string), OnboardingStatus? isAccountOnboarded = default(OnboardingStatus?), int? nodes = default(int?), string serviceURL = default(string), IDictionary tags = default(IDictionary), string type = default(string)) + { + Id = id; + Location = location; + Name = name; + GatewaySubnet = gatewaySubnet; + IsAccountOnboarded = isAccountOnboarded; + Nodes = nodes; + ServiceURL = serviceURL; + Tags = tags; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/dedicatedCloudServices/{dedicatedCloudServiceName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets azure region + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets {dedicatedCloudServiceName} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets gateway Subnet for the account. It will collect the + /// subnet address and always treat it as /28 + /// + [JsonProperty(PropertyName = "properties.gatewaySubnet")] + public string GatewaySubnet { get; set; } + + /// + /// Gets indicates whether account onboarded or not in a given region. + /// Possible values include: 'notOnBoarded', 'onBoarded', + /// 'onBoardingFailed', 'onBoarding' + /// + [JsonProperty(PropertyName = "properties.isAccountOnboarded")] + public OnboardingStatus? IsAccountOnboarded { get; private set; } + + /// + /// Gets total nodes purchased + /// + [JsonProperty(PropertyName = "properties.nodes")] + public int? Nodes { get; private set; } + + /// + /// Gets link to a service management web portal + /// + [JsonProperty(PropertyName = "properties.serviceURL")] + public string ServiceURL { get; private set; } + + /// + /// Gets or sets the list of tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets {resourceProviderNamespace}/{resourceType} + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (GatewaySubnet == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "GatewaySubnet"); + } + if (Name != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Name, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "Name", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudServicesDeleteHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudServicesDeleteHeaders.cs new file mode 100644 index 000000000000..98c38c13f728 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DedicatedCloudServicesDeleteHeaders.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class DedicatedCloudServicesDeleteHeaders + { + /// + /// Initializes a new instance of the + /// DedicatedCloudServicesDeleteHeaders class. + /// + public DedicatedCloudServicesDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DedicatedCloudServicesDeleteHeaders class. + /// + public DedicatedCloudServicesDeleteHeaders(string contentType = default(string)) + { + ContentType = contentType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Content-Type")] + public string ContentType { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DiskIndependenceMode.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DiskIndependenceMode.cs new file mode 100644 index 000000000000..9212c8454483 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/DiskIndependenceMode.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for DiskIndependenceMode. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum DiskIndependenceMode + { + [EnumMember(Value = "persistent")] + Persistent, + [EnumMember(Value = "independent_persistent")] + IndependentPersistent, + [EnumMember(Value = "independent_nonpersistent")] + IndependentNonpersistent + } + internal static class DiskIndependenceModeEnumExtension + { + internal static string ToSerializedValue(this DiskIndependenceMode? value) + { + return value == null ? null : ((DiskIndependenceMode)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this DiskIndependenceMode value) + { + switch( value ) + { + case DiskIndependenceMode.Persistent: + return "persistent"; + case DiskIndependenceMode.IndependentPersistent: + return "independent_persistent"; + case DiskIndependenceMode.IndependentNonpersistent: + return "independent_nonpersistent"; + } + return null; + } + + internal static DiskIndependenceMode? ParseDiskIndependenceMode(this string value) + { + switch( value ) + { + case "persistent": + return DiskIndependenceMode.Persistent; + case "independent_persistent": + return DiskIndependenceMode.IndependentPersistent; + case "independent_nonpersistent": + return DiskIndependenceMode.IndependentNonpersistent; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSCustomization.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSCustomization.cs new file mode 100644 index 000000000000..2d5757f7a938 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSCustomization.cs @@ -0,0 +1,85 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Guest OS Customization properties + /// + public partial class GuestOSCustomization + { + /// + /// Initializes a new instance of the GuestOSCustomization class. + /// + public GuestOSCustomization() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GuestOSCustomization class. + /// + /// List of dns servers to use + /// Virtual Machine hostname + /// Password for login + /// id of customization policy + /// Username for login + public GuestOSCustomization(IList dnsServers = default(IList), string hostName = default(string), string password = default(string), string policyId = default(string), string username = default(string)) + { + DnsServers = dnsServers; + HostName = hostName; + Password = password; + PolicyId = policyId; + Username = username; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of dns servers to use + /// + [JsonProperty(PropertyName = "dnsServers")] + public IList DnsServers { get; set; } + + /// + /// Gets or sets virtual Machine hostname + /// + [JsonProperty(PropertyName = "hostName")] + public string HostName { get; set; } + + /// + /// Gets or sets password for login + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + /// + /// Gets or sets id of customization policy + /// + [JsonProperty(PropertyName = "policyId")] + public string PolicyId { get; set; } + + /// + /// Gets or sets username for login + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSNICCustomization.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSNICCustomization.cs new file mode 100644 index 000000000000..720874605871 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSNICCustomization.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Guest OS nic customization + /// + public partial class GuestOSNICCustomization + { + /// + /// Initializes a new instance of the GuestOSNICCustomization class. + /// + public GuestOSNICCustomization() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GuestOSNICCustomization class. + /// + /// IP address allocation method. Possible + /// values include: 'static', 'dynamic' + /// List of dns servers to use + /// Gateway addresses assigned to nic + /// Static ip address for nic + /// Network mask for nic + /// primary WINS server for + /// Windows + /// secondary WINS server for + /// Windows + public GuestOSNICCustomization(string allocation = default(string), IList dnsServers = default(IList), IList gateway = default(IList), string ipAddress = default(string), string mask = default(string), string primaryWinsServer = default(string), string secondaryWinsServer = default(string)) + { + Allocation = allocation; + DnsServers = dnsServers; + Gateway = gateway; + IpAddress = ipAddress; + Mask = mask; + PrimaryWinsServer = primaryWinsServer; + SecondaryWinsServer = secondaryWinsServer; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets IP address allocation method. Possible values include: + /// 'static', 'dynamic' + /// + [JsonProperty(PropertyName = "allocation")] + public string Allocation { get; set; } + + /// + /// Gets or sets list of dns servers to use + /// + [JsonProperty(PropertyName = "dnsServers")] + public IList DnsServers { get; set; } + + /// + /// Gets or sets gateway addresses assigned to nic + /// + [JsonProperty(PropertyName = "gateway")] + public IList Gateway { get; set; } + + /// + /// Gets or sets static ip address for nic + /// + [JsonProperty(PropertyName = "ipAddress")] + public string IpAddress { get; set; } + + /// + /// Gets or sets network mask for nic + /// + [JsonProperty(PropertyName = "mask")] + public string Mask { get; set; } + + /// + /// Gets or sets primary WINS server for Windows + /// + [JsonProperty(PropertyName = "primaryWinsServer")] + public string PrimaryWinsServer { get; set; } + + /// + /// Gets or sets secondary WINS server for Windows + /// + [JsonProperty(PropertyName = "secondaryWinsServer")] + public string SecondaryWinsServer { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSType.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSType.cs new file mode 100644 index 000000000000..69a9243d1d5d --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/GuestOSType.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for GuestOSType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum GuestOSType + { + [EnumMember(Value = "linux")] + Linux, + [EnumMember(Value = "windows")] + Windows, + [EnumMember(Value = "other")] + Other + } + internal static class GuestOSTypeEnumExtension + { + internal static string ToSerializedValue(this GuestOSType? value) + { + return value == null ? null : ((GuestOSType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this GuestOSType value) + { + switch( value ) + { + case GuestOSType.Linux: + return "linux"; + case GuestOSType.Windows: + return "windows"; + case GuestOSType.Other: + return "other"; + } + return null; + } + + internal static GuestOSType? ParseGuestOSType(this string value) + { + switch( value ) + { + case "linux": + return GuestOSType.Linux; + case "windows": + return GuestOSType.Windows; + case "other": + return GuestOSType.Other; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/NICType.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/NICType.cs new file mode 100644 index 000000000000..b00279ec22cb --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/NICType.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for NICType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NICType + { + [EnumMember(Value = "E1000")] + E1000, + [EnumMember(Value = "E1000E")] + E1000E, + [EnumMember(Value = "PCNET32")] + PCNET32, + [EnumMember(Value = "VMXNET")] + VMXNET, + [EnumMember(Value = "VMXNET2")] + VMXNET2, + [EnumMember(Value = "VMXNET3")] + VMXNET3 + } + internal static class NICTypeEnumExtension + { + internal static string ToSerializedValue(this NICType? value) + { + return value == null ? null : ((NICType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this NICType value) + { + switch( value ) + { + case NICType.E1000: + return "E1000"; + case NICType.E1000E: + return "E1000E"; + case NICType.PCNET32: + return "PCNET32"; + case NICType.VMXNET: + return "VMXNET"; + case NICType.VMXNET2: + return "VMXNET2"; + case NICType.VMXNET3: + return "VMXNET3"; + } + return null; + } + + internal static NICType? ParseNICType(this string value) + { + switch( value ) + { + case "E1000": + return NICType.E1000; + case "E1000E": + return NICType.E1000E; + case "PCNET32": + return NICType.PCNET32; + case "VMXNET": + return NICType.VMXNET; + case "VMXNET2": + return NICType.VMXNET2; + case "VMXNET3": + return NICType.VMXNET3; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/NodeStatus.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/NodeStatus.cs new file mode 100644 index 000000000000..469c3070f81f --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/NodeStatus.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for NodeStatus. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum NodeStatus + { + [EnumMember(Value = "unused")] + Unused, + [EnumMember(Value = "used")] + Used + } + internal static class NodeStatusEnumExtension + { + internal static string ToSerializedValue(this NodeStatus? value) + { + return value == null ? null : ((NodeStatus)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this NodeStatus value) + { + switch( value ) + { + case NodeStatus.Unused: + return "unused"; + case NodeStatus.Used: + return "used"; + } + return null; + } + + internal static NodeStatus? ParseNodeStatus(this string value) + { + switch( value ) + { + case "unused": + return NodeStatus.Unused; + case "used": + return NodeStatus.Used; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OnboardingStatus.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OnboardingStatus.cs new file mode 100644 index 000000000000..7f9868b8ef98 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OnboardingStatus.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for OnboardingStatus. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OnboardingStatus + { + [EnumMember(Value = "notOnBoarded")] + NotOnBoarded, + [EnumMember(Value = "onBoarded")] + OnBoarded, + [EnumMember(Value = "onBoardingFailed")] + OnBoardingFailed, + [EnumMember(Value = "onBoarding")] + OnBoarding + } + internal static class OnboardingStatusEnumExtension + { + internal static string ToSerializedValue(this OnboardingStatus? value) + { + return value == null ? null : ((OnboardingStatus)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this OnboardingStatus value) + { + switch( value ) + { + case OnboardingStatus.NotOnBoarded: + return "notOnBoarded"; + case OnboardingStatus.OnBoarded: + return "onBoarded"; + case OnboardingStatus.OnBoardingFailed: + return "onBoardingFailed"; + case OnboardingStatus.OnBoarding: + return "onBoarding"; + } + return null; + } + + internal static OnboardingStatus? ParseOnboardingStatus(this string value) + { + switch( value ) + { + case "notOnBoarded": + return OnboardingStatus.NotOnBoarded; + case "onBoarded": + return OnboardingStatus.OnBoarded; + case "onBoardingFailed": + return OnboardingStatus.OnBoardingFailed; + case "onBoarding": + return OnboardingStatus.OnBoarding; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationError.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationError.cs new file mode 100644 index 000000000000..e2c93a6c0a67 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationError.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Operation error model + /// + public partial class OperationError + { + /// + /// Initializes a new instance of the OperationError class. + /// + public OperationError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationError class. + /// + /// Error's code + /// Error's message + public OperationError(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error's code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error's message + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationOrigin.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationOrigin.cs new file mode 100644 index 000000000000..e33108b9501b --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationOrigin.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for OperationOrigin. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OperationOrigin + { + [EnumMember(Value = "user")] + User, + [EnumMember(Value = "system")] + System, + [EnumMember(Value = "user,system")] + Usersystem + } + internal static class OperationOriginEnumExtension + { + internal static string ToSerializedValue(this OperationOrigin? value) + { + return value == null ? null : ((OperationOrigin)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this OperationOrigin value) + { + switch( value ) + { + case OperationOrigin.User: + return "user"; + case OperationOrigin.System: + return "system"; + case OperationOrigin.Usersystem: + return "user,system"; + } + return null; + } + + internal static OperationOrigin? ParseOperationOrigin(this string value) + { + switch( value ) + { + case "user": + return OperationOrigin.User; + case "system": + return OperationOrigin.System; + case "user,system": + return OperationOrigin.Usersystem; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationResource.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationResource.cs new file mode 100644 index 000000000000..e5b6bcec2b30 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationResource.cs @@ -0,0 +1,91 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Operation status response + /// + public partial class OperationResource + { + /// + /// Initializes a new instance of the OperationResource class. + /// + public OperationResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationResource class. + /// + /// End time of the operation + /// Error Message if operation failed + /// Operation Id + /// Operation ID + /// Start time of the operation + /// Operation status + public OperationResource(System.DateTime? endTime = default(System.DateTime?), OperationError error = default(OperationError), string id = default(string), string name = default(string), System.DateTime? startTime = default(System.DateTime?), string status = default(string)) + { + EndTime = endTime; + Error = error; + Id = id; + Name = name; + StartTime = startTime; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets end time of the operation + /// + [JsonProperty(PropertyName = "endTime")] + public System.DateTime? EndTime { get; private set; } + + /// + /// Gets or sets error Message if operation failed + /// + [JsonProperty(PropertyName = "error")] + public OperationError Error { get; set; } + + /// + /// Gets operation Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets operation ID + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets start time of the operation + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; private set; } + + /// + /// Gets operation status + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationsGetHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationsGetHeaders.cs new file mode 100644 index 000000000000..03cafb158a7a --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/OperationsGetHeaders.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Get operation. + /// + public partial class OperationsGetHeaders + { + /// + /// Initializes a new instance of the OperationsGetHeaders class. + /// + public OperationsGetHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationsGetHeaders class. + /// + public OperationsGetHeaders(string location = default(string), int? retryAfter = default(int?), string contentType = default(string)) + { + Location = location; + RetryAfter = retryAfter; + ContentType = contentType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Content-Type")] + public string ContentType { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Page.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..55e467e4526d --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Page.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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PatchPayload.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PatchPayload.cs new file mode 100644 index 000000000000..047598f92b74 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PatchPayload.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// General patch payload modal + /// + public partial class PatchPayload + { + /// + /// Initializes a new instance of the PatchPayload class. + /// + public PatchPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PatchPayload class. + /// + /// The tags key:value pairs + public PatchPayload(IDictionary tags = default(IDictionary)) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the tags key:value pairs + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PrivateCloud.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PrivateCloud.cs new file mode 100644 index 000000000000..ded57a514519 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PrivateCloud.cs @@ -0,0 +1,283 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Private cloud model + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateCloud + { + /// + /// Initializes a new instance of the PrivateCloud class. + /// + public PrivateCloud() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateCloud class. + /// + /// Azure Id, e.g. + /// "/subscriptions/4da99247-a172-4ed6-8ae9-ebed2d12f839/providers/Microsoft.VMwareCloudSimple/privateClouds/cloud123" + /// Location where private cloud created, e.g + /// "westus" + /// Private cloud name + /// Availability Zone id, e.g. + /// "az1" + /// Availability Zone name, e.g. + /// "Availability Zone 1" + /// Number of clusters + /// User's emails who created cloud + /// When private cloud was created + /// Array of DNS servers + /// Expiration date of PC + /// Nsx Type, e.g. "Advanced" + /// Placement Group id, e.g. + /// "n1" + /// Placement Group name + /// Id of a private cloud + /// The list of Resource Pools + /// Private Cloud state, e.g. "operational" + /// Number of cores + /// Number of nodes + /// Memory size + /// Disk space in TB + /// Virtualization type e.g. + /// "vSphere" + /// e.g. "6.5u2" + /// FQDN for vcenter access + /// Vcenter ip address + /// The list of Virtual Machine + /// Templates + /// The list of Virtual Networks + /// Is vRealize Operations Manager + /// enabled/disabled + /// Azure Resource type. Possible values include: + /// 'Microsoft.VMwareCloudSimple/privateClouds' + public PrivateCloud(string id = default(string), string location = default(string), string name = default(string), string availabilityZoneId = default(string), string availabilityZoneName = default(string), int? clustersNumber = default(int?), string createdBy = default(string), System.DateTime? createdOn = default(System.DateTime?), IList dnsServers = default(IList), string expires = default(string), string nsxType = default(string), string placementGroupId = default(string), string placementGroupName = default(string), System.Guid? privateCloudId = default(System.Guid?), IList resourcePools = default(IList), string state = default(string), int? totalCpuCores = default(int?), int? totalNodes = default(int?), int? totalRam = default(int?), double? totalStorage = default(double?), string privateCloudPropertiesType = default(string), string vSphereVersion = default(string), string vcenterFqdn = default(string), string vcenterRefid = default(string), IList virtualMachineTemplates = default(IList), IList virtualNetworks = default(IList), bool? vrOpsEnabled = default(bool?), PrivateCloudResourceType? type = default(PrivateCloudResourceType?)) + { + Id = id; + Location = location; + Name = name; + AvailabilityZoneId = availabilityZoneId; + AvailabilityZoneName = availabilityZoneName; + ClustersNumber = clustersNumber; + CreatedBy = createdBy; + CreatedOn = createdOn; + DnsServers = dnsServers; + Expires = expires; + NsxType = nsxType; + PlacementGroupId = placementGroupId; + PlacementGroupName = placementGroupName; + PrivateCloudId = privateCloudId; + ResourcePools = resourcePools; + State = state; + TotalCpuCores = totalCpuCores; + TotalNodes = totalNodes; + TotalRam = totalRam; + TotalStorage = totalStorage; + PrivateCloudPropertiesType = privateCloudPropertiesType; + VSphereVersion = vSphereVersion; + VcenterFqdn = vcenterFqdn; + VcenterRefid = vcenterRefid; + VirtualMachineTemplates = virtualMachineTemplates; + VirtualNetworks = virtualNetworks; + VrOpsEnabled = vrOpsEnabled; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure Id, e.g. + /// "/subscriptions/4da99247-a172-4ed6-8ae9-ebed2d12f839/providers/Microsoft.VMwareCloudSimple/privateClouds/cloud123" + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets location where private cloud created, e.g "westus" + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets private cloud name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets availability Zone id, e.g. "az1" + /// + [JsonProperty(PropertyName = "properties.availabilityZoneId")] + public string AvailabilityZoneId { get; set; } + + /// + /// Gets or sets availability Zone name, e.g. "Availability Zone 1" + /// + [JsonProperty(PropertyName = "properties.availabilityZoneName")] + public string AvailabilityZoneName { get; set; } + + /// + /// Gets or sets number of clusters + /// + [JsonProperty(PropertyName = "properties.clustersNumber")] + public int? ClustersNumber { get; set; } + + /// + /// Gets or sets user's emails who created cloud + /// + [JsonProperty(PropertyName = "properties.createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets when private cloud was created + /// + [JsonProperty(PropertyName = "properties.createdOn")] + public System.DateTime? CreatedOn { get; set; } + + /// + /// Gets or sets array of DNS servers + /// + [JsonProperty(PropertyName = "properties.dnsServers")] + public IList DnsServers { get; set; } + + /// + /// Gets or sets expiration date of PC + /// + [JsonProperty(PropertyName = "properties.expires")] + public string Expires { get; set; } + + /// + /// Gets or sets nsx Type, e.g. "Advanced" + /// + [JsonProperty(PropertyName = "properties.nsxType")] + public string NsxType { get; set; } + + /// + /// Gets or sets placement Group id, e.g. "n1" + /// + [JsonProperty(PropertyName = "properties.placementGroupId")] + public string PlacementGroupId { get; set; } + + /// + /// Gets or sets placement Group name + /// + [JsonProperty(PropertyName = "properties.placementGroupName")] + public string PlacementGroupName { get; set; } + + /// + /// Gets or sets id of a private cloud + /// + [JsonProperty(PropertyName = "properties.privateCloudId")] + public System.Guid? PrivateCloudId { get; set; } + + /// + /// Gets or sets the list of Resource Pools + /// + [JsonProperty(PropertyName = "properties.resourcePools")] + public IList ResourcePools { get; set; } + + /// + /// Gets or sets private Cloud state, e.g. "operational" + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; set; } + + /// + /// Gets or sets number of cores + /// + [JsonProperty(PropertyName = "properties.totalCpuCores")] + public int? TotalCpuCores { get; set; } + + /// + /// Gets or sets number of nodes + /// + [JsonProperty(PropertyName = "properties.totalNodes")] + public int? TotalNodes { get; set; } + + /// + /// Gets or sets memory size + /// + [JsonProperty(PropertyName = "properties.totalRam")] + public int? TotalRam { get; set; } + + /// + /// Gets or sets disk space in TB + /// + [JsonProperty(PropertyName = "properties.totalStorage")] + public double? TotalStorage { get; set; } + + /// + /// Gets or sets virtualization type e.g. "vSphere" + /// + [JsonProperty(PropertyName = "properties.type")] + public string PrivateCloudPropertiesType { get; set; } + + /// + /// Gets or sets e.g. "6.5u2" + /// + [JsonProperty(PropertyName = "properties.vSphereVersion")] + public string VSphereVersion { get; set; } + + /// + /// Gets or sets FQDN for vcenter access + /// + [JsonProperty(PropertyName = "properties.vcenterFqdn")] + public string VcenterFqdn { get; set; } + + /// + /// Gets or sets vcenter ip address + /// + [JsonProperty(PropertyName = "properties.vcenterRefid")] + public string VcenterRefid { get; set; } + + /// + /// Gets or sets the list of Virtual Machine Templates + /// + [JsonProperty(PropertyName = "properties.virtualMachineTemplates")] + public IList VirtualMachineTemplates { get; set; } + + /// + /// Gets or sets the list of Virtual Networks + /// + [JsonProperty(PropertyName = "properties.virtualNetworks")] + public IList VirtualNetworks { get; set; } + + /// + /// Gets or sets is vRealize Operations Manager enabled/disabled + /// + [JsonProperty(PropertyName = "properties.vrOpsEnabled")] + public bool? VrOpsEnabled { get; set; } + + /// + /// Gets or sets azure Resource type. Possible values include: + /// 'Microsoft.VMwareCloudSimple/privateClouds' + /// + [JsonProperty(PropertyName = "type")] + public PrivateCloudResourceType? Type { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PrivateCloudResourceType.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PrivateCloudResourceType.cs new file mode 100644 index 000000000000..fc6c7aaf166b --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/PrivateCloudResourceType.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for PrivateCloudResourceType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum PrivateCloudResourceType + { + [EnumMember(Value = "Microsoft.VMwareCloudSimple/privateClouds")] + MicrosoftVMwareCloudSimplePrivateClouds + } + internal static class PrivateCloudResourceTypeEnumExtension + { + internal static string ToSerializedValue(this PrivateCloudResourceType? value) + { + return value == null ? null : ((PrivateCloudResourceType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this PrivateCloudResourceType value) + { + switch( value ) + { + case PrivateCloudResourceType.MicrosoftVMwareCloudSimplePrivateClouds: + return "Microsoft.VMwareCloudSimple/privateClouds"; + } + return null; + } + + internal static PrivateCloudResourceType? ParsePrivateCloudResourceType(this string value) + { + switch( value ) + { + case "Microsoft.VMwareCloudSimple/privateClouds": + return PrivateCloudResourceType.MicrosoftVMwareCloudSimplePrivateClouds; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/ResourcePool.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/ResourcePool.cs new file mode 100644 index 000000000000..0a2c9b81cd1f --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/ResourcePool.cs @@ -0,0 +1,109 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource pool model + /// + [Rest.Serialization.JsonTransformation] + public partial class ResourcePool + { + /// + /// Initializes a new instance of the ResourcePool class. + /// + public ResourcePool() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcePool class. + /// + /// resource pool id + /// (privateCloudId:vsphereId) + /// Azure region + /// {ResourcePoolName} + /// The Private Cloud Id + /// Hierarchical resource pool name + /// {resourceProviderNamespace}/{resourceType} + public ResourcePool(string id, string location = default(string), string name = default(string), string privateCloudId = default(string), string fullName = default(string), string type = default(string)) + { + Id = id; + Location = location; + Name = name; + PrivateCloudId = privateCloudId; + FullName = fullName; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource pool id (privateCloudId:vsphereId) + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets azure region + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets {ResourcePoolName} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the Private Cloud Id + /// + [JsonProperty(PropertyName = "privateCloudId")] + public string PrivateCloudId { get; private set; } + + /// + /// Gets hierarchical resource pool name + /// + [JsonProperty(PropertyName = "properties.fullName")] + public string FullName { get; private set; } + + /// + /// Gets {resourceProviderNamespace}/{resourceType} + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Sku.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Sku.cs new file mode 100644 index 000000000000..fb28370381f6 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Sku.cs @@ -0,0 +1,104 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The purchase SKU for CloudSimple paid resources + /// + public partial class Sku + { + /// + /// Initializes a new instance of the Sku class. + /// + public Sku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Sku class. + /// + /// The name of the SKU for VMWare CloudSimple + /// Node + /// The capacity of the SKU + /// dedicatedCloudNode example: 8 x Ten-Core + /// Intel® Xeon® Processor E5-2640 v4 2.40GHz 25MB Cache (90W); 12 x + /// 64GB PC4-19200 2400MHz DDR4 ECC Registered DIMM, ... + /// If the service has different generations of + /// hardware, for the same SKU, then that can be captured here + /// The tier of the SKU + public Sku(string name, string capacity = default(string), string description = default(string), string family = default(string), string tier = default(string)) + { + Capacity = capacity; + Description = description; + Family = family; + Name = name; + Tier = tier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the capacity of the SKU + /// + [JsonProperty(PropertyName = "capacity")] + public string Capacity { get; set; } + + /// + /// Gets or sets dedicatedCloudNode example: 8 x Ten-Core Intel® Xeon® + /// Processor E5-2640 v4 2.40GHz 25MB Cache (90W); 12 x 64GB PC4-19200 + /// 2400MHz DDR4 ECC Registered DIMM, ... + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets if the service has different generations of hardware, + /// for the same SKU, then that can be captured here + /// + [JsonProperty(PropertyName = "family")] + public string Family { get; set; } + + /// + /// Gets or sets the name of the SKU for VMWare CloudSimple Node + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the tier of the SKU + /// + [JsonProperty(PropertyName = "tier")] + public string Tier { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/SkuAvailability.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/SkuAvailability.cs new file mode 100644 index 000000000000..7cd18fecfa00 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/SkuAvailability.cs @@ -0,0 +1,124 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// SKU availability model + /// + public partial class SkuAvailability + { + /// + /// Initializes a new instance of the SkuAvailability class. + /// + public SkuAvailability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SkuAvailability class. + /// + /// indicates how many resources of a given SKU is + /// available in a AZ->PG + /// CloudSimple Availability + /// Zone id + /// CloudSimple + /// Availability Zone Name + /// CloudSimple Placement Group + /// Id + /// CloudSimple Placement + /// Group name + /// resource type e.g. + /// DedicatedCloudNodes + /// sku id + /// sku name + public SkuAvailability(int limit, string dedicatedAvailabilityZoneId = default(string), string dedicatedAvailabilityZoneName = default(string), string dedicatedPlacementGroupId = default(string), string dedicatedPlacementGroupName = default(string), string resourceType = default(string), string skuId = default(string), string skuName = default(string)) + { + DedicatedAvailabilityZoneId = dedicatedAvailabilityZoneId; + DedicatedAvailabilityZoneName = dedicatedAvailabilityZoneName; + DedicatedPlacementGroupId = dedicatedPlacementGroupId; + DedicatedPlacementGroupName = dedicatedPlacementGroupName; + Limit = limit; + ResourceType = resourceType; + SkuId = skuId; + SkuName = skuName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets cloudSimple Availability Zone id + /// + [JsonProperty(PropertyName = "dedicatedAvailabilityZoneId")] + public string DedicatedAvailabilityZoneId { get; set; } + + /// + /// Gets or sets cloudSimple Availability Zone Name + /// + [JsonProperty(PropertyName = "dedicatedAvailabilityZoneName")] + public string DedicatedAvailabilityZoneName { get; set; } + + /// + /// Gets or sets cloudSimple Placement Group Id + /// + [JsonProperty(PropertyName = "dedicatedPlacementGroupId")] + public string DedicatedPlacementGroupId { get; set; } + + /// + /// Gets or sets cloudSimple Placement Group name + /// + [JsonProperty(PropertyName = "dedicatedPlacementGroupName")] + public string DedicatedPlacementGroupName { get; set; } + + /// + /// Gets or sets indicates how many resources of a given SKU is + /// available in a AZ->PG + /// + [JsonProperty(PropertyName = "limit")] + public int Limit { get; set; } + + /// + /// Gets or sets resource type e.g. DedicatedCloudNodes + /// + [JsonProperty(PropertyName = "resourceType")] + public string ResourceType { get; set; } + + /// + /// Gets or sets sku id + /// + [JsonProperty(PropertyName = "skuId")] + public string SkuId { get; set; } + + /// + /// Gets or sets sku name + /// + [JsonProperty(PropertyName = "skuName")] + public string SkuName { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/StopMode.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/StopMode.cs new file mode 100644 index 000000000000..f8565815e1eb --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/StopMode.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for StopMode. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum StopMode + { + [EnumMember(Value = "reboot")] + Reboot, + [EnumMember(Value = "suspend")] + Suspend, + [EnumMember(Value = "shutdown")] + Shutdown, + [EnumMember(Value = "poweroff")] + Poweroff + } + internal static class StopModeEnumExtension + { + internal static string ToSerializedValue(this StopMode? value) + { + return value == null ? null : ((StopMode)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this StopMode value) + { + switch( value ) + { + case StopMode.Reboot: + return "reboot"; + case StopMode.Suspend: + return "suspend"; + case StopMode.Shutdown: + return "shutdown"; + case StopMode.Poweroff: + return "poweroff"; + } + return null; + } + + internal static StopMode? ParseStopMode(this string value) + { + switch( value ) + { + case "reboot": + return StopMode.Reboot; + case "suspend": + return StopMode.Suspend; + case "shutdown": + return StopMode.Shutdown; + case "poweroff": + return StopMode.Poweroff; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Usage.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Usage.cs new file mode 100644 index 000000000000..c628264b8152 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/Usage.cs @@ -0,0 +1,91 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Usage model + /// + public partial class Usage + { + /// + /// Initializes a new instance of the Usage class. + /// + public Usage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Usage class. + /// + /// The current usage value + /// limit of a given sku in a region for a + /// subscription. The maximum permitted value for the usage quota. If + /// there is no limit, this value will be -1 + /// Usage name value and localized name + /// The usages' unit. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + /// 'BytesPerSecond' + public Usage(int currentValue, int limit, UsageName name = default(UsageName), UsageCount? unit = default(UsageCount?)) + { + CurrentValue = currentValue; + Limit = limit; + Name = name; + Unit = unit; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the current usage value + /// + [JsonProperty(PropertyName = "currentValue")] + public int CurrentValue { get; set; } + + /// + /// Gets or sets limit of a given sku in a region for a subscription. + /// The maximum permitted value for the usage quota. If there is no + /// limit, this value will be -1 + /// + [JsonProperty(PropertyName = "limit")] + public int Limit { get; set; } + + /// + /// Gets or sets usage name value and localized name + /// + [JsonProperty(PropertyName = "name")] + public UsageName Name { get; set; } + + /// + /// Gets or sets the usages' unit. Possible values include: 'Count', + /// 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond' + /// + [JsonProperty(PropertyName = "unit")] + public UsageCount? Unit { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/UsageCount.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/UsageCount.cs new file mode 100644 index 000000000000..b53ccf4babe6 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/UsageCount.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for UsageCount. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum UsageCount + { + [EnumMember(Value = "Count")] + Count, + [EnumMember(Value = "Bytes")] + Bytes, + [EnumMember(Value = "Seconds")] + Seconds, + [EnumMember(Value = "Percent")] + Percent, + [EnumMember(Value = "CountPerSecond")] + CountPerSecond, + [EnumMember(Value = "BytesPerSecond")] + BytesPerSecond + } + internal static class UsageCountEnumExtension + { + internal static string ToSerializedValue(this UsageCount? value) + { + return value == null ? null : ((UsageCount)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this UsageCount value) + { + switch( value ) + { + case UsageCount.Count: + return "Count"; + case UsageCount.Bytes: + return "Bytes"; + case UsageCount.Seconds: + return "Seconds"; + case UsageCount.Percent: + return "Percent"; + case UsageCount.CountPerSecond: + return "CountPerSecond"; + case UsageCount.BytesPerSecond: + return "BytesPerSecond"; + } + return null; + } + + internal static UsageCount? ParseUsageCount(this string value) + { + switch( value ) + { + case "Count": + return UsageCount.Count; + case "Bytes": + return UsageCount.Bytes; + case "Seconds": + return UsageCount.Seconds; + case "Percent": + return UsageCount.Percent; + case "CountPerSecond": + return UsageCount.CountPerSecond; + case "BytesPerSecond": + return UsageCount.BytesPerSecond; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/UsageName.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/UsageName.cs new file mode 100644 index 000000000000..e68d4d0524c6 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/UsageName.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// User name model + /// + public partial class UsageName + { + /// + /// Initializes a new instance of the UsageName class. + /// + public UsageName() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UsageName class. + /// + /// e.g. "Virtual Machines" + /// resource type or resource type sku name, e.g. + /// virtualMachines + public UsageName(string localizedValue = default(string), string value = default(string)) + { + LocalizedValue = localizedValue; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets e.g. "Virtual Machines" + /// + [JsonProperty(PropertyName = "localizedValue")] + public string LocalizedValue { get; set; } + + /// + /// Gets or sets resource type or resource type sku name, e.g. + /// virtualMachines + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualDisk.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualDisk.cs new file mode 100644 index 000000000000..84986ce07c05 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualDisk.cs @@ -0,0 +1,101 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Virtual disk model + /// + public partial class VirtualDisk + { + /// + /// Initializes a new instance of the VirtualDisk class. + /// + public VirtualDisk() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualDisk class. + /// + /// Disk's Controller id + /// Disk's independence mode type. + /// Possible values include: 'persistent', 'independent_persistent', + /// 'independent_nonpersistent' + /// Disk's total size + /// Disk's id + /// Disk's display name + public VirtualDisk(string controllerId, DiskIndependenceMode independenceMode, int totalSize, string virtualDiskId = default(string), string virtualDiskName = default(string)) + { + ControllerId = controllerId; + IndependenceMode = independenceMode; + TotalSize = totalSize; + VirtualDiskId = virtualDiskId; + VirtualDiskName = virtualDiskName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets disk's Controller id + /// + [JsonProperty(PropertyName = "controllerId")] + public string ControllerId { get; set; } + + /// + /// Gets or sets disk's independence mode type. Possible values + /// include: 'persistent', 'independent_persistent', + /// 'independent_nonpersistent' + /// + [JsonProperty(PropertyName = "independenceMode")] + public DiskIndependenceMode IndependenceMode { get; set; } + + /// + /// Gets or sets disk's total size + /// + [JsonProperty(PropertyName = "totalSize")] + public int TotalSize { get; set; } + + /// + /// Gets or sets disk's id + /// + [JsonProperty(PropertyName = "virtualDiskId")] + public string VirtualDiskId { get; set; } + + /// + /// Gets disk's display name + /// + [JsonProperty(PropertyName = "virtualDiskName")] + public string VirtualDiskName { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ControllerId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ControllerId"); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualDiskController.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualDiskController.cs new file mode 100644 index 000000000000..cb05c27361a2 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualDiskController.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Virtual disk controller model + /// + public partial class VirtualDiskController + { + /// + /// Initializes a new instance of the VirtualDiskController class. + /// + public VirtualDiskController() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualDiskController class. + /// + /// Controller's id + /// The display name of Controller + /// dik controller subtype (VMWARE_PARAVIRTUAL, + /// BUS_PARALLEL, LSI_PARALLEL, LSI_SAS) + /// disk controller type (SCSI) + public VirtualDiskController(string id = default(string), string name = default(string), string subType = default(string), string type = default(string)) + { + Id = id; + Name = name; + SubType = subType; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets controller's id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the display name of Controller + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets dik controller subtype (VMWARE_PARAVIRTUAL, BUS_PARALLEL, + /// LSI_PARALLEL, LSI_SAS) + /// + [JsonProperty(PropertyName = "subType")] + public string SubType { get; private set; } + + /// + /// Gets disk controller type (SCSI) + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachine.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachine.cs new file mode 100644 index 000000000000..c2c50bd99653 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachine.cs @@ -0,0 +1,332 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Virtual machine model + /// + [Rest.Serialization.JsonTransformation] + public partial class VirtualMachine : IResource + { + /// + /// Initializes a new instance of the VirtualMachine class. + /// + public VirtualMachine() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachine class. + /// + /// Azure region + /// The amount of memory + /// The number of CPU cores + /// Private Cloud Id + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/virtualMachines/{virtualMachineName} + /// {virtualMachineName} + /// The list of Virtual Disks' + /// Controllers + /// Virtual machine properties + /// The list of Virtual Disks + /// The DNS name of Virtual Machine in + /// VCenter + /// Expose Guest OS or not + /// The path to virtual machine folder in + /// VCenter + /// The name of Guest OS + /// The Guest OS type. Possible values + /// include: 'linux', 'windows', 'other' + /// The list of Virtual NICs + /// Password for login. Deprecated - use + /// customization property + /// The provisioning status of the + /// resource + /// The public ip of Virtual Machine + /// Virtual Machines Resource Pool + /// The status of Virtual machine. Possible values + /// include: 'running', 'suspended', 'poweredoff', 'updating', + /// 'deallocating', 'deleting' + /// Virtual Machine Template Id + /// Username for login. Deprecated - use + /// customization property + /// The list of Virtual VSphere + /// Networks + /// The internal id of Virtual Machine in + /// VCenter + /// VMware tools version + /// The list of tags + /// {resourceProviderNamespace}/{resourceType} + public VirtualMachine(string location, int amountOfRam, int numberOfCores, string privateCloudId, string id = default(string), string name = default(string), IList controllers = default(IList), GuestOSCustomization customization = default(GuestOSCustomization), IList disks = default(IList), string dnsname = default(string), bool? exposeToGuestVM = default(bool?), string folder = default(string), string guestOS = default(string), GuestOSType? guestOSType = default(GuestOSType?), IList nics = default(IList), string password = default(string), string provisioningState = default(string), string publicIP = default(string), ResourcePool resourcePool = default(ResourcePool), VirtualMachineStatus? status = default(VirtualMachineStatus?), string templateId = default(string), string username = default(string), IList vSphereNetworks = default(IList), string vmId = default(string), string vmwaretools = default(string), IDictionary tags = default(IDictionary), string type = default(string)) + { + Id = id; + Location = location; + Name = name; + AmountOfRam = amountOfRam; + Controllers = controllers; + Customization = customization; + Disks = disks; + Dnsname = dnsname; + ExposeToGuestVM = exposeToGuestVM; + Folder = folder; + GuestOS = guestOS; + GuestOSType = guestOSType; + Nics = nics; + NumberOfCores = numberOfCores; + Password = password; + PrivateCloudId = privateCloudId; + ProvisioningState = provisioningState; + PublicIP = publicIP; + ResourcePool = resourcePool; + Status = status; + TemplateId = templateId; + Username = username; + VSphereNetworks = vSphereNetworks; + VmId = vmId; + Vmwaretools = vmwaretools; + Tags = tags; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/virtualMachines/{virtualMachineName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets azure region + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets {virtualMachineName} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the amount of memory + /// + [JsonProperty(PropertyName = "properties.amountOfRam")] + public int AmountOfRam { get; set; } + + /// + /// Gets the list of Virtual Disks' Controllers + /// + [JsonProperty(PropertyName = "properties.controllers")] + public IList Controllers { get; private set; } + + /// + /// Gets or sets virtual machine properties + /// + [JsonProperty(PropertyName = "properties.customization")] + public GuestOSCustomization Customization { get; set; } + + /// + /// Gets or sets the list of Virtual Disks + /// + [JsonProperty(PropertyName = "properties.disks")] + public IList Disks { get; set; } + + /// + /// Gets the DNS name of Virtual Machine in VCenter + /// + [JsonProperty(PropertyName = "properties.dnsname")] + public string Dnsname { get; private set; } + + /// + /// Gets or sets expose Guest OS or not + /// + [JsonProperty(PropertyName = "properties.exposeToGuestVM")] + public bool? ExposeToGuestVM { get; set; } + + /// + /// Gets the path to virtual machine folder in VCenter + /// + [JsonProperty(PropertyName = "properties.folder")] + public string Folder { get; private set; } + + /// + /// Gets the name of Guest OS + /// + [JsonProperty(PropertyName = "properties.guestOS")] + public string GuestOS { get; private set; } + + /// + /// Gets the Guest OS type. Possible values include: 'linux', + /// 'windows', 'other' + /// + [JsonProperty(PropertyName = "properties.guestOSType")] + public GuestOSType? GuestOSType { get; private set; } + + /// + /// Gets or sets the list of Virtual NICs + /// + [JsonProperty(PropertyName = "properties.nics")] + public IList Nics { get; set; } + + /// + /// Gets or sets the number of CPU cores + /// + [JsonProperty(PropertyName = "properties.numberOfCores")] + public int NumberOfCores { get; set; } + + /// + /// Gets or sets password for login. Deprecated - use customization + /// property + /// + [JsonProperty(PropertyName = "properties.password")] + public string Password { get; set; } + + /// + /// Gets or sets private Cloud Id + /// + [JsonProperty(PropertyName = "properties.privateCloudId")] + public string PrivateCloudId { get; set; } + + /// + /// Gets the provisioning status of the resource + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the public ip of Virtual Machine + /// + [JsonProperty(PropertyName = "properties.publicIP")] + public string PublicIP { get; private set; } + + /// + /// Gets or sets virtual Machines Resource Pool + /// + [JsonProperty(PropertyName = "properties.resourcePool")] + public ResourcePool ResourcePool { get; set; } + + /// + /// Gets the status of Virtual machine. Possible values include: + /// 'running', 'suspended', 'poweredoff', 'updating', 'deallocating', + /// 'deleting' + /// + [JsonProperty(PropertyName = "properties.status")] + public VirtualMachineStatus? Status { get; private set; } + + /// + /// Gets or sets virtual Machine Template Id + /// + [JsonProperty(PropertyName = "properties.templateId")] + public string TemplateId { get; set; } + + /// + /// Gets or sets username for login. Deprecated - use customization + /// property + /// + [JsonProperty(PropertyName = "properties.username")] + public string Username { get; set; } + + /// + /// Gets or sets the list of Virtual VSphere Networks + /// + [JsonProperty(PropertyName = "properties.vSphereNetworks")] + public IList VSphereNetworks { get; set; } + + /// + /// Gets the internal id of Virtual Machine in VCenter + /// + [JsonProperty(PropertyName = "properties.vmId")] + public string VmId { get; private set; } + + /// + /// Gets vMware tools version + /// + [JsonProperty(PropertyName = "properties.vmwaretools")] + public string Vmwaretools { get; private set; } + + /// + /// Gets or sets the list of tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets {resourceProviderNamespace}/{resourceType} + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + if (PrivateCloudId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PrivateCloudId"); + } + if (Name != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(Name, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "Name", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (Disks != null) + { + foreach (var element in Disks) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Nics != null) + { + foreach (var element1 in Nics) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (ResourcePool != null) + { + ResourcePool.Validate(); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineStatus.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineStatus.cs new file mode 100644 index 000000000000..2f1287e4e235 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineStatus.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for VirtualMachineStatus. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum VirtualMachineStatus + { + [EnumMember(Value = "running")] + Running, + [EnumMember(Value = "suspended")] + Suspended, + [EnumMember(Value = "poweredoff")] + Poweredoff, + [EnumMember(Value = "updating")] + Updating, + [EnumMember(Value = "deallocating")] + Deallocating, + [EnumMember(Value = "deleting")] + Deleting + } + internal static class VirtualMachineStatusEnumExtension + { + internal static string ToSerializedValue(this VirtualMachineStatus? value) + { + return value == null ? null : ((VirtualMachineStatus)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this VirtualMachineStatus value) + { + switch( value ) + { + case VirtualMachineStatus.Running: + return "running"; + case VirtualMachineStatus.Suspended: + return "suspended"; + case VirtualMachineStatus.Poweredoff: + return "poweredoff"; + case VirtualMachineStatus.Updating: + return "updating"; + case VirtualMachineStatus.Deallocating: + return "deallocating"; + case VirtualMachineStatus.Deleting: + return "deleting"; + } + return null; + } + + internal static VirtualMachineStatus? ParseVirtualMachineStatus(this string value) + { + switch( value ) + { + case "running": + return VirtualMachineStatus.Running; + case "suspended": + return VirtualMachineStatus.Suspended; + case "poweredoff": + return VirtualMachineStatus.Poweredoff; + case "updating": + return VirtualMachineStatus.Updating; + case "deallocating": + return VirtualMachineStatus.Deallocating; + case "deleting": + return VirtualMachineStatus.Deleting; + } + return null; + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineStopMode.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineStopMode.cs new file mode 100644 index 000000000000..b2b254152326 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineStopMode.cs @@ -0,0 +1,55 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// List of virtual machine stop modes + /// + public partial class VirtualMachineStopMode + { + /// + /// Initializes a new instance of the VirtualMachineStopMode class. + /// + public VirtualMachineStopMode() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachineStopMode class. + /// + /// mode indicates a type of stop operation - + /// reboot, suspend, shutdown or power-off. Possible values include: + /// 'reboot', 'suspend', 'shutdown', 'poweroff' + public VirtualMachineStopMode(StopMode? mode = default(StopMode?)) + { + Mode = mode; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets mode indicates a type of stop operation - reboot, + /// suspend, shutdown or power-off. Possible values include: 'reboot', + /// 'suspend', 'shutdown', 'poweroff' + /// + [JsonProperty(PropertyName = "mode")] + public StopMode? Mode { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineTemplate.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineTemplate.cs new file mode 100644 index 000000000000..e280be73942b --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachineTemplate.cs @@ -0,0 +1,229 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Virtual machine template model + /// + [Rest.Serialization.JsonTransformation] + public partial class VirtualMachineTemplate + { + /// + /// Initializes a new instance of the VirtualMachineTemplate class. + /// + public VirtualMachineTemplate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachineTemplate class. + /// + /// The Private Cloud Id + /// virtual machine template id + /// (privateCloudId:vsphereId) + /// Azure region + /// {virtualMachineTemplateName} + /// The amount of memory + /// The list of Virtual Disk + /// Controllers + /// The description of Virtual Machine + /// Template + /// The list of Virtual Disks + /// Expose Guest OS or not + /// The Guest OS + /// The Guest OS types + /// The list of Virtual NICs + /// The number of CPU cores + /// path to folder + /// The list of VSphere networks + /// The tags from VSphere + /// The VMware tools version + /// {resourceProviderNamespace}/{resourceType} + public VirtualMachineTemplate(string privateCloudId, string id = default(string), string location = default(string), string name = default(string), int? amountOfRam = default(int?), IList controllers = default(IList), string description = default(string), IList disks = default(IList), bool? exposeToGuestVM = default(bool?), string guestOS = default(string), string guestOSType = default(string), IList nics = default(IList), int? numberOfCores = default(int?), string path = default(string), IList vSphereNetworks = default(IList), IList vSphereTags = default(IList), string vmwaretools = default(string), string type = default(string)) + { + Id = id; + Location = location; + Name = name; + AmountOfRam = amountOfRam; + Controllers = controllers; + Description = description; + Disks = disks; + ExposeToGuestVM = exposeToGuestVM; + GuestOS = guestOS; + GuestOSType = guestOSType; + Nics = nics; + NumberOfCores = numberOfCores; + Path = path; + PrivateCloudId = privateCloudId; + VSphereNetworks = vSphereNetworks; + VSphereTags = vSphereTags; + Vmwaretools = vmwaretools; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets virtual machine template id (privateCloudId:vsphereId) + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets azure region + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets {virtualMachineTemplateName} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the amount of memory + /// + [JsonProperty(PropertyName = "properties.amountOfRam")] + public int? AmountOfRam { get; set; } + + /// + /// Gets or sets the list of Virtual Disk Controllers + /// + [JsonProperty(PropertyName = "properties.controllers")] + public IList Controllers { get; set; } + + /// + /// Gets or sets the description of Virtual Machine Template + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the list of Virtual Disks + /// + [JsonProperty(PropertyName = "properties.disks")] + public IList Disks { get; set; } + + /// + /// Gets or sets expose Guest OS or not + /// + [JsonProperty(PropertyName = "properties.exposeToGuestVM")] + public bool? ExposeToGuestVM { get; set; } + + /// + /// Gets the Guest OS + /// + [JsonProperty(PropertyName = "properties.guestOS")] + public string GuestOS { get; private set; } + + /// + /// Gets the Guest OS types + /// + [JsonProperty(PropertyName = "properties.guestOSType")] + public string GuestOSType { get; private set; } + + /// + /// Gets or sets the list of Virtual NICs + /// + [JsonProperty(PropertyName = "properties.nics")] + public IList Nics { get; set; } + + /// + /// Gets or sets the number of CPU cores + /// + [JsonProperty(PropertyName = "properties.numberOfCores")] + public int? NumberOfCores { get; set; } + + /// + /// Gets or sets path to folder + /// + [JsonProperty(PropertyName = "properties.path")] + public string Path { get; set; } + + /// + /// Gets or sets the Private Cloud Id + /// + [JsonProperty(PropertyName = "properties.privateCloudId")] + public string PrivateCloudId { get; set; } + + /// + /// Gets or sets the list of VSphere networks + /// + [JsonProperty(PropertyName = "properties.vSphereNetworks")] + public IList VSphereNetworks { get; set; } + + /// + /// Gets or sets the tags from VSphere + /// + [JsonProperty(PropertyName = "properties.vSphereTags")] + public IList VSphereTags { get; set; } + + /// + /// Gets the VMware tools version + /// + [JsonProperty(PropertyName = "properties.vmwaretools")] + public string Vmwaretools { get; private set; } + + /// + /// Gets {resourceProviderNamespace}/{resourceType} + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PrivateCloudId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "PrivateCloudId"); + } + if (Disks != null) + { + foreach (var element in Disks) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Nics != null) + { + foreach (var element1 in Nics) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesCreateOrUpdateHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesCreateOrUpdateHeaders.cs new file mode 100644 index 000000000000..3bb8efc50b2b --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesCreateOrUpdateHeaders.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOrUpdate operation. + /// + public partial class VirtualMachinesCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the + /// VirtualMachinesCreateOrUpdateHeaders class. + /// + public VirtualMachinesCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// VirtualMachinesCreateOrUpdateHeaders class. + /// + public VirtualMachinesCreateOrUpdateHeaders(string azureAsyncOperation = default(string)) + { + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesDeleteHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesDeleteHeaders.cs new file mode 100644 index 000000000000..6314fae18e57 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesDeleteHeaders.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class VirtualMachinesDeleteHeaders + { + /// + /// Initializes a new instance of the VirtualMachinesDeleteHeaders + /// class. + /// + public VirtualMachinesDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachinesDeleteHeaders + /// class. + /// + public VirtualMachinesDeleteHeaders(string azureAsyncOperation = default(string), string location = default(string), int? retryAfter = default(int?), string contentType = default(string)) + { + AzureAsyncOperation = azureAsyncOperation; + Location = location; + RetryAfter = retryAfter; + ContentType = contentType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Content-Type")] + public string ContentType { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesStartHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesStartHeaders.cs new file mode 100644 index 000000000000..ad452e28f5f3 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesStartHeaders.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.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Start operation. + /// + public partial class VirtualMachinesStartHeaders + { + /// + /// Initializes a new instance of the VirtualMachinesStartHeaders + /// class. + /// + public VirtualMachinesStartHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachinesStartHeaders + /// class. + /// + public VirtualMachinesStartHeaders(string azureAsyncOperation = default(string), string location = default(string), int? retryAfter = default(int?), string contentType = default(string)) + { + AzureAsyncOperation = azureAsyncOperation; + Location = location; + RetryAfter = retryAfter; + ContentType = contentType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Content-Type")] + public string ContentType { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesStopHeaders.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesStopHeaders.cs new file mode 100644 index 000000000000..6732366e0831 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualMachinesStopHeaders.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Stop operation. + /// + public partial class VirtualMachinesStopHeaders + { + /// + /// Initializes a new instance of the VirtualMachinesStopHeaders class. + /// + public VirtualMachinesStopHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachinesStopHeaders class. + /// + public VirtualMachinesStopHeaders(string azureAsyncOperation = default(string), string location = default(string), int? retryAfter = default(int?), string contentType = default(string)) + { + AzureAsyncOperation = azureAsyncOperation; + Location = location; + RetryAfter = retryAfter; + ContentType = contentType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Retry-After")] + public int? RetryAfter { get; set; } + + /// + /// + [JsonProperty(PropertyName = "Content-Type")] + public string ContentType { get; set; } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualNetwork.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualNetwork.cs new file mode 100644 index 000000000000..871c2ed27c28 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualNetwork.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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Virtual network model + /// + [Rest.Serialization.JsonTransformation] + public partial class VirtualNetwork + { + /// + /// Initializes a new instance of the VirtualNetwork class. + /// + public VirtualNetwork() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualNetwork class. + /// + /// virtual network id + /// (privateCloudId:vsphereId) + /// can be used in vm + /// creation/deletion + /// Azure region + /// {VirtualNetworkName} + /// The Private Cloud id + /// {resourceProviderNamespace}/{resourceType} + public VirtualNetwork(string id, bool? assignable = default(bool?), string location = default(string), string name = default(string), string privateCloudId = default(string), string type = default(string)) + { + Assignable = assignable; + Id = id; + Location = location; + Name = name; + PrivateCloudId = privateCloudId; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets can be used in vm creation/deletion + /// + [JsonProperty(PropertyName = "assignable")] + public bool? Assignable { get; private set; } + + /// + /// Gets or sets virtual network id (privateCloudId:vsphereId) + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets azure region + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; private set; } + + /// + /// Gets {VirtualNetworkName} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the Private Cloud id + /// + [JsonProperty(PropertyName = "properties.privateCloudId")] + public string PrivateCloudId { get; private set; } + + /// + /// Gets {resourceProviderNamespace}/{resourceType} + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualNic.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualNic.cs new file mode 100644 index 000000000000..e8f301530c89 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Models/VirtualNic.cs @@ -0,0 +1,129 @@ +// +// 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.VMwareCloudSimple.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Virtual NIC model + /// + public partial class VirtualNic + { + /// + /// Initializes a new instance of the VirtualNic class. + /// + public VirtualNic() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualNic class. + /// + /// Virtual Network + /// NIC type. Possible values include: 'E1000', + /// 'E1000E', 'PCNET32', 'VMXNET', 'VMXNET2', 'VMXNET3' + /// guest OS customization for nic + /// NIC ip address + /// NIC MAC address + /// Is NIC powered on/off on boot + /// NIC id + /// NIC name + public VirtualNic(VirtualNetwork network, NICType nicType, GuestOSNICCustomization customization = default(GuestOSNICCustomization), IList ipAddresses = default(IList), string macAddress = default(string), bool? powerOnBoot = default(bool?), string virtualNicId = default(string), string virtualNicName = default(string)) + { + Customization = customization; + IpAddresses = ipAddresses; + MacAddress = macAddress; + Network = network; + NicType = nicType; + PowerOnBoot = powerOnBoot; + VirtualNicId = virtualNicId; + VirtualNicName = virtualNicName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets guest OS customization for nic + /// + [JsonProperty(PropertyName = "customization")] + public GuestOSNICCustomization Customization { get; set; } + + /// + /// Gets or sets NIC ip address + /// + [JsonProperty(PropertyName = "ipAddresses")] + public IList IpAddresses { get; set; } + + /// + /// Gets or sets NIC MAC address + /// + [JsonProperty(PropertyName = "macAddress")] + public string MacAddress { get; set; } + + /// + /// Gets or sets virtual Network + /// + [JsonProperty(PropertyName = "network")] + public VirtualNetwork Network { get; set; } + + /// + /// Gets or sets NIC type. Possible values include: 'E1000', 'E1000E', + /// 'PCNET32', 'VMXNET', 'VMXNET2', 'VMXNET3' + /// + [JsonProperty(PropertyName = "nicType")] + public NICType NicType { get; set; } + + /// + /// Gets or sets is NIC powered on/off on boot + /// + [JsonProperty(PropertyName = "powerOnBoot")] + public bool? PowerOnBoot { get; set; } + + /// + /// Gets or sets NIC id + /// + [JsonProperty(PropertyName = "virtualNicId")] + public string VirtualNicId { get; set; } + + /// + /// Gets NIC name + /// + [JsonProperty(PropertyName = "virtualNicName")] + public string VirtualNicName { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Network == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Network"); + } + if (Network != null) + { + Network.Validate(); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Operations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Operations.cs new file mode 100644 index 000000000000..707269dc4a29 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/Operations.cs @@ -0,0 +1,619 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// Operations operations. + /// + internal partial class Operations : IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.VMwareCloudSimple/operations").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements get of async operation + /// + /// + /// Return an async operation + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// referer url + /// + /// + /// operation id + /// + /// + /// 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 regionId, string referer, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (referer == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "referer"); + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("referer", referer); + tracingParameters.Add("operationId", operationId); + 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}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/operationResults/{operationId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (referer != null) + { + if (_httpRequest.Headers.Contains("Referer")) + { + _httpRequest.Headers.Remove("Referer"); + } + _httpRequest.Headers.TryAddWithoutValidation("Referer", referer); + } + 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 != 202 && (int)_statusCode != 204) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + 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; + } + + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/OperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..e500236f61ff --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/OperationsExtensions.cs @@ -0,0 +1,151 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements get of async operation + /// + /// + /// Return an async operation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// referer url + /// + /// + /// operation id + /// + public static OperationResource Get(this IOperations operations, string regionId, string referer, string operationId) + { + return operations.GetAsync(regionId, referer, operationId).GetAwaiter().GetResult(); + } + + /// + /// Implements get of async operation + /// + /// + /// Return an async operation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// referer url + /// + /// + /// operation id + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IOperations operations, string regionId, string referer, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(regionId, referer, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list of available operations + /// + /// + /// Return list of operations + /// + /// + /// 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 IOperations 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/PrivateCloudsOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/PrivateCloudsOperations.cs new file mode 100644 index 000000000000..88b797a104d4 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/PrivateCloudsOperations.cs @@ -0,0 +1,604 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// PrivateCloudsOperations operations. + /// + internal partial class PrivateCloudsOperations : IServiceOperations, IPrivateCloudsOperations + { + /// + /// Initializes a new instance of the PrivateCloudsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateCloudsOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// 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 regionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements private cloud GET method + /// + /// + /// Returns private cloud by its name + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// 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 pcName, string regionId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("regionId", regionId); + 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}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/PrivateCloudsOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/PrivateCloudsOperationsExtensions.cs new file mode 100644 index 000000000000..31fcbf2f08ae --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/PrivateCloudsOperationsExtensions.cs @@ -0,0 +1,151 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateCloudsOperations. + /// + public static partial class PrivateCloudsOperationsExtensions + { + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + public static IPage List(this IPrivateCloudsOperations operations, string regionId) + { + return operations.ListAsync(regionId).GetAwaiter().GetResult(); + } + + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPrivateCloudsOperations operations, string regionId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(regionId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements private cloud GET method + /// + /// + /// Returns private cloud by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + public static PrivateCloud Get(this IPrivateCloudsOperations operations, string pcName, string regionId) + { + return operations.GetAsync(pcName, regionId).GetAwaiter().GetResult(); + } + + /// + /// Implements private cloud GET method + /// + /// + /// Returns private cloud by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateCloudsOperations operations, string pcName, string regionId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(pcName, regionId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IPrivateCloudsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements private cloud list GET method + /// + /// + /// Returns list of private clouds in particular region + /// + /// + /// 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 IPrivateCloudsOperations 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ResourcePoolsOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ResourcePoolsOperations.cs new file mode 100644 index 000000000000..1c72eeddddb6 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ResourcePoolsOperations.cs @@ -0,0 +1,622 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// ResourcePoolsOperations operations. + /// + internal partial class ResourcePoolsOperations : IServiceOperations, IResourcePoolsOperations + { + /// + /// Initializes a new instance of the ResourcePoolsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ResourcePoolsOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud 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 regionId, string pcName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/resourcePools").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements get of resource pool + /// + /// + /// Returns resource pool templates by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// resource pool id (vsphereId) + /// + /// + /// 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 regionId, string pcName, string resourcePoolName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (resourcePoolName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourcePoolName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("resourcePoolName", resourcePoolName); + 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}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/resourcePools/{resourcePoolName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + _url = _url.Replace("{resourcePoolName}", System.Uri.EscapeDataString(resourcePoolName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ResourcePoolsOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ResourcePoolsOperationsExtensions.cs new file mode 100644 index 000000000000..244a79cef3f8 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/ResourcePoolsOperationsExtensions.cs @@ -0,0 +1,163 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ResourcePoolsOperations. + /// + public static partial class ResourcePoolsOperationsExtensions + { + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + public static IPage List(this IResourcePoolsOperations operations, string regionId, string pcName) + { + return operations.ListAsync(regionId, pcName).GetAwaiter().GetResult(); + } + + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IResourcePoolsOperations operations, string regionId, string pcName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(regionId, pcName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements get of resource pool + /// + /// + /// Returns resource pool templates by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// resource pool id (vsphereId) + /// + public static ResourcePool Get(this IResourcePoolsOperations operations, string regionId, string pcName, string resourcePoolName) + { + return operations.GetAsync(regionId, pcName, resourcePoolName).GetAwaiter().GetResult(); + } + + /// + /// Implements get of resource pool + /// + /// + /// Returns resource pool templates by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// resource pool id (vsphereId) + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IResourcePoolsOperations operations, string regionId, string pcName, string resourcePoolName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(regionId, pcName, resourcePoolName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IResourcePoolsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements get of resource pools list + /// + /// + /// Returns list of resource pools in region for private cloud + /// + /// + /// 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 IResourcePoolsOperations 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SdkInfo_VMwareCloudSimple.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SdkInfo_VMwareCloudSimple.cs new file mode 100644 index 000000000000..8f602ee95699 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SdkInfo_VMwareCloudSimple.cs @@ -0,0 +1,37 @@ + +// +// 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.VMwareCloudSimple +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_VMwareCloudSimple + { + get + { + return new Tuple[] + { + new Tuple("VMwareCloudSimple", "DedicatedCloudNodes", "2019-04-01"), + new Tuple("VMwareCloudSimple", "DedicatedCloudServices", "2019-04-01"), + new Tuple("VMwareCloudSimple", "Operations", "2019-04-01"), + new Tuple("VMwareCloudSimple", "PrivateClouds", "2019-04-01"), + new Tuple("VMwareCloudSimple", "ResourcePools", "2019-04-01"), + new Tuple("VMwareCloudSimple", "SkusAvailability", "2019-04-01"), + new Tuple("VMwareCloudSimple", "Usages", "2019-04-01"), + new Tuple("VMwareCloudSimple", "VirtualMachineTemplates", "2019-04-01"), + new Tuple("VMwareCloudSimple", "VirtualMachines", "2019-04-01"), + new Tuple("VMwareCloudSimple", "VirtualNetworks", "2019-04-01"), + new Tuple("VMwareCloudSimple", "customizationPolicies", "2019-04-01"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SkusAvailabilityOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SkusAvailabilityOperations.cs new file mode 100644 index 000000000000..c5af4ade1fb3 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SkusAvailabilityOperations.cs @@ -0,0 +1,418 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// SkusAvailabilityOperations operations. + /// + internal partial class SkusAvailabilityOperations : IServiceOperations, ISkusAvailabilityOperations + { + /// + /// Initializes a new instance of the SkusAvailabilityOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SkusAvailabilityOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// sku id, if no sku is passed availability for all skus will be returned + /// + /// + /// 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 regionId, string skuId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("skuId", skuId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/availabilities").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + List _queryParameters = new List(); + if (skuId != null) + { + _queryParameters.Add(string.Format("skuId={0}", System.Uri.EscapeDataString(skuId))); + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SkusAvailabilityOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SkusAvailabilityOperationsExtensions.cs new file mode 100644 index 000000000000..15b5ab15fe49 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/SkusAvailabilityOperationsExtensions.cs @@ -0,0 +1,111 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SkusAvailabilityOperations. + /// + public static partial class SkusAvailabilityOperationsExtensions + { + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// sku id, if no sku is passed availability for all skus will be returned + /// + public static IPage List(this ISkusAvailabilityOperations operations, string regionId, string skuId = default(string)) + { + return operations.ListAsync(regionId, skuId).GetAwaiter().GetResult(); + } + + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// sku id, if no sku is passed availability for all skus will be returned + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ISkusAvailabilityOperations operations, string regionId, string skuId = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(regionId, skuId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ISkusAvailabilityOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements SkuAvailability List method + /// + /// + /// Returns list of available resources in region + /// + /// + /// 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 ISkusAvailabilityOperations 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/UsagesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/UsagesOperations.cs new file mode 100644 index 000000000000..30691715ebeb --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/UsagesOperations.cs @@ -0,0 +1,419 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// UsagesOperations operations. + /// + internal partial class UsagesOperations : IServiceOperations, IUsagesOperations + { + /// + /// Initializes a new instance of the UsagesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal UsagesOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The filter to apply on the list operation. only name.value is allowed here + /// as a filter e.g. $filter=name.value eq 'xxxx' + /// + /// + /// 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 regionId, string filter = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/usages").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + List _queryParameters = new List(); + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/UsagesOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/UsagesOperationsExtensions.cs new file mode 100644 index 000000000000..259bd776c36e --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/UsagesOperationsExtensions.cs @@ -0,0 +1,113 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for UsagesOperations. + /// + public static partial class UsagesOperationsExtensions + { + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The filter to apply on the list operation. only name.value is allowed here + /// as a filter e.g. $filter=name.value eq 'xxxx' + /// + public static IPage List(this IUsagesOperations operations, string regionId, string filter = default(string)) + { + return operations.ListAsync(regionId, filter).GetAwaiter().GetResult(); + } + + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The filter to apply on the list operation. only name.value is allowed here + /// as a filter e.g. $filter=name.value eq 'xxxx' + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IUsagesOperations operations, string regionId, string filter = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(regionId, filter, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IUsagesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements Usages List method + /// + /// + /// Returns list of usage in region + /// + /// + /// 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 IUsagesOperations 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VMwareCloudSimpleClient.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VMwareCloudSimpleClient.cs new file mode 100644 index 000000000000..a6015409a87f --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VMwareCloudSimpleClient.cs @@ -0,0 +1,420 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + + /// + /// Description of the new service + /// + public partial class VMwareCloudSimpleClient : ServiceClient, IVMwareCloudSimpleClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// The subscription ID. + /// + public string SubscriptionId { get; set; } + + /// + /// Client API version. + /// + public string ApiVersion { get; private set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IDedicatedCloudNodesOperations. + /// + public virtual IDedicatedCloudNodesOperations DedicatedCloudNodes { get; private set; } + + /// + /// Gets the IDedicatedCloudServicesOperations. + /// + public virtual IDedicatedCloudServicesOperations DedicatedCloudServices { get; private set; } + + /// + /// Gets the ISkusAvailabilityOperations. + /// + public virtual ISkusAvailabilityOperations SkusAvailability { get; private set; } + + /// + /// Gets the IPrivateCloudsOperations. + /// + public virtual IPrivateCloudsOperations PrivateClouds { get; private set; } + + /// + /// Gets the ICustomizationPoliciesOperations. + /// + public virtual ICustomizationPoliciesOperations CustomizationPolicies { get; private set; } + + /// + /// Gets the IResourcePoolsOperations. + /// + public virtual IResourcePoolsOperations ResourcePools { get; private set; } + + /// + /// Gets the IVirtualMachineTemplatesOperations. + /// + public virtual IVirtualMachineTemplatesOperations VirtualMachineTemplates { get; private set; } + + /// + /// Gets the IVirtualNetworksOperations. + /// + public virtual IVirtualNetworksOperations VirtualNetworks { get; private set; } + + /// + /// Gets the IUsagesOperations. + /// + public virtual IUsagesOperations Usages { get; private set; } + + /// + /// Gets the IVirtualMachinesOperations. + /// + public virtual IVirtualMachinesOperations VirtualMachines { get; private set; } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling VMwareCloudSimpleClient.Dispose(). False: will not dispose provided httpClient + protected VMwareCloudSimpleClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected VMwareCloudSimpleClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected VMwareCloudSimpleClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected VMwareCloudSimpleClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected VMwareCloudSimpleClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public VMwareCloudSimpleClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling VMwareCloudSimpleClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public VMwareCloudSimpleClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public VMwareCloudSimpleClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public VMwareCloudSimpleClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the VMwareCloudSimpleClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public VMwareCloudSimpleClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + Operations = new Operations(this); + DedicatedCloudNodes = new DedicatedCloudNodesOperations(this); + DedicatedCloudServices = new DedicatedCloudServicesOperations(this); + SkusAvailability = new SkusAvailabilityOperations(this); + PrivateClouds = new PrivateCloudsOperations(this); + CustomizationPolicies = new CustomizationPoliciesOperations(this); + ResourcePools = new ResourcePoolsOperations(this); + VirtualMachineTemplates = new VirtualMachineTemplatesOperations(this); + VirtualNetworks = new VirtualNetworksOperations(this); + Usages = new UsagesOperations(this); + VirtualMachines = new VirtualMachinesOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2019-04-01"; + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachineTemplatesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachineTemplatesOperations.cs new file mode 100644 index 000000000000..858df2d5a5fe --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachineTemplatesOperations.cs @@ -0,0 +1,634 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// VirtualMachineTemplatesOperations operations. + /// + internal partial class VirtualMachineTemplatesOperations : IServiceOperations, IVirtualMachineTemplatesOperations + { + /// + /// Initializes a new instance of the VirtualMachineTemplatesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal VirtualMachineTemplatesOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private cloud + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// Resource pool used to derive vSphere cluster which contains VM templates + /// + /// + /// 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 pcName, string regionId, string resourcePoolName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (resourcePoolName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourcePoolName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("resourcePoolName", resourcePoolName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/virtualMachineTemplates").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (resourcePoolName != null) + { + _queryParameters.Add(string.Format("resourcePoolName={0}", System.Uri.EscapeDataString(resourcePoolName))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements virtual machine template GET method + /// + /// + /// Returns virtual machine templates by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual machine template id (vsphereId) + /// + /// + /// 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 regionId, string pcName, string virtualMachineTemplateName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (virtualMachineTemplateName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineTemplateName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("virtualMachineTemplateName", virtualMachineTemplateName); + 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}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/virtualMachineTemplates/{virtualMachineTemplateName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + _url = _url.Replace("{virtualMachineTemplateName}", System.Uri.EscapeDataString(virtualMachineTemplateName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private cloud + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachineTemplatesOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachineTemplatesOperationsExtensions.cs new file mode 100644 index 000000000000..f707ce4ec3e1 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachineTemplatesOperationsExtensions.cs @@ -0,0 +1,169 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for VirtualMachineTemplatesOperations. + /// + public static partial class VirtualMachineTemplatesOperationsExtensions + { + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// Resource pool used to derive vSphere cluster which contains VM templates + /// + public static IPage List(this IVirtualMachineTemplatesOperations operations, string pcName, string regionId, string resourcePoolName) + { + return operations.ListAsync(pcName, regionId, resourcePoolName).GetAwaiter().GetResult(); + } + + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The private cloud name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// Resource pool used to derive vSphere cluster which contains VM templates + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IVirtualMachineTemplatesOperations operations, string pcName, string regionId, string resourcePoolName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(pcName, regionId, resourcePoolName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual machine template GET method + /// + /// + /// Returns virtual machine templates by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual machine template id (vsphereId) + /// + public static VirtualMachineTemplate Get(this IVirtualMachineTemplatesOperations operations, string regionId, string pcName, string virtualMachineTemplateName) + { + return operations.GetAsync(regionId, pcName, virtualMachineTemplateName).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine template GET method + /// + /// + /// Returns virtual machine templates by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual machine template id (vsphereId) + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVirtualMachineTemplatesOperations operations, string regionId, string pcName, string virtualMachineTemplateName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(regionId, pcName, virtualMachineTemplateName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IVirtualMachineTemplatesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list of available VM templates + /// + /// + /// Returns list of virtual machine templates in region for private cloud + /// + /// + /// 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 IVirtualMachineTemplatesOperations 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/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachinesOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachinesOperations.cs new file mode 100644 index 000000000000..70434052c1d2 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachinesOperations.cs @@ -0,0 +1,2259 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// VirtualMachinesOperations operations. + /// + internal partial class VirtualMachinesOperations : IServiceOperations, IVirtualMachinesOperations + { + /// + /// Initializes a new instance of the VirtualMachinesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal VirtualMachinesOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within subscription + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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(string filter = default(string), 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + 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.VMwareCloudSimple/virtualMachines").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within resource group + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), 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 (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", 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.VMwareCloudSimple/virtualMachines").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements virtual machine GET method + /// + /// + /// Get virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine 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> GetWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, 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 (virtualMachineName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("virtualMachineName", virtualMachineName); + 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.VMwareCloudSimple/virtualMachines/{virtualMachineName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualMachineName}", System.Uri.EscapeDataString(virtualMachineName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, virtualMachineRequest, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, tags, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> StartWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginStartWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements shutdown, poweroff, and suspend method for a virtual machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible values + /// include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown or + /// power-off. Possible values include: 'reboot', 'suspend', 'shutdown', + /// 'poweroff' + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> StopWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationHeaderResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, mode, mode1, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest, 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 (referer == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "referer"); + } + if (virtualMachineName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineName"); + } + if (virtualMachineName != null) + { + if (!System.Text.RegularExpressions.Regex.IsMatch(virtualMachineName, "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$")) + { + throw new ValidationException(ValidationRules.Pattern, "virtualMachineName", "^[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?$"); + } + } + if (virtualMachineRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineRequest"); + } + if (virtualMachineRequest != null) + { + virtualMachineRequest.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("referer", referer); + tracingParameters.Add("virtualMachineName", virtualMachineName); + tracingParameters.Add("virtualMachineRequest", virtualMachineRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VMwareCloudSimple/virtualMachines/{virtualMachineName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualMachineName}", System.Uri.EscapeDataString(virtualMachineName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (referer != null) + { + if (_httpRequest.Headers.Contains("Referer")) + { + _httpRequest.Headers.Remove("Referer"); + } + _httpRequest.Headers.TryAddWithoutValidation("Referer", referer); + } + 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(virtualMachineRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(virtualMachineRequest, 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + 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; + } + + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, 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 (referer == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "referer"); + } + if (virtualMachineName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("referer", referer); + tracingParameters.Add("virtualMachineName", virtualMachineName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VMwareCloudSimple/virtualMachines/{virtualMachineName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualMachineName}", System.Uri.EscapeDataString(virtualMachineName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (referer != null) + { + if (_httpRequest.Headers.Contains("Referer")) + { + _httpRequest.Headers.Remove("Referer"); + } + _httpRequest.Headers.TryAddWithoutValidation("Referer", referer); + } + 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 != 202 && (int)_statusCode != 204) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + 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; + } + + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary), 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 (virtualMachineName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + PatchPayload virtualMachineRequest = new PatchPayload(); + if (tags != null) + { + virtualMachineRequest.Tags = tags; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("virtualMachineName", virtualMachineName); + tracingParameters.Add("virtualMachineRequest", virtualMachineRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VMwareCloudSimple/virtualMachines/{virtualMachineName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualMachineName}", System.Uri.EscapeDataString(virtualMachineName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(virtualMachineRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(virtualMachineRequest, 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// 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> BeginStartWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, 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 (referer == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "referer"); + } + if (virtualMachineName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("referer", referer); + tracingParameters.Add("virtualMachineName", virtualMachineName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStart", 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.VMwareCloudSimple/virtualMachines/{virtualMachineName}/start").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualMachineName}", System.Uri.EscapeDataString(virtualMachineName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (referer != null) + { + if (_httpRequest.Headers.Contains("Referer")) + { + _httpRequest.Headers.Remove("Referer"); + } + _httpRequest.Headers.TryAddWithoutValidation("Referer", referer); + } + 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 != 202) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + 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; + } + + /// + /// Implements shutdown, poweroff, and suspend method for a virtual machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible values + /// include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown or + /// power-off. Possible values include: 'reboot', 'suspend', 'shutdown', + /// 'poweroff' + /// + /// + /// 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> BeginStopWithHttpMessagesAsync(string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?), 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 (referer == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "referer"); + } + if (virtualMachineName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + VirtualMachineStopMode m = default(VirtualMachineStopMode); + if (mode1 != null) + { + m = new VirtualMachineStopMode(); + m.Mode = mode1; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("referer", referer); + tracingParameters.Add("virtualMachineName", virtualMachineName); + tracingParameters.Add("mode", mode); + tracingParameters.Add("m", m); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStop", 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.VMwareCloudSimple/virtualMachines/{virtualMachineName}/stop").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualMachineName}", System.Uri.EscapeDataString(virtualMachineName)); + List _queryParameters = new List(); + if (mode != null) + { + _queryParameters.Add(string.Format("mode={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(mode, Client.SerializationSettings).Trim('"')))); + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (referer != null) + { + if (_httpRequest.Headers.Contains("Referer")) + { + _httpRequest.Headers.Remove("Referer"); + } + _httpRequest.Headers.TryAddWithoutValidation("Referer", referer); + } + 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(m != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(m, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + 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; + } + + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within 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>> ListByResourceGroupNextWithHttpMessagesAsync(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, "ListByResourceGroupNext", 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachinesOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachinesOperationsExtensions.cs new file mode 100644 index 000000000000..1b20e00864df --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualMachinesOperationsExtensions.cs @@ -0,0 +1,831 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for VirtualMachinesOperations. + /// + public static partial class VirtualMachinesOperationsExtensions + { + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + public static IPage ListBySubscription(this IVirtualMachinesOperations operations, string filter = default(string), int? top = default(int?), string skipToken = default(string)) + { + return operations.ListBySubscriptionAsync(filter, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IVirtualMachinesOperations operations, string filter = default(string), int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(filter, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + public static IPage ListByResourceGroup(this IVirtualMachinesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// The filter to apply on the list operation + /// + /// + /// The maximum number of record sets to return + /// + /// + /// to be used by nextLink implementation + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual machine GET method + /// + /// + /// Get virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + public static VirtualMachine Get(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName) + { + return operations.GetAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine GET method + /// + /// + /// Get virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualMachineName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + public static VirtualMachine CreateOrUpdate(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest) + { + return operations.CreateOrUpdateAsync(resourceGroupName, referer, virtualMachineName, virtualMachineRequest).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, virtualMachineRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + public static VirtualMachinesDeleteHeaders Delete(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName) + { + return operations.DeleteAsync(resourceGroupName, referer, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + public static VirtualMachine Update(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, virtualMachineName, tags).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + public static VirtualMachinesStartHeaders Start(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName) + { + return operations.StartAsync(resourceGroupName, referer, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// The cancellation token. + /// + public static async Task StartAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.StartWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements shutdown, poweroff, and suspend method for a virtual machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible values + /// include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown or + /// power-off. Possible values include: 'reboot', 'suspend', 'shutdown', + /// 'poweroff' + /// + public static VirtualMachinesStopHeaders Stop(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?)) + { + return operations.StopAsync(resourceGroupName, referer, virtualMachineName, mode, mode1).GetAwaiter().GetResult(); + } + + /// + /// Implements shutdown, poweroff, and suspend method for a virtual machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible values + /// include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown or + /// power-off. Possible values include: 'reboot', 'suspend', 'shutdown', + /// 'poweroff' + /// + /// + /// The cancellation token. + /// + public static async Task StopAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.StopWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, mode, mode1, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + public static VirtualMachine BeginCreateOrUpdate(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, referer, virtualMachineName, virtualMachineRequest).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine PUT method + /// + /// + /// Create Or Update Virtual Machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// Create or Update Virtual Machine request + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, VirtualMachine virtualMachineRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, virtualMachineRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + public static VirtualMachinesDeleteHeaders BeginDelete(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName) + { + return operations.BeginDeleteAsync(resourceGroupName, referer, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine DELETE method + /// + /// + /// Delete virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + public static VirtualMachine BeginUpdate(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary)) + { + return operations.BeginUpdateAsync(resourceGroupName, virtualMachineName, tags).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine PATCH method + /// + /// + /// Patch virtual machine properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// virtual machine name + /// + /// + /// The tags key:value pairs + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + public static VirtualMachinesStartHeaders BeginStart(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName) + { + return operations.BeginStartAsync(resourceGroupName, referer, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements a start method for a virtual machine + /// + /// + /// Power on virtual machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// The cancellation token. + /// + public static async Task BeginStartAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginStartWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements shutdown, poweroff, and suspend method for a virtual machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible values + /// include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown or + /// power-off. Possible values include: 'reboot', 'suspend', 'shutdown', + /// 'poweroff' + /// + public static VirtualMachinesStopHeaders BeginStop(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?)) + { + return operations.BeginStopAsync(resourceGroupName, referer, virtualMachineName, mode, mode1).GetAwaiter().GetResult(); + } + + /// + /// Implements shutdown, poweroff, and suspend method for a virtual machine + /// + /// + /// Power off virtual machine, options: shutdown, poweroff, and suspend + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group + /// + /// + /// referer url + /// + /// + /// virtual machine name + /// + /// + /// query stop mode parameter (reboot, shutdown, etc...). Possible values + /// include: 'reboot', 'suspend', 'shutdown', 'poweroff' + /// + /// + /// mode indicates a type of stop operation - reboot, suspend, shutdown or + /// power-off. Possible values include: 'reboot', 'suspend', 'shutdown', + /// 'poweroff' + /// + /// + /// The cancellation token. + /// + public static async Task BeginStopAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string referer, string virtualMachineName, StopMode? mode = default(StopMode?), StopMode? mode1 = default(StopMode?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, referer, virtualMachineName, mode, mode1, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IVirtualMachinesOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list virtual machine within subscription method + /// + /// + /// Returns list virtual machine within 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 IVirtualMachinesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IVirtualMachinesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list virtual machine within RG method + /// + /// + /// Returns list of virtual machine within 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> ListByResourceGroupNextAsync(this IVirtualMachinesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualNetworksOperations.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualNetworksOperations.cs new file mode 100644 index 000000000000..8f0925ae6513 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualNetworksOperations.cs @@ -0,0 +1,635 @@ +// +// 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.VMwareCloudSimple +{ + 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; + + /// + /// VirtualNetworksOperations operations. + /// + internal partial class VirtualNetworksOperations : IServiceOperations, IVirtualNetworksOperations + { + /// + /// Initializes a new instance of the VirtualNetworksOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal VirtualNetworksOperations(VMwareCloudSimpleClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the VMwareCloudSimpleClient + /// + public VMwareCloudSimpleClient Client { get; private set; } + + /// + /// Implements list available virtual networks within a subscription method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// Resource pool used to derive vSphere cluster which contains virtual + /// networks + /// + /// + /// 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 regionId, string pcName, string resourcePoolName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (resourcePoolName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourcePoolName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("resourcePoolName", resourcePoolName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/virtualNetworks").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (resourcePoolName != null) + { + _queryParameters.Add(string.Format("resourcePoolName={0}", System.Uri.EscapeDataString(resourcePoolName))); + } + 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements virtual network GET method + /// + /// + /// Return virtual network by its name + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual network id (vsphereId) + /// + /// + /// 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 regionId, string pcName, string virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (regionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "regionId"); + } + if (pcName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "pcName"); + } + if (virtualNetworkName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("regionId", regionId); + tracingParameters.Add("pcName", pcName); + tracingParameters.Add("virtualNetworkName", virtualNetworkName); + 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}/providers/Microsoft.VMwareCloudSimple/locations/{regionId}/privateClouds/{pcName}/virtualNetworks/{virtualNetworkName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{regionId}", System.Uri.EscapeDataString(regionId)); + _url = _url.Replace("{pcName}", System.Uri.EscapeDataString(pcName)); + _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements list available virtual networks within a subscription method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// 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 CSRPErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CSRPError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualNetworksOperationsExtensions.cs b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualNetworksOperationsExtensions.cs new file mode 100644 index 000000000000..465eb871e6f8 --- /dev/null +++ b/sdk/vmwarecloudsimple/Microsoft.Azure.Management.VMwareCloudSimple/src/Generated/VirtualNetworksOperationsExtensions.cs @@ -0,0 +1,171 @@ +// +// 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.VMwareCloudSimple +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for VirtualNetworksOperations. + /// + public static partial class VirtualNetworksOperationsExtensions + { + /// + /// Implements list available virtual networks within a subscription method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// Resource pool used to derive vSphere cluster which contains virtual + /// networks + /// + public static IPage List(this IVirtualNetworksOperations operations, string regionId, string pcName, string resourcePoolName) + { + return operations.ListAsync(regionId, pcName, resourcePoolName).GetAwaiter().GetResult(); + } + + /// + /// Implements list available virtual networks within a subscription method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// Resource pool used to derive vSphere cluster which contains virtual + /// networks + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IVirtualNetworksOperations operations, string regionId, string pcName, string resourcePoolName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(regionId, pcName, resourcePoolName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual network GET method + /// + /// + /// Return virtual network by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual network id (vsphereId) + /// + public static VirtualNetwork Get(this IVirtualNetworksOperations operations, string regionId, string pcName, string virtualNetworkName) + { + return operations.GetAsync(regionId, pcName, virtualNetworkName).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual network GET method + /// + /// + /// Return virtual network by its name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The region Id (westus, eastus) + /// + /// + /// The private cloud name + /// + /// + /// virtual network id (vsphereId) + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVirtualNetworksOperations operations, string regionId, string pcName, string virtualNetworkName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(regionId, pcName, virtualNetworkName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements list available virtual networks within a subscription method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IVirtualNetworksOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements list available virtual networks within a subscription method + /// + /// + /// Return list of virtual networks in location for private cloud + /// + /// + /// 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 IVirtualNetworksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}