diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/AzureArcVMwareManagementServiceAPIClient.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/AzureArcVMwareManagementServiceAPIClient.cs new file mode 100644 index 000000000000..8c36fa4d16d5 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/AzureArcVMwareManagementServiceAPIClient.cs @@ -0,0 +1,434 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// Self service experience for VMware. + /// + public partial class AzureArcVMwareManagementServiceAPIClient : ServiceClient, IAzureArcVMwareManagementServiceAPIClient, 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 IResourcePoolsOperations. + /// + public virtual IResourcePoolsOperations ResourcePools { get; private set; } + + /// + /// Gets the IClustersOperations. + /// + public virtual IClustersOperations Clusters { get; private set; } + + /// + /// Gets the IHostsOperations. + /// + public virtual IHostsOperations Hosts { get; private set; } + + /// + /// Gets the IDatastoresOperations. + /// + public virtual IDatastoresOperations Datastores { get; private set; } + + /// + /// Gets the IVCentersOperations. + /// + public virtual IVCentersOperations VCenters { get; private set; } + + /// + /// Gets the IVirtualMachinesOperations. + /// + public virtual IVirtualMachinesOperations VirtualMachines { 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 IInventoryItemsOperations. + /// + public virtual IInventoryItemsOperations InventoryItems { get; private set; } + + /// + /// Gets the IHybridIdentityMetadataOperations. + /// + public virtual IHybridIdentityMetadataOperations HybridIdentityMetadata { get; private set; } + + /// + /// Gets the IMachineExtensionsOperations. + /// + public virtual IMachineExtensionsOperations MachineExtensions { get; private set; } + + /// + /// Gets the IGuestAgentsOperations. + /// + public virtual IGuestAgentsOperations GuestAgents { get; private set; } + + /// + /// Initializes a new instance of the AzureArcVMwareManagementServiceAPIClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling AzureArcVMwareManagementServiceAPIClient.Dispose(). False: will not dispose provided httpClient + protected AzureArcVMwareManagementServiceAPIClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the AzureArcVMwareManagementServiceAPIClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AzureArcVMwareManagementServiceAPIClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the AzureArcVMwareManagementServiceAPIClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected AzureArcVMwareManagementServiceAPIClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the AzureArcVMwareManagementServiceAPIClient 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 AzureArcVMwareManagementServiceAPIClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the AzureArcVMwareManagementServiceAPIClient 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 AzureArcVMwareManagementServiceAPIClient(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 AzureArcVMwareManagementServiceAPIClient 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 AzureArcVMwareManagementServiceAPIClient(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 AzureArcVMwareManagementServiceAPIClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling AzureArcVMwareManagementServiceAPIClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public AzureArcVMwareManagementServiceAPIClient(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 AzureArcVMwareManagementServiceAPIClient 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 AzureArcVMwareManagementServiceAPIClient(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 AzureArcVMwareManagementServiceAPIClient 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 AzureArcVMwareManagementServiceAPIClient(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 AzureArcVMwareManagementServiceAPIClient 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 AzureArcVMwareManagementServiceAPIClient(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); + ResourcePools = new ResourcePoolsOperations(this); + Clusters = new ClustersOperations(this); + Hosts = new HostsOperations(this); + Datastores = new DatastoresOperations(this); + VCenters = new VCentersOperations(this); + VirtualMachines = new VirtualMachinesOperations(this); + VirtualMachineTemplates = new VirtualMachineTemplatesOperations(this); + VirtualNetworks = new VirtualNetworksOperations(this); + InventoryItems = new InventoryItemsOperations(this); + HybridIdentityMetadata = new HybridIdentityMetadataOperations(this); + MachineExtensions = new MachineExtensionsOperations(this); + GuestAgents = new GuestAgentsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-10-01-preview"; + 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() + } + }; + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("inventoryType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("inventoryType")); + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ClustersOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ClustersOperations.cs new file mode 100644 index 000000000000..b4ce2d39b5dc --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ClustersOperations.cs @@ -0,0 +1,1620 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// ClustersOperations operations. + /// + internal partial class ClustersOperations : IServiceOperations, IClustersOperations + { + /// + /// Initializes a new instance of the ClustersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ClustersOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster body = default(Cluster), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, clusterName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a cluster. + /// + /// + /// Implements cluster GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 clusterName, 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 (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + 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("clusterName", clusterName); + 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.ConnectedVMwarevSphere/clusters/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a cluster. + /// + /// + /// API to update certain properties of the cluster resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Resource tags. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, 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 (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + ResourcePatch body = default(ResourcePatch); + if (tags != null) + { + body = new ResourcePatch(); + body.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("clusterName", clusterName); + tracingParameters.Add("body", body); + 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.ConnectedVMwarevSphere/clusters/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string clusterName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/clusters").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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster body = default(Cluster), 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 (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + 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("clusterName", clusterName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 clusterName, bool? force = default(bool?), 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 (clusterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "clusterName"); + } + 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("clusterName", clusterName); + tracingParameters.Add("force", force); + 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.ConnectedVMwarevSphere/clusters/{clusterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{clusterName}", System.Uri.EscapeDataString(clusterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ClustersOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ClustersOperationsExtensions.cs new file mode 100644 index 000000000000..0117dafe64bd --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ClustersOperationsExtensions.cs @@ -0,0 +1,481 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 ClustersOperations. + /// + public static partial class ClustersOperationsExtensions + { + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + public static Cluster Create(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster body = default(Cluster)) + { + return operations.CreateAsync(resourceGroupName, clusterName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster body = default(Cluster), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, clusterName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a cluster. + /// + /// + /// Implements cluster GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + public static Cluster Get(this IClustersOperations operations, string resourceGroupName, string clusterName) + { + return operations.GetAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); + } + + /// + /// Gets a cluster. + /// + /// + /// Implements cluster GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, clusterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a cluster. + /// + /// + /// API to update certain properties of the cluster resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Resource tags. + /// + public static Cluster Update(this IClustersOperations operations, string resourceGroupName, string clusterName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, clusterName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates a cluster. + /// + /// + /// API to update certain properties of the cluster resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Resource tags. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, clusterName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, clusterName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, clusterName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IClustersOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IClustersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IClustersOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IClustersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + public static Cluster BeginCreate(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster body = default(Cluster)) + { + return operations.BeginCreateAsync(resourceGroupName, clusterName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, Cluster body = default(Cluster), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, clusterName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, clusterName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IClustersOperations operations, string resourceGroupName, string clusterName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, clusterName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IClustersOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IClustersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in 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 IClustersOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IClustersOperations 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/DatastoresOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/DatastoresOperations.cs new file mode 100644 index 000000000000..e34359b31769 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/DatastoresOperations.cs @@ -0,0 +1,1620 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// DatastoresOperations operations. + /// + internal partial class DatastoresOperations : IServiceOperations, IDatastoresOperations + { + /// + /// Initializes a new instance of the DatastoresOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DatastoresOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string datastoreName, Datastore body = default(Datastore), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, datastoreName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a datastore. + /// + /// + /// Implements datastore GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 datastoreName, 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 (datastoreName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "datastoreName"); + } + 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("datastoreName", datastoreName); + 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.ConnectedVMwarevSphere/datastores/{datastoreName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{datastoreName}", System.Uri.EscapeDataString(datastoreName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a datastore. + /// + /// + /// API to update certain properties of the datastore resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Resource tags. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string datastoreName, 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 (datastoreName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "datastoreName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + ResourcePatch body = default(ResourcePatch); + if (tags != null) + { + body = new ResourcePatch(); + body.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("datastoreName", datastoreName); + tracingParameters.Add("body", body); + 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.ConnectedVMwarevSphere/datastores/{datastoreName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{datastoreName}", System.Uri.EscapeDataString(datastoreName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string datastoreName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, datastoreName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/datastores").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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string datastoreName, Datastore body = default(Datastore), 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 (datastoreName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "datastoreName"); + } + 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("datastoreName", datastoreName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{datastoreName}", System.Uri.EscapeDataString(datastoreName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 datastoreName, bool? force = default(bool?), 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 (datastoreName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "datastoreName"); + } + 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("datastoreName", datastoreName); + tracingParameters.Add("force", force); + 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.ConnectedVMwarevSphere/datastores/{datastoreName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{datastoreName}", System.Uri.EscapeDataString(datastoreName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/DatastoresOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/DatastoresOperationsExtensions.cs new file mode 100644 index 000000000000..c048eee587db --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/DatastoresOperationsExtensions.cs @@ -0,0 +1,481 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 DatastoresOperations. + /// + public static partial class DatastoresOperationsExtensions + { + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + public static Datastore Create(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, Datastore body = default(Datastore)) + { + return operations.CreateAsync(resourceGroupName, datastoreName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, Datastore body = default(Datastore), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, datastoreName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a datastore. + /// + /// + /// Implements datastore GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + public static Datastore Get(this IDatastoresOperations operations, string resourceGroupName, string datastoreName) + { + return operations.GetAsync(resourceGroupName, datastoreName).GetAwaiter().GetResult(); + } + + /// + /// Gets a datastore. + /// + /// + /// Implements datastore GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, datastoreName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a datastore. + /// + /// + /// API to update certain properties of the datastore resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Resource tags. + /// + public static Datastore Update(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, datastoreName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates a datastore. + /// + /// + /// API to update certain properties of the datastore resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Resource tags. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, datastoreName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, datastoreName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, datastoreName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IDatastoresOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDatastoresOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IDatastoresOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IDatastoresOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + public static Datastore BeginCreate(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, Datastore body = default(Datastore)) + { + return operations.BeginCreateAsync(resourceGroupName, datastoreName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, Datastore body = default(Datastore), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, datastoreName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, datastoreName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IDatastoresOperations operations, string resourceGroupName, string datastoreName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, datastoreName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IDatastoresOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IDatastoresOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in 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 IDatastoresOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IDatastoresOperations 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/GuestAgentsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/GuestAgentsOperations.cs new file mode 100644 index 000000000000..2a77128fb3aa --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/GuestAgentsOperations.cs @@ -0,0 +1,1094 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// GuestAgentsOperations operations. + /// + internal partial class GuestAgentsOperations : IServiceOperations, IGuestAgentsOperations + { + /// + /// Initializes a new instance of the GuestAgentsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GuestAgentsOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, name, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets GuestAgent. + /// + /// + /// Implements GuestAgent GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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, string name, 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 (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + 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("name", name); + 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}").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)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineName, name, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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>> ListByVmWithHttpMessagesAsync(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, "ListByVm", 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents").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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent), 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 (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + 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("name", name); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}").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)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// 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 virtualMachineName, string name, 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 (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + 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("name", name); + 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}").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)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// 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>> ListByVmNextWithHttpMessagesAsync(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, "ListByVmNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/GuestAgentsOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/GuestAgentsOperationsExtensions.cs new file mode 100644 index 000000000000..d451c5a2aeed --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/GuestAgentsOperationsExtensions.cs @@ -0,0 +1,377 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GuestAgentsOperations. + /// + public static partial class GuestAgentsOperationsExtensions + { + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + public static GuestAgent Create(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent)) + { + return operations.CreateAsync(resourceGroupName, virtualMachineName, name, body).GetAwaiter().GetResult(); + } + + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, name, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets GuestAgent. + /// + /// + /// Implements GuestAgent GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + public static GuestAgent Get(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name) + { + return operations.GetAsync(resourceGroupName, virtualMachineName, name).GetAwaiter().GetResult(); + } + + /// + /// Gets GuestAgent. + /// + /// + /// Implements GuestAgent GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualMachineName, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + public static void Delete(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name) + { + operations.DeleteAsync(resourceGroupName, virtualMachineName, name).GetAwaiter().GetResult(); + } + + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineName, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + public static IPage ListByVm(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName) + { + return operations.ListByVmAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByVmAsync(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByVmWithHttpMessagesAsync(resourceGroupName, virtualMachineName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + public static GuestAgent BeginCreate(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent)) + { + return operations.BeginCreateAsync(resourceGroupName, virtualMachineName, name, body).GetAwaiter().GetResult(); + } + + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, name, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + public static void BeginDelete(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name) + { + operations.BeginDeleteAsync(resourceGroupName, virtualMachineName, name).GetAwaiter().GetResult(); + } + + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IGuestAgentsOperations operations, string resourceGroupName, string virtualMachineName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineName, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByVmNext(this IGuestAgentsOperations operations, string nextPageLink) + { + return operations.ListByVmNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByVmNextAsync(this IGuestAgentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByVmNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HostsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HostsOperations.cs new file mode 100644 index 000000000000..b063ddf8aa64 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HostsOperations.cs @@ -0,0 +1,1620 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// HostsOperations operations. + /// + internal partial class HostsOperations : IServiceOperations, IHostsOperations + { + /// + /// Initializes a new instance of the HostsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal HostsOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string hostName, Host body = default(Host), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, hostName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a host. + /// + /// + /// Implements host GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 hostName, 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 (hostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "hostName"); + } + 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("hostName", hostName); + 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.ConnectedVMwarevSphere/hosts/{hostName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{hostName}", System.Uri.EscapeDataString(hostName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a host. + /// + /// + /// API to update certain properties of the host resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Resource tags. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string hostName, 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 (hostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "hostName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + ResourcePatch body = default(ResourcePatch); + if (tags != null) + { + body = new ResourcePatch(); + body.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("hostName", hostName); + tracingParameters.Add("body", body); + 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.ConnectedVMwarevSphere/hosts/{hostName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{hostName}", System.Uri.EscapeDataString(hostName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string hostName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, hostName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/hosts").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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string hostName, Host body = default(Host), 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 (hostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "hostName"); + } + 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("hostName", hostName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{hostName}", System.Uri.EscapeDataString(hostName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 hostName, bool? force = default(bool?), 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 (hostName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "hostName"); + } + 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("hostName", hostName); + tracingParameters.Add("force", force); + 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.ConnectedVMwarevSphere/hosts/{hostName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{hostName}", System.Uri.EscapeDataString(hostName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HostsOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HostsOperationsExtensions.cs new file mode 100644 index 000000000000..6674bf79a9c1 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HostsOperationsExtensions.cs @@ -0,0 +1,481 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 HostsOperations. + /// + public static partial class HostsOperationsExtensions + { + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + public static Host Create(this IHostsOperations operations, string resourceGroupName, string hostName, Host body = default(Host)) + { + return operations.CreateAsync(resourceGroupName, hostName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IHostsOperations operations, string resourceGroupName, string hostName, Host body = default(Host), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, hostName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a host. + /// + /// + /// Implements host GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + public static Host Get(this IHostsOperations operations, string resourceGroupName, string hostName) + { + return operations.GetAsync(resourceGroupName, hostName).GetAwaiter().GetResult(); + } + + /// + /// Gets a host. + /// + /// + /// Implements host GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IHostsOperations operations, string resourceGroupName, string hostName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, hostName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a host. + /// + /// + /// API to update certain properties of the host resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Resource tags. + /// + public static Host Update(this IHostsOperations operations, string resourceGroupName, string hostName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, hostName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates a host. + /// + /// + /// API to update certain properties of the host resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Resource tags. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IHostsOperations operations, string resourceGroupName, string hostName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, hostName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IHostsOperations operations, string resourceGroupName, string hostName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, hostName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IHostsOperations operations, string resourceGroupName, string hostName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, hostName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IHostsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IHostsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IHostsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IHostsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + public static Host BeginCreate(this IHostsOperations operations, string resourceGroupName, string hostName, Host body = default(Host)) + { + return operations.BeginCreateAsync(resourceGroupName, hostName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IHostsOperations operations, string resourceGroupName, string hostName, Host body = default(Host), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, hostName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IHostsOperations operations, string resourceGroupName, string hostName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, hostName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IHostsOperations operations, string resourceGroupName, string hostName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, hostName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IHostsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IHostsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in 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 IHostsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IHostsOperations 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HybridIdentityMetadataOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HybridIdentityMetadataOperations.cs new file mode 100644 index 000000000000..405c3f2ad18c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HybridIdentityMetadataOperations.cs @@ -0,0 +1,1017 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// HybridIdentityMetadataOperations operations. + /// + internal partial class HybridIdentityMetadataOperations : IServiceOperations, IHybridIdentityMetadataOperations + { + /// + /// Initializes a new instance of the HybridIdentityMetadataOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal HybridIdentityMetadataOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements HybridIdentityMetadata PUT method. + /// + /// + /// Create Or Update HybridIdentityMetadata. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the hybridIdentityMetadata. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, string metadataName, HybridIdentityMetadata body = default(HybridIdentityMetadata), 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 (metadataName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "metadataName"); + } + 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("metadataName", metadataName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Create", 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}").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)); + _url = _url.Replace("{metadataName}", System.Uri.EscapeDataString(metadataName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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, string metadataName, 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 (metadataName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "metadataName"); + } + 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("metadataName", metadataName); + 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}").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)); + _url = _url.Replace("{metadataName}", System.Uri.EscapeDataString(metadataName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + /// + /// 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 virtualMachineName, string metadataName, 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 (metadataName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "metadataName"); + } + 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("metadataName", metadataName); + 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}").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)); + _url = _url.Replace("{metadataName}", System.Uri.EscapeDataString(metadataName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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>> ListByVmWithHttpMessagesAsync(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, "ListByVm", 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata").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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// 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>> ListByVmNextWithHttpMessagesAsync(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, "ListByVmNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HybridIdentityMetadataOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HybridIdentityMetadataOperationsExtensions.cs new file mode 100644 index 000000000000..065afcd97780 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/HybridIdentityMetadataOperationsExtensions.cs @@ -0,0 +1,270 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for HybridIdentityMetadataOperations. + /// + public static partial class HybridIdentityMetadataOperationsExtensions + { + /// + /// Implements HybridIdentityMetadata PUT method. + /// + /// + /// Create Or Update HybridIdentityMetadata. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the hybridIdentityMetadata. + /// + /// + /// Request payload. + /// + public static HybridIdentityMetadata Create(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName, string metadataName, HybridIdentityMetadata body = default(HybridIdentityMetadata)) + { + return operations.CreateAsync(resourceGroupName, virtualMachineName, metadataName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements HybridIdentityMetadata PUT method. + /// + /// + /// Create Or Update HybridIdentityMetadata. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the hybridIdentityMetadata. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName, string metadataName, HybridIdentityMetadata body = default(HybridIdentityMetadata), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, metadataName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + public static HybridIdentityMetadata Get(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName, string metadataName) + { + return operations.GetAsync(resourceGroupName, virtualMachineName, metadataName).GetAwaiter().GetResult(); + } + + /// + /// Gets HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName, string metadataName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualMachineName, metadataName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + public static void Delete(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName, string metadataName) + { + operations.DeleteAsync(resourceGroupName, virtualMachineName, metadataName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName, string metadataName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineName, metadataName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + public static IPage ListByVm(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName) + { + return operations.ListByVmAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByVmAsync(this IHybridIdentityMetadataOperations operations, string resourceGroupName, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByVmWithHttpMessagesAsync(resourceGroupName, virtualMachineName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByVmNext(this IHybridIdentityMetadataOperations operations, string nextPageLink) + { + return operations.ListByVmNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByVmNextAsync(this IHybridIdentityMetadataOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByVmNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IAzureArcVMwareManagementServiceAPIClient.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IAzureArcVMwareManagementServiceAPIClient.cs new file mode 100644 index 000000000000..5eb98992bab6 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IAzureArcVMwareManagementServiceAPIClient.cs @@ -0,0 +1,138 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Self service experience for VMware. + /// + public partial interface IAzureArcVMwareManagementServiceAPIClient : 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 IResourcePoolsOperations. + /// + IResourcePoolsOperations ResourcePools { get; } + + /// + /// Gets the IClustersOperations. + /// + IClustersOperations Clusters { get; } + + /// + /// Gets the IHostsOperations. + /// + IHostsOperations Hosts { get; } + + /// + /// Gets the IDatastoresOperations. + /// + IDatastoresOperations Datastores { get; } + + /// + /// Gets the IVCentersOperations. + /// + IVCentersOperations VCenters { get; } + + /// + /// Gets the IVirtualMachinesOperations. + /// + IVirtualMachinesOperations VirtualMachines { get; } + + /// + /// Gets the IVirtualMachineTemplatesOperations. + /// + IVirtualMachineTemplatesOperations VirtualMachineTemplates { get; } + + /// + /// Gets the IVirtualNetworksOperations. + /// + IVirtualNetworksOperations VirtualNetworks { get; } + + /// + /// Gets the IInventoryItemsOperations. + /// + IInventoryItemsOperations InventoryItems { get; } + + /// + /// Gets the IHybridIdentityMetadataOperations. + /// + IHybridIdentityMetadataOperations HybridIdentityMetadata { get; } + + /// + /// Gets the IMachineExtensionsOperations. + /// + IMachineExtensionsOperations MachineExtensions { get; } + + /// + /// Gets the IGuestAgentsOperations. + /// + IGuestAgentsOperations GuestAgents { get; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IClustersOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IClustersOperations.cs new file mode 100644 index 000000000000..0c01cc061e65 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IClustersOperations.cs @@ -0,0 +1,301 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ClustersOperations operations. + /// + public partial interface IClustersOperations + { + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster body = default(Cluster), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a cluster. + /// + /// + /// Implements cluster GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// 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 clusterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a cluster. + /// + /// + /// API to update certain properties of the cluster resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Resource tags. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string clusterName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 clusterName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements cluster PUT method. + /// + /// + /// Create Or Update cluster. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string clusterName, Cluster body = default(Cluster), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an cluster. + /// + /// + /// Implements cluster DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the cluster. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 clusterName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET clusters in a subscription. + /// + /// + /// List of clusters in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET clusters in a resource group. + /// + /// + /// List of clusters in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IDatastoresOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IDatastoresOperations.cs new file mode 100644 index 000000000000..51643c10f415 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IDatastoresOperations.cs @@ -0,0 +1,301 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DatastoresOperations operations. + /// + public partial interface IDatastoresOperations + { + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string datastoreName, Datastore body = default(Datastore), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a datastore. + /// + /// + /// Implements datastore GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// 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 datastoreName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a datastore. + /// + /// + /// API to update certain properties of the datastore resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Resource tags. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string datastoreName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 datastoreName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements datastore PUT method. + /// + /// + /// Create Or Update datastore. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string datastoreName, Datastore body = default(Datastore), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an datastore. + /// + /// + /// Implements datastore DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the datastore. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 datastoreName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET datastores in a subscription. + /// + /// + /// List of datastores in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET datastores in a resource group. + /// + /// + /// List of datastores in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IGuestAgentsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IGuestAgentsOperations.cs new file mode 100644 index 000000000000..f16a4fedae65 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IGuestAgentsOperations.cs @@ -0,0 +1,235 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GuestAgentsOperations operations. + /// + public partial interface IGuestAgentsOperations + { + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets GuestAgent. + /// + /// + /// Implements GuestAgent GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// 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, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// 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 virtualMachineName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// 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>> ListByVmWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GuestAgent PUT method. + /// + /// + /// Create Or Update GuestAgent. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the guestAgents. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, string name, GuestAgent body = default(GuestAgent), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an GuestAgent. + /// + /// + /// Implements GuestAgent DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the GuestAgent. + /// + /// + /// 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 virtualMachineName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET GuestAgent in a vm. + /// + /// + /// Returns the list of GuestAgent of the given vm. + /// + /// + /// 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>> ListByVmNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IHostsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IHostsOperations.cs new file mode 100644 index 000000000000..474e278244fa --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IHostsOperations.cs @@ -0,0 +1,301 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// HostsOperations operations. + /// + public partial interface IHostsOperations + { + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string hostName, Host body = default(Host), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a host. + /// + /// + /// Implements host GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// 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 hostName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a host. + /// + /// + /// API to update certain properties of the host resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Resource tags. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string hostName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 hostName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements host PUT method. + /// + /// + /// Create Or Update host. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string hostName, Host body = default(Host), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an host. + /// + /// + /// Implements host DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the host. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 hostName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET hosts in a subscription. + /// + /// + /// List of hosts in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET hosts in a resource group. + /// + /// + /// List of hosts in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IHybridIdentityMetadataOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IHybridIdentityMetadataOperations.cs new file mode 100644 index 000000000000..735b05b48977 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IHybridIdentityMetadataOperations.cs @@ -0,0 +1,173 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// HybridIdentityMetadataOperations operations. + /// + public partial interface IHybridIdentityMetadataOperations + { + /// + /// Implements HybridIdentityMetadata PUT method. + /// + /// + /// Create Or Update HybridIdentityMetadata. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the hybridIdentityMetadata. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, string metadataName, HybridIdentityMetadata body = default(HybridIdentityMetadata), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + /// + /// 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, string metadataName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an HybridIdentityMetadata. + /// + /// + /// Implements HybridIdentityMetadata DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// Name of the HybridIdentityMetadata. + /// + /// + /// 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 virtualMachineName, string metadataName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vm. + /// + /// + /// 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>> ListByVmWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET HybridIdentityMetadata in a vm. + /// + /// + /// Returns the list of HybridIdentityMetadata of the given vm. + /// + /// + /// 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>> ListByVmNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IInventoryItemsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IInventoryItemsOperations.cs new file mode 100644 index 000000000000..34335765fc8c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IInventoryItemsOperations.cs @@ -0,0 +1,173 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// InventoryItemsOperations operations. + /// + public partial interface IInventoryItemsOperations + { + /// + /// Implements InventoryItem PUT method. + /// + /// + /// Create Or Update InventoryItem. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, string inventoryItemName, InventoryItem body = default(InventoryItem), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets InventoryItem. + /// + /// + /// Implements InventoryItem GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// 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 vcenterName, string inventoryItemName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an inventoryItem. + /// + /// + /// Implements inventoryItem DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// 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 vcenterName, string inventoryItemName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// 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>> ListByVCenterWithHttpMessagesAsync(string resourceGroupName, string vcenterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// 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>> ListByVCenterNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IMachineExtensionsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IMachineExtensionsOperations.cs new file mode 100644 index 000000000000..e2cc7ac73e6e --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IMachineExtensionsOperations.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.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MachineExtensionsOperations operations. + /// + public partial interface IMachineExtensionsOperations + { + /// + /// The operation to create or update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or + /// updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or + /// updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to delete the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + /// + /// 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 name, string extensionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to get the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The name of the machine extension. + /// + /// + /// 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 name, string extensionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The expand expression to apply on the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string name, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to create or update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or + /// updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or + /// updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to delete the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + /// + /// 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 name, string extensionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IOperations.cs new file mode 100644 index 000000000000..08e705164f54 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IOperations.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 + { + /// + /// Returns list of all 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)); + /// + /// Returns list of all 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IResourcePoolsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IResourcePoolsOperations.cs new file mode 100644 index 000000000000..47b527c7a538 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IResourcePoolsOperations.cs @@ -0,0 +1,301 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a resourcePool. + /// + /// + /// Implements resourcePool GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// 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 resourcePoolName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a resourcePool. + /// + /// + /// API to update certain properties of the resourcePool resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Resource tags. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string resourcePoolName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 resourcePoolName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 resourcePoolName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVCentersOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVCentersOperations.cs new file mode 100644 index 000000000000..31301f1bac8a --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVCentersOperations.cs @@ -0,0 +1,301 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// VCentersOperations operations. + /// + public partial interface IVCentersOperations + { + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, VCenter body = default(VCenter), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a vCenter. + /// + /// + /// Implements vCenter GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// 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 vcenterName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a vCenter. + /// + /// + /// API to update certain properties of the vCenter resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Resource tags. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 vcenterName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, VCenter body = default(VCenter), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 vcenterName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualMachineTemplatesOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualMachineTemplatesOperations.cs new file mode 100644 index 000000000000..9cafdcafc7fc --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualMachineTemplatesOperations.cs @@ -0,0 +1,302 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a virtual machine template. + /// + /// + /// Implements virtual machine template GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// 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 virtualMachineTemplateName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a virtual machine template. + /// + /// + /// API to update certain properties of the virtual machine template + /// resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Resource tags. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineTemplateName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualMachineTemplateName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualMachineTemplateName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualMachinesOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualMachinesOperations.cs new file mode 100644 index 000000000000..659714b58300 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualMachinesOperations.cs @@ -0,0 +1,492 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 virtual machine PUT method. + /// + /// + /// Create Or Update virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a virtual machine. + /// + /// + /// Implements virtual machine GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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)); + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + /// + /// 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, VirtualMachineUpdate body = default(VirtualMachineUpdate), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualMachineName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown + /// whereas false indicates otherwise. Defaults to false. + /// + /// + /// 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 virtualMachineName, bool? skipShutdown = false, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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 virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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 RestartWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual machine PUT method. + /// + /// + /// Create Or Update virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + /// + /// 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, VirtualMachineUpdate body = default(VirtualMachineUpdate), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualMachineName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown + /// whereas false indicates otherwise. Defaults to false. + /// + /// + /// 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 virtualMachineName, bool? skipShutdown = false, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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 virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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 BeginRestartWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualNetworksOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualNetworksOperations.cs new file mode 100644 index 000000000000..3e86c2fd1996 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/IVirtualNetworksOperations.cs @@ -0,0 +1,301 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a virtual network. + /// + /// + /// Implements virtual network GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// 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 virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates a virtual network. + /// + /// + /// API to update certain properties of the virtual network resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Resource tags. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualNetworkName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualNetworkName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/InventoryItemsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/InventoryItemsOperations.cs new file mode 100644 index 000000000000..b8e0767ba16c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/InventoryItemsOperations.cs @@ -0,0 +1,1017 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// InventoryItemsOperations operations. + /// + internal partial class InventoryItemsOperations : IServiceOperations, IInventoryItemsOperations + { + /// + /// Initializes a new instance of the InventoryItemsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal InventoryItemsOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements InventoryItem PUT method. + /// + /// + /// Create Or Update InventoryItem. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> CreateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, string inventoryItemName, InventoryItem body = default(InventoryItem), 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + if (inventoryItemName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "inventoryItemName"); + } + 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("vcenterName", vcenterName); + tracingParameters.Add("inventoryItemName", inventoryItemName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Create", 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.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + _url = _url.Replace("{inventoryItemName}", System.Uri.EscapeDataString(inventoryItemName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets InventoryItem. + /// + /// + /// Implements InventoryItem GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 vcenterName, string inventoryItemName, 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + if (inventoryItemName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "inventoryItemName"); + } + 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("vcenterName", vcenterName); + tracingParameters.Add("inventoryItemName", inventoryItemName); + 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.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + _url = _url.Replace("{inventoryItemName}", System.Uri.EscapeDataString(inventoryItemName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an inventoryItem. + /// + /// + /// Implements inventoryItem DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// 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 vcenterName, string inventoryItemName, 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + if (inventoryItemName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "inventoryItemName"); + } + 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("vcenterName", vcenterName); + tracingParameters.Add("inventoryItemName", inventoryItemName); + 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.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + _url = _url.Replace("{inventoryItemName}", System.Uri.EscapeDataString(inventoryItemName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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>> ListByVCenterWithHttpMessagesAsync(string resourceGroupName, string vcenterName, 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + 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("vcenterName", vcenterName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByVCenter", 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.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// 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>> ListByVCenterNextWithHttpMessagesAsync(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, "ListByVCenterNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/InventoryItemsOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/InventoryItemsOperationsExtensions.cs new file mode 100644 index 000000000000..efd3e01b24a6 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/InventoryItemsOperationsExtensions.cs @@ -0,0 +1,270 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for InventoryItemsOperations. + /// + public static partial class InventoryItemsOperationsExtensions + { + /// + /// Implements InventoryItem PUT method. + /// + /// + /// Create Or Update InventoryItem. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// Request payload. + /// + public static InventoryItem Create(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName, string inventoryItemName, InventoryItem body = default(InventoryItem)) + { + return operations.CreateAsync(resourceGroupName, vcenterName, inventoryItemName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements InventoryItem PUT method. + /// + /// + /// Create Or Update InventoryItem. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName, string inventoryItemName, InventoryItem body = default(InventoryItem), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, vcenterName, inventoryItemName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets InventoryItem. + /// + /// + /// Implements InventoryItem GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + public static InventoryItem Get(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName, string inventoryItemName) + { + return operations.GetAsync(resourceGroupName, vcenterName, inventoryItemName).GetAwaiter().GetResult(); + } + + /// + /// Gets InventoryItem. + /// + /// + /// Implements InventoryItem GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName, string inventoryItemName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, vcenterName, inventoryItemName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an inventoryItem. + /// + /// + /// Implements inventoryItem DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + public static void Delete(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName, string inventoryItemName) + { + operations.DeleteAsync(resourceGroupName, vcenterName, inventoryItemName).GetAwaiter().GetResult(); + } + + /// + /// Deletes an inventoryItem. + /// + /// + /// Implements inventoryItem DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Name of the inventoryItem. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName, string inventoryItemName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, vcenterName, inventoryItemName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + public static IPage ListByVCenter(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName) + { + return operations.ListByVCenterAsync(resourceGroupName, vcenterName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByVCenterAsync(this IInventoryItemsOperations operations, string resourceGroupName, string vcenterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByVCenterWithHttpMessagesAsync(resourceGroupName, vcenterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByVCenterNext(this IInventoryItemsOperations operations, string nextPageLink) + { + return operations.ListByVCenterNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET inventoryItems in a vCenter. + /// + /// + /// Returns the list of inventoryItems of the given vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByVCenterNextAsync(this IInventoryItemsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByVCenterNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/MachineExtensionsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/MachineExtensionsOperations.cs new file mode 100644 index 000000000000..15aba6e39cff --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/MachineExtensionsOperations.cs @@ -0,0 +1,1345 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// MachineExtensionsOperations operations. + /// + internal partial class MachineExtensionsOperations : IServiceOperations, IMachineExtensionsOperations + { + /// + /// Initializes a new instance of the MachineExtensionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MachineExtensionsOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// The operation to create or update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, extensionName, extensionParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// The operation to update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, name, extensionName, extensionParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// The operation to delete the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, name, extensionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// The operation to get the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The name of the machine extension. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 name, string extensionName, 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"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (extensionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "extensionName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + tracingParameters.Add("extensionName", extensionName); + 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.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{extensionName}", System.Uri.EscapeDataString(extensionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The expand expression to apply on the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string name, string expand = 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"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to create or update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters, 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"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (extensionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "extensionName"); + } + if (extensionParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "extensionParameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + tracingParameters.Add("extensionName", extensionName); + tracingParameters.Add("extensionParameters", extensionParameters); + 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.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{extensionName}", System.Uri.EscapeDataString(extensionName)); + 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(extensionParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(extensionParameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to update the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters, 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"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (extensionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "extensionName"); + } + if (extensionParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "extensionParameters"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + tracingParameters.Add("extensionName", extensionName); + tracingParameters.Add("extensionParameters", extensionParameters); + 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.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{extensionName}", System.Uri.EscapeDataString(extensionName)); + 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(extensionParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(extensionParameters, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to delete the extension. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + /// + /// 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 name, string extensionName, 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"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + if (extensionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "extensionName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("name", name); + tracingParameters.Add("extensionName", extensionName); + 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.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + _url = _url.Replace("{extensionName}", System.Uri.EscapeDataString(extensionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/MachineExtensionsOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/MachineExtensionsOperationsExtensions.cs new file mode 100644 index 000000000000..55e9129dc441 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/MachineExtensionsOperationsExtensions.cs @@ -0,0 +1,445 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MachineExtensionsOperations. + /// + public static partial class MachineExtensionsOperationsExtensions + { + /// + /// The operation to create or update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + public static MachineExtension CreateOrUpdate(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, name, extensionName, extensionParameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to create or update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, extensionName, extensionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + public static MachineExtension Update(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters) + { + return operations.UpdateAsync(resourceGroupName, name, extensionName, extensionParameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, name, extensionName, extensionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to delete the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + public static void Delete(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName) + { + operations.DeleteAsync(resourceGroupName, name, extensionName).GetAwaiter().GetResult(); + } + + /// + /// The operation to delete the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, name, extensionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// The operation to get the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The name of the machine extension. + /// + public static MachineExtension Get(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName) + { + return operations.GetAsync(resourceGroupName, name, extensionName).GetAwaiter().GetResult(); + } + + /// + /// The operation to get the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The name of the machine extension. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, name, extensionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The expand expression to apply on the operation. + /// + public static IPage List(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string expand = default(string)) + { + return operations.ListAsync(resourceGroupName, name, expand).GetAwaiter().GetResult(); + } + + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine containing the extension. + /// + /// + /// The expand expression to apply on the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, name, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to create or update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + public static MachineExtension BeginCreateOrUpdate(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, name, extensionName, extensionParameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to create or update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, extensionName, extensionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + public static MachineExtension BeginUpdate(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, name, extensionName, extensionParameters).GetAwaiter().GetResult(); + } + + /// + /// The operation to update the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be created or updated. + /// + /// + /// The name of the machine extension. + /// + /// + /// Parameters supplied to the Create Machine Extension operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtensionUpdate extensionParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, name, extensionName, extensionParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// The operation to delete the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + public static void BeginDelete(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName) + { + operations.BeginDeleteAsync(resourceGroupName, name, extensionName).GetAwaiter().GetResult(); + } + + /// + /// The operation to delete the extension. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The name of the machine where the extension should be deleted. + /// + /// + /// The name of the machine extension. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, name, extensionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IMachineExtensionsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// The operation to get all extensions of a non-Azure machine + /// + /// + /// 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 IMachineExtensionsOperations 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/AzureEntityResource.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/AzureEntityResource.cs new file mode 100644 index 000000000000..e5e887582d47 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/AzureEntityResource.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Entity Resource + /// + /// + /// The resource model definition for an Azure Resource Manager resource + /// with an etag. + /// + public partial class AzureEntityResource : Resource + { + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + public AzureEntityResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureEntityResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource Etag. + public AzureEntityResource(string id = default(string), string name = default(string), string type = default(string), string etag = default(string)) + : base(id, name, type) + { + Etag = etag; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Etag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Cluster.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Cluster.cs new file mode 100644 index 000000000000..84e79351b9b6 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Cluster.cs @@ -0,0 +1,210 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Define the cluster. + /// + [Rest.Serialization.JsonTransformation] + public partial class Cluster : IResource + { + /// + /// Initializes a new instance of the Cluster class. + /// + public Cluster() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Cluster class. + /// + /// Gets or sets the location. + /// Gets or sets a unique identifier for this + /// resource. + /// Gets or sets the ARM Id of the vCenter + /// resource in which this cluster resides. + /// Gets or sets the vCenter MoRef (Managed + /// Object Reference) ID for the cluster. + /// Gets or sets the inventory Item ID + /// for the cluster. + /// Gets or sets the vCenter Managed Object name + /// for the cluster. + /// The resource status information. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// Gets or sets the datastore ARM + /// ids. + /// Gets or sets the network ARM ids. + /// Gets or sets the provisioning + /// state. + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public Cluster(string location, string uuid = default(string), string vCenterId = default(string), string moRefId = default(string), string inventoryItemId = default(string), string moName = default(string), IList statuses = default(IList), string customResourceName = default(string), IList datastoreIds = default(IList), IList networkIds = default(IList), string provisioningState = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string)) + { + Uuid = uuid; + VCenterId = vCenterId; + MoRefId = moRefId; + InventoryItemId = inventoryItemId; + MoName = moName; + Statuses = statuses; + CustomResourceName = customResourceName; + DatastoreIds = datastoreIds; + NetworkIds = networkIds; + ProvisioningState = provisioningState; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets the ARM Id of the vCenter resource in which this + /// cluster resides. + /// + [JsonProperty(PropertyName = "properties.vCenterId")] + public string VCenterId { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID for + /// the cluster. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the inventory Item ID for the cluster. + /// + [JsonProperty(PropertyName = "properties.inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the cluster. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets or sets the datastore ARM ids. + /// + [JsonProperty(PropertyName = "properties.datastoreIds")] + public IList DatastoreIds { get; private set; } + + /// + /// Gets or sets the network ARM ids. + /// + [JsonProperty(PropertyName = "properties.networkIds")] + public IList NetworkIds { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ClusterInventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ClusterInventoryItem.cs new file mode 100644 index 000000000000..2674ce38e414 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ClusterInventoryItem.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The cluster inventory item. + /// + [Newtonsoft.Json.JsonObject("Cluster")] + public partial class ClusterInventoryItem : InventoryItemProperties + { + /// + /// Initializes a new instance of the ClusterInventoryItem class. + /// + public ClusterInventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ClusterInventoryItem class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + public ClusterInventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string)) + : base(managedResourceId, moRefId, moName, provisioningState) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Condition.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Condition.cs new file mode 100644 index 000000000000..e7223480999e --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Condition.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Condition defines an extension to status. + /// + public partial class Condition + { + /// + /// Initializes a new instance of the Condition class. + /// + public Condition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Condition class. + /// + /// Status of the condition. + /// The reason for the condition's status. + /// A human readable message indicating details + /// about the status. + /// Severity with which to treat failures of + /// this type of condition. + public Condition(string status = default(string), string reason = default(string), string message = default(string), string severity = default(string)) + { + Status = status; + Reason = reason; + Message = message; + Severity = severity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets status of the condition. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Gets the reason for the condition's status. + /// + [JsonProperty(PropertyName = "reason")] + public string Reason { get; private set; } + + /// + /// Gets a human readable message indicating details about the status. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets severity with which to treat failures of this type of + /// condition. + /// + [JsonProperty(PropertyName = "severity")] + public string Severity { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/CreatedByType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/CreatedByType.cs new file mode 100644 index 000000000000..653280cdd17f --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/CreatedByType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for CreatedByType. + /// + public static class CreatedByType + { + public const string User = "User"; + public const string Application = "Application"; + public const string ManagedIdentity = "ManagedIdentity"; + public const string Key = "Key"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Datastore.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Datastore.cs new file mode 100644 index 000000000000..9dfed2521b9b --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Datastore.cs @@ -0,0 +1,197 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Define the datastore. + /// + [Rest.Serialization.JsonTransformation] + public partial class Datastore : IResource + { + /// + /// Initializes a new instance of the Datastore class. + /// + public Datastore() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Datastore class. + /// + /// Gets or sets the location. + /// Gets or sets a unique identifier for this + /// resource. + /// Gets or sets the ARM Id of the vCenter + /// resource in which this datastore resides. + /// Gets or sets the vCenter MoRef (Managed + /// Object Reference) ID for the datastore. + /// Gets or sets the inventory Item ID + /// for the datastore. + /// Gets or sets the vCenter Managed Object name + /// for the datastore. + /// The resource status information. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// Provisioning state of the resource. + /// Possible values include: 'Succeeded', 'Failed', 'Canceled', + /// 'Provisioning', 'Updating', 'Deleting', 'Accepted', + /// 'Created' + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public Datastore(string location, string uuid = default(string), string vCenterId = default(string), string moRefId = default(string), string inventoryItemId = default(string), string moName = default(string), IList statuses = default(IList), string customResourceName = default(string), string provisioningState = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string)) + { + Uuid = uuid; + VCenterId = vCenterId; + MoRefId = moRefId; + InventoryItemId = inventoryItemId; + MoName = moName; + Statuses = statuses; + CustomResourceName = customResourceName; + ProvisioningState = provisioningState; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets the ARM Id of the vCenter resource in which this + /// datastore resides. + /// + [JsonProperty(PropertyName = "properties.vCenterId")] + public string VCenterId { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID for + /// the datastore. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the inventory Item ID for the datastore. + /// + [JsonProperty(PropertyName = "properties.inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the datastore. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets provisioning state of the resource. Possible values include: + /// 'Succeeded', 'Failed', 'Canceled', 'Provisioning', 'Updating', + /// 'Deleting', 'Accepted', 'Created' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DatastoreInventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DatastoreInventoryItem.cs new file mode 100644 index 000000000000..8bdaf4325c21 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DatastoreInventoryItem.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The datastore inventory item. + /// + [Newtonsoft.Json.JsonObject("Datastore")] + public partial class DatastoreInventoryItem : InventoryItemProperties + { + /// + /// Initializes a new instance of the DatastoreInventoryItem class. + /// + public DatastoreInventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DatastoreInventoryItem class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + /// Gets or sets Maximum capacity of this + /// datastore, in GBs. + /// Gets or sets Available space of this + /// datastore, in GBs. + public DatastoreInventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string), long? capacityGB = default(long?), long? freeSpaceGB = default(long?)) + : base(managedResourceId, moRefId, moName, provisioningState) + { + CapacityGB = capacityGB; + FreeSpaceGB = freeSpaceGB; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets Maximum capacity of this datastore, in GBs. + /// + [JsonProperty(PropertyName = "capacityGB")] + public long? CapacityGB { get; set; } + + /// + /// Gets or sets Available space of this datastore, in GBs. + /// + [JsonProperty(PropertyName = "freeSpaceGB")] + public long? FreeSpaceGB { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DiskMode.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DiskMode.cs new file mode 100644 index 000000000000..d2b4932bbd9d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DiskMode.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for DiskMode. + /// + public static class DiskMode + { + public const string Persistent = "persistent"; + public const string IndependentPersistent = "independent_persistent"; + public const string IndependentNonpersistent = "independent_nonpersistent"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DiskType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DiskType.cs new file mode 100644 index 000000000000..d8b7b3816e31 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/DiskType.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for DiskType. + /// + public static class DiskType + { + public const string Flat = "flat"; + public const string Pmem = "pmem"; + public const string Rawphysical = "rawphysical"; + public const string Rawvirtual = "rawvirtual"; + public const string Sparse = "sparse"; + public const string Sesparse = "sesparse"; + public const string Unknown = "unknown"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorDefinition.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorDefinition.cs new file mode 100644 index 000000000000..998934fa6d96 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorDefinition.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error definition. + /// + public partial class ErrorDefinition + { + /// + /// Initializes a new instance of the ErrorDefinition class. + /// + public ErrorDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDefinition class. + /// + /// Service specific error code which serves as the + /// substatus for the HTTP error code. + /// Description of the error. + /// Internal error details. + public ErrorDefinition(string code = default(string), string message = default(string), IList details = default(IList)) + { + Code = code; + Message = message; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets service specific error code which serves as the substatus for + /// the HTTP error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets description of the error. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets internal error details. + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorDetail.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorDetail.cs new file mode 100644 index 000000000000..faf4b0442c4b --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorDetail.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error details. + /// + public partial class ErrorDetail + { + /// + /// Initializes a new instance of the ErrorDetail class. + /// + public ErrorDetail() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetail class. + /// + /// The error's code. + /// A human readable error message. + /// Indicates which property in the request is + /// responsible for the error. + /// Additional error details. + public ErrorDetail(string code, string message, string target = default(string), IList details = default(IList)) + { + Code = code; + Message = message; + Target = target; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the error's code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets a human readable error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets indicates which property in the request is responsible + /// for the error. + /// + [JsonProperty(PropertyName = "target")] + public string Target { get; set; } + + /// + /// Gets or sets additional error details. + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorResponse.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..4bb3d5830523 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorResponse.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The error details. + public ErrorResponse(ErrorDefinition error = default(ErrorDefinition)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the error details. + /// + [JsonProperty(PropertyName = "error")] + public ErrorDefinition Error { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorResponseException.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..714ec96a926a --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse + /// information. + /// + public partial class ErrorResponseException : 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 ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ExtendedLocation.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ExtendedLocation.cs new file mode 100644 index 000000000000..9ffe37aba40e --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ExtendedLocation.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The extended location. + /// + public partial class ExtendedLocation + { + /// + /// Initializes a new instance of the ExtendedLocation class. + /// + public ExtendedLocation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExtendedLocation class. + /// + /// The extended location type. + /// The extended location name. + public ExtendedLocation(string type = default(string), string name = default(string)) + { + Type = type; + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the extended location type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the extended location name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/FirmwareType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/FirmwareType.cs new file mode 100644 index 000000000000..399d94fb3fdd --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/FirmwareType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for FirmwareType. + /// + public static class FirmwareType + { + public const string Bios = "bios"; + public const string Efi = "efi"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestAgent.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestAgent.cs new file mode 100644 index 000000000000..83b18340d5fc --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestAgent.cs @@ -0,0 +1,130 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Defines the GuestAgent. + /// + [Rest.Serialization.JsonTransformation] + public partial class GuestAgent : IResource + { + /// + /// Initializes a new instance of the GuestAgent class. + /// + public GuestAgent() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GuestAgent class. + /// + /// Gets or sets a unique identifier for this + /// resource. + /// Username / Password Credentials to + /// provision guest agent. + /// HTTP Proxy configuration for the + /// VM. + /// Gets or sets the guest agent + /// provisioning action. Possible values include: 'install', + /// 'uninstall', 'repair' + /// Gets or sets the guest agent status. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// The resource status information. + /// Gets or sets the provisioning + /// state. + /// The system data. + public GuestAgent(string uuid = default(string), GuestCredential credentials = default(GuestCredential), HttpProxyConfiguration httpProxyConfig = default(HttpProxyConfiguration), string provisioningAction = default(string), string status = default(string), string customResourceName = default(string), IList statuses = default(IList), string provisioningState = default(string), SystemData systemData = default(SystemData)) + { + Uuid = uuid; + Credentials = credentials; + HttpProxyConfig = httpProxyConfig; + ProvisioningAction = provisioningAction; + Status = status; + CustomResourceName = customResourceName; + Statuses = statuses; + ProvisioningState = provisioningState; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets username / Password Credentials to provision guest + /// agent. + /// + [JsonProperty(PropertyName = "properties.credentials")] + public GuestCredential Credentials { get; set; } + + /// + /// Gets or sets HTTP Proxy configuration for the VM. + /// + [JsonProperty(PropertyName = "properties.httpProxyConfig")] + public HttpProxyConfiguration HttpProxyConfig { get; set; } + + /// + /// Gets or sets the guest agent provisioning action. Possible values + /// include: 'install', 'uninstall', 'repair' + /// + [JsonProperty(PropertyName = "properties.provisioningAction")] + public string ProvisioningAction { get; set; } + + /// + /// Gets or sets the guest agent status. + /// + [JsonProperty(PropertyName = "properties.status")] + public string Status { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestAgentProfile.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestAgentProfile.cs new file mode 100644 index 000000000000..8c42d6d80d76 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestAgentProfile.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class GuestAgentProfile + { + /// + /// Initializes a new instance of the GuestAgentProfile class. + /// + public GuestAgentProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GuestAgentProfile class. + /// + /// Specifies the VM's unique SMBIOS ID. + /// The status of the hybrid machine agent. + /// Possible values include: 'Connected', 'Disconnected', + /// 'Error' + /// The time of the last status + /// change. + /// The hybrid machine agent full + /// version. + /// Details about the error state. + public GuestAgentProfile(string vmUuid = default(string), string status = default(string), System.DateTime? lastStatusChange = default(System.DateTime?), string agentVersion = default(string), IList errorDetails = default(IList)) + { + VmUuid = vmUuid; + Status = status; + LastStatusChange = lastStatusChange; + AgentVersion = agentVersion; + ErrorDetails = errorDetails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets specifies the VM's unique SMBIOS ID. + /// + [JsonProperty(PropertyName = "vmUuid")] + public string VmUuid { get; private set; } + + /// + /// Gets the status of the hybrid machine agent. Possible values + /// include: 'Connected', 'Disconnected', 'Error' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Gets the time of the last status change. + /// + [JsonProperty(PropertyName = "lastStatusChange")] + public System.DateTime? LastStatusChange { get; private set; } + + /// + /// Gets the hybrid machine agent full version. + /// + [JsonProperty(PropertyName = "agentVersion")] + public string AgentVersion { get; private set; } + + /// + /// Gets details about the error state. + /// + [JsonProperty(PropertyName = "errorDetails")] + public IList ErrorDetails { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestCredential.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestCredential.cs new file mode 100644 index 000000000000..780e6dbcb07c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/GuestCredential.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Username / Password Credentials to connect to guest. + /// + public partial class GuestCredential + { + /// + /// Initializes a new instance of the GuestCredential class. + /// + public GuestCredential() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GuestCredential class. + /// + /// Gets or sets username to connect with the + /// guest. + /// Gets or sets the password to connect with + /// the guest. + public GuestCredential(string username = default(string), string password = default(string)) + { + Username = username; + Password = password; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets username to connect with the guest. + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + /// + /// Gets or sets the password to connect with the guest. + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HardwareProfile.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HardwareProfile.cs new file mode 100644 index 000000000000..8a566097b53c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HardwareProfile.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class HardwareProfile + { + /// + /// Initializes a new instance of the HardwareProfile class. + /// + public HardwareProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HardwareProfile class. + /// + /// Gets or sets memory size in MBs for the + /// vm. + /// Gets or sets the number of vCPUs for the + /// vm. + /// Gets or sets the number of cores + /// per socket for the vm. Defaults to 1 if unspecified. + /// Gets or sets a value indicating + /// whether virtual processors can be added while this virtual machine + /// is running. + /// Gets or sets a value indicating + /// whether virtual processors can be removed while this virtual + /// machine is running. + /// Gets or sets a value indicating + /// whether memory can be added while this virtual machine is + /// running. + public HardwareProfile(int? memorySizeMB = default(int?), int? numCPUs = default(int?), int? numCoresPerSocket = default(int?), bool? cpuHotAddEnabled = default(bool?), bool? cpuHotRemoveEnabled = default(bool?), bool? memoryHotAddEnabled = default(bool?)) + { + MemorySizeMB = memorySizeMB; + NumCPUs = numCPUs; + NumCoresPerSocket = numCoresPerSocket; + CpuHotAddEnabled = cpuHotAddEnabled; + CpuHotRemoveEnabled = cpuHotRemoveEnabled; + MemoryHotAddEnabled = memoryHotAddEnabled; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets memory size in MBs for the vm. + /// + [JsonProperty(PropertyName = "memorySizeMB")] + public int? MemorySizeMB { get; set; } + + /// + /// Gets or sets the number of vCPUs for the vm. + /// + [JsonProperty(PropertyName = "numCPUs")] + public int? NumCPUs { get; set; } + + /// + /// Gets or sets the number of cores per socket for the vm. Defaults to + /// 1 if unspecified. + /// + [JsonProperty(PropertyName = "numCoresPerSocket")] + public int? NumCoresPerSocket { get; set; } + + /// + /// Gets or sets a value indicating whether virtual processors can be + /// added while this virtual machine is running. + /// + [JsonProperty(PropertyName = "cpuHotAddEnabled")] + public bool? CpuHotAddEnabled { get; private set; } + + /// + /// Gets or sets a value indicating whether virtual processors can be + /// removed while this virtual machine is running. + /// + [JsonProperty(PropertyName = "cpuHotRemoveEnabled")] + public bool? CpuHotRemoveEnabled { get; private set; } + + /// + /// Gets or sets a value indicating whether memory can be added while + /// this virtual machine is running. + /// + [JsonProperty(PropertyName = "memoryHotAddEnabled")] + public bool? MemoryHotAddEnabled { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Host.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Host.cs new file mode 100644 index 000000000000..b89dd86f587d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Host.cs @@ -0,0 +1,193 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Define the host. + /// + [Rest.Serialization.JsonTransformation] + public partial class Host : IResource + { + /// + /// Initializes a new instance of the Host class. + /// + public Host() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Host class. + /// + /// Gets or sets the location. + /// Gets or sets a unique identifier for this + /// resource. + /// Gets or sets the ARM Id of the vCenter + /// resource in which this host resides. + /// Gets or sets the vCenter MoRef (Managed + /// Object Reference) ID for the host. + /// Gets or sets the inventory Item ID + /// for the host. + /// Gets or sets the vCenter Managed Object name + /// for the host. + /// The resource status information. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// Gets or sets the provisioning + /// state. + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public Host(string location, string uuid = default(string), string vCenterId = default(string), string moRefId = default(string), string inventoryItemId = default(string), string moName = default(string), IList statuses = default(IList), string customResourceName = default(string), string provisioningState = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string)) + { + Uuid = uuid; + VCenterId = vCenterId; + MoRefId = moRefId; + InventoryItemId = inventoryItemId; + MoName = moName; + Statuses = statuses; + CustomResourceName = customResourceName; + ProvisioningState = provisioningState; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets the ARM Id of the vCenter resource in which this host + /// resides. + /// + [JsonProperty(PropertyName = "properties.vCenterId")] + public string VCenterId { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID for + /// the host. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the inventory Item ID for the host. + /// + [JsonProperty(PropertyName = "properties.inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the host. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HostInventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HostInventoryItem.cs new file mode 100644 index 000000000000..c7c96f90390d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HostInventoryItem.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The host inventory item. + /// + [Newtonsoft.Json.JsonObject("Host")] + public partial class HostInventoryItem : InventoryItemProperties + { + /// + /// Initializes a new instance of the HostInventoryItem class. + /// + public HostInventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HostInventoryItem class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + /// Parent host inventory resource + /// details. + public HostInventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string), InventoryItemDetails parent = default(InventoryItemDetails)) + : base(managedResourceId, moRefId, moName, provisioningState) + { + Parent = parent; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets parent host inventory resource details. + /// + [JsonProperty(PropertyName = "parent")] + public InventoryItemDetails Parent { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HttpProxyConfiguration.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HttpProxyConfiguration.cs new file mode 100644 index 000000000000..aeb8ebab2970 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HttpProxyConfiguration.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// HTTP Proxy configuration for the VM. + /// + public partial class HttpProxyConfiguration + { + /// + /// Initializes a new instance of the HttpProxyConfiguration class. + /// + public HttpProxyConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HttpProxyConfiguration class. + /// + /// Gets or sets httpsProxy url. + public HttpProxyConfiguration(string httpsProxy = default(string)) + { + HttpsProxy = httpsProxy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets httpsProxy url. + /// + [JsonProperty(PropertyName = "httpsProxy")] + public string HttpsProxy { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HybridIdentityMetadata.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HybridIdentityMetadata.cs new file mode 100644 index 000000000000..f842fa062066 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/HybridIdentityMetadata.cs @@ -0,0 +1,88 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the HybridIdentityMetadata. + /// + [Rest.Serialization.JsonTransformation] + public partial class HybridIdentityMetadata : IResource + { + /// + /// Initializes a new instance of the HybridIdentityMetadata class. + /// + public HybridIdentityMetadata() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HybridIdentityMetadata class. + /// + /// Gets or sets the Vm Id. + /// Gets or sets the Public Key. + /// The identity of the resource. + /// Gets or sets the provisioning + /// state. + /// The system data. + public HybridIdentityMetadata(string vmId = default(string), string publicKey = default(string), Identity identity = default(Identity), string provisioningState = default(string), SystemData systemData = default(SystemData)) + { + VmId = vmId; + PublicKey = publicKey; + Identity = identity; + ProvisioningState = provisioningState; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Vm Id. + /// + [JsonProperty(PropertyName = "properties.vmId")] + public string VmId { get; set; } + + /// + /// Gets or sets the Public Key. + /// + [JsonProperty(PropertyName = "properties.publicKey")] + public string PublicKey { get; set; } + + /// + /// Gets the identity of the resource. + /// + [JsonProperty(PropertyName = "properties.identity")] + public Identity Identity { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/IPAddressAllocationMethod.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/IPAddressAllocationMethod.cs new file mode 100644 index 000000000000..d41816703f30 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/IPAddressAllocationMethod.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for IPAddressAllocationMethod. + /// + public static class IPAddressAllocationMethod + { + public const string Unset = "unset"; + public const string Dynamic = "dynamic"; + public const string Static = "static"; + public const string Linklayer = "linklayer"; + public const string Random = "random"; + public const string Other = "other"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Identity.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Identity.cs new file mode 100644 index 000000000000..4b7565450bdb --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Identity.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Managed service identity. + /// + public partial class Identity + { + /// + /// Initializes a new instance of the Identity class. + /// + public Identity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Identity class. + /// + /// The type of managed service identity. Possible + /// values include: 'None', 'SystemAssigned' + /// The principal id of managed service + /// identity. + /// The tenant of managed service + /// identity. + public Identity(string type, string principalId = default(string), string tenantId = default(string)) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the principal id of managed service identity. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets the tenant of managed service identity. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets or sets the type of managed service identity. Possible values + /// include: 'None', 'SystemAssigned' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/IdentityType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/IdentityType.cs new file mode 100644 index 000000000000..70577af79a23 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/IdentityType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for IdentityType. + /// + public static class IdentityType + { + public const string None = "None"; + public const string SystemAssigned = "SystemAssigned"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItem.cs new file mode 100644 index 000000000000..a7537f501a5a --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItem.cs @@ -0,0 +1,108 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the inventory item. + /// + [Rest.Serialization.JsonTransformation] + public partial class InventoryItem : IResource + { + /// + /// Initializes a new instance of the InventoryItem class. + /// + public InventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the InventoryItem class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + /// The system data. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public InventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string), SystemData systemData = default(SystemData), string kind = default(string)) + { + ManagedResourceId = managedResourceId; + MoRefId = moRefId; + MoName = moName; + ProvisioningState = provisioningState; + SystemData = systemData; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the tracked resource id corresponding to the inventory + /// resource. + /// + [JsonProperty(PropertyName = "properties.managedResourceId")] + public string ManagedResourceId { get; set; } + + /// + /// Gets or sets the MoRef (Managed Object Reference) ID for the + /// inventory item. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the inventory + /// item. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItemDetails.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItemDetails.cs new file mode 100644 index 000000000000..76dc9bc65c99 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItemDetails.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class InventoryItemDetails + { + /// + /// Initializes a new instance of the InventoryItemDetails class. + /// + public InventoryItemDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the InventoryItemDetails class. + /// + /// Gets or sets the inventory Item ID + /// for the resource. + /// Gets or sets the vCenter Managed Object name + /// for the resource. + public InventoryItemDetails(string inventoryItemId = default(string), string moName = default(string)) + { + InventoryItemId = inventoryItemId; + MoName = moName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the inventory Item ID for the resource. + /// + [JsonProperty(PropertyName = "inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the resource. + /// + [JsonProperty(PropertyName = "moName")] + public string MoName { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItemProperties.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItemProperties.cs new file mode 100644 index 000000000000..be3cafb581f4 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryItemProperties.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class InventoryItemProperties + { + /// + /// Initializes a new instance of the InventoryItemProperties class. + /// + public InventoryItemProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the InventoryItemProperties class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + public InventoryItemProperties(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string)) + { + ManagedResourceId = managedResourceId; + MoRefId = moRefId; + MoName = moName; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the tracked resource id corresponding to the inventory + /// resource. + /// + [JsonProperty(PropertyName = "managedResourceId")] + public string ManagedResourceId { get; set; } + + /// + /// Gets or sets the MoRef (Managed Object Reference) ID for the + /// inventory item. + /// + [JsonProperty(PropertyName = "moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the inventory + /// item. + /// + [JsonProperty(PropertyName = "moName")] + public string MoName { get; set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryType.cs new file mode 100644 index 000000000000..4c150bb9fa2c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/InventoryType.cs @@ -0,0 +1,27 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for InventoryType. + /// + public static class InventoryType + { + public const string ResourcePool = "ResourcePool"; + public const string VirtualMachine = "VirtualMachine"; + public const string VirtualMachineTemplate = "VirtualMachineTemplate"; + public const string VirtualNetwork = "VirtualNetwork"; + public const string Cluster = "Cluster"; + public const string Datastore = "Datastore"; + public const string Host = "Host"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtension.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtension.cs new file mode 100644 index 000000000000..af6d0bde37b6 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtension.cs @@ -0,0 +1,189 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Describes a Machine Extension. + /// + [Rest.Serialization.JsonTransformation] + public partial class MachineExtension : IResource + { + /// + /// Initializes a new instance of the MachineExtension class. + /// + public MachineExtension() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MachineExtension class. + /// + /// How the extension handler should be + /// forced to update even if the extension configuration has not + /// changed. + /// The name of the extension handler + /// publisher. + /// Specifies the type of + /// the extension; an example is "CustomScriptExtension". + /// Specifies the version of the + /// script handler. + /// Indicates whether the + /// extension should use a newer minor version if one is available at + /// deployment time. Once deployed, however, the extension will not + /// upgrade minor versions unless redeployed, even with this property + /// set to true. + /// Json formatted public settings for the + /// extension. + /// The extension can contain either + /// protectedSettings or protectedSettingsFromKeyVault or no protected + /// settings at all. + /// The provisioning state, which only + /// appears in the response. + /// The machine extension instance + /// view. + /// Gets or sets the location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + public MachineExtension(string forceUpdateTag = default(string), string publisher = default(string), string machineExtensionPropertiesType = default(string), string typeHandlerVersion = default(string), bool? autoUpgradeMinorVersion = default(bool?), object settings = default(object), object protectedSettings = default(object), string provisioningState = default(string), MachineExtensionPropertiesInstanceView instanceView = default(MachineExtensionPropertiesInstanceView), string location = default(string), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string)) + { + ForceUpdateTag = forceUpdateTag; + Publisher = publisher; + MachineExtensionPropertiesType = machineExtensionPropertiesType; + TypeHandlerVersion = typeHandlerVersion; + AutoUpgradeMinorVersion = autoUpgradeMinorVersion; + Settings = settings; + ProtectedSettings = protectedSettings; + ProvisioningState = provisioningState; + InstanceView = instanceView; + Location = location; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets how the extension handler should be forced to update + /// even if the extension configuration has not changed. + /// + [JsonProperty(PropertyName = "properties.forceUpdateTag")] + public string ForceUpdateTag { get; set; } + + /// + /// Gets or sets the name of the extension handler publisher. + /// + [JsonProperty(PropertyName = "properties.publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets specifies the type of the extension; an example is + /// "CustomScriptExtension". + /// + [JsonProperty(PropertyName = "properties.type")] + public string MachineExtensionPropertiesType { get; set; } + + /// + /// Gets or sets specifies the version of the script handler. + /// + [JsonProperty(PropertyName = "properties.typeHandlerVersion")] + public string TypeHandlerVersion { get; set; } + + /// + /// Gets or sets indicates whether the extension should use a newer + /// minor version if one is available at deployment time. Once + /// deployed, however, the extension will not upgrade minor versions + /// unless redeployed, even with this property set to true. + /// + [JsonProperty(PropertyName = "properties.autoUpgradeMinorVersion")] + public bool? AutoUpgradeMinorVersion { get; set; } + + /// + /// Gets or sets json formatted public settings for the extension. + /// + [JsonProperty(PropertyName = "properties.settings")] + public object Settings { get; set; } + + /// + /// Gets or sets the extension can contain either protectedSettings or + /// protectedSettingsFromKeyVault or no protected settings at all. + /// + [JsonProperty(PropertyName = "properties.protectedSettings")] + public object ProtectedSettings { get; set; } + + /// + /// Gets the provisioning state, which only appears in the response. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the machine extension instance view. + /// + [JsonProperty(PropertyName = "properties.instanceView")] + public MachineExtensionPropertiesInstanceView InstanceView { get; set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionInstanceView.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionInstanceView.cs new file mode 100644 index 000000000000..b9f92516a780 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionInstanceView.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes the Machine Extension Instance View. + /// + public partial class MachineExtensionInstanceView + { + /// + /// Initializes a new instance of the MachineExtensionInstanceView + /// class. + /// + public MachineExtensionInstanceView() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MachineExtensionInstanceView + /// class. + /// + /// The machine extension name. + /// Specifies the type of the extension; an example + /// is "CustomScriptExtension". + /// Specifies the version of the + /// script handler. + /// Instance view status. + public MachineExtensionInstanceView(string name = default(string), string type = default(string), string typeHandlerVersion = default(string), MachineExtensionInstanceViewStatus status = default(MachineExtensionInstanceViewStatus)) + { + Name = name; + Type = type; + TypeHandlerVersion = typeHandlerVersion; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the machine extension name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets specifies the type of the extension; an example is + /// "CustomScriptExtension". + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets specifies the version of the script handler. + /// + [JsonProperty(PropertyName = "typeHandlerVersion")] + public string TypeHandlerVersion { get; private set; } + + /// + /// Gets or sets instance view status. + /// + [JsonProperty(PropertyName = "status")] + public MachineExtensionInstanceViewStatus Status { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionInstanceViewStatus.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionInstanceViewStatus.cs new file mode 100644 index 000000000000..e6b8ea0b03cf --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionInstanceViewStatus.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Instance view status. + /// + public partial class MachineExtensionInstanceViewStatus + { + /// + /// Initializes a new instance of the + /// MachineExtensionInstanceViewStatus class. + /// + public MachineExtensionInstanceViewStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MachineExtensionInstanceViewStatus class. + /// + /// The status code. + /// The level code. Possible values include: + /// 'Info', 'Warning', 'Error' + /// The short localizable label for the + /// status. + /// The detailed status message, including for + /// alerts and error messages. + /// The time of the status. + public MachineExtensionInstanceViewStatus(string code = default(string), string level = default(string), string displayStatus = default(string), string message = default(string), System.DateTime? time = default(System.DateTime?)) + { + Code = code; + Level = level; + DisplayStatus = displayStatus; + Message = message; + Time = time; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the status code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets the level code. Possible values include: 'Info', 'Warning', + /// 'Error' + /// + [JsonProperty(PropertyName = "level")] + public string Level { get; private set; } + + /// + /// Gets the short localizable label for the status. + /// + [JsonProperty(PropertyName = "displayStatus")] + public string DisplayStatus { get; private set; } + + /// + /// Gets the detailed status message, including for alerts and error + /// messages. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets the time of the status. + /// + [JsonProperty(PropertyName = "time")] + public System.DateTime? Time { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionPropertiesInstanceView.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionPropertiesInstanceView.cs new file mode 100644 index 000000000000..311893efe9b4 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionPropertiesInstanceView.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.ConnectedVMwarevSphere.Models +{ + using System.Linq; + + /// + /// The machine extension instance view. + /// + public partial class MachineExtensionPropertiesInstanceView : MachineExtensionInstanceView + { + /// + /// Initializes a new instance of the + /// MachineExtensionPropertiesInstanceView class. + /// + public MachineExtensionPropertiesInstanceView() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MachineExtensionPropertiesInstanceView class. + /// + /// The machine extension name. + /// Specifies the type of the extension; an example + /// is "CustomScriptExtension". + /// Specifies the version of the + /// script handler. + /// Instance view status. + public MachineExtensionPropertiesInstanceView(string name = default(string), string type = default(string), string typeHandlerVersion = default(string), MachineExtensionInstanceViewStatus status = default(MachineExtensionInstanceViewStatus)) + : base(name, type, typeHandlerVersion, status) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionUpdate.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionUpdate.cs new file mode 100644 index 000000000000..bffc5c98f34b --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/MachineExtensionUpdate.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.ConnectedVMwarevSphere.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Describes a Machine Extension Update. + /// + [Rest.Serialization.JsonTransformation] + public partial class MachineExtensionUpdate : ResourcePatch + { + /// + /// Initializes a new instance of the MachineExtensionUpdate class. + /// + public MachineExtensionUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MachineExtensionUpdate class. + /// + /// Resource tags. + /// How the extension handler should be + /// forced to update even if the extension configuration has not + /// changed. + /// The name of the extension handler + /// publisher. + /// Specifies the type of the extension; an example + /// is "CustomScriptExtension". + /// Specifies the version of the + /// script handler. + /// Indicates whether the + /// extension should use a newer minor version if one is available at + /// deployment time. Once deployed, however, the extension will not + /// upgrade minor versions unless redeployed, even with this property + /// set to true. + /// Json formatted public settings for the + /// extension. + /// The extension can contain either + /// protectedSettings or protectedSettingsFromKeyVault or no protected + /// settings at all. + public MachineExtensionUpdate(IDictionary tags = default(IDictionary), string forceUpdateTag = default(string), string publisher = default(string), string type = default(string), string typeHandlerVersion = default(string), bool? autoUpgradeMinorVersion = default(bool?), object settings = default(object), object protectedSettings = default(object)) + : base(tags) + { + ForceUpdateTag = forceUpdateTag; + Publisher = publisher; + Type = type; + TypeHandlerVersion = typeHandlerVersion; + AutoUpgradeMinorVersion = autoUpgradeMinorVersion; + Settings = settings; + ProtectedSettings = protectedSettings; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets how the extension handler should be forced to update + /// even if the extension configuration has not changed. + /// + [JsonProperty(PropertyName = "properties.forceUpdateTag")] + public string ForceUpdateTag { get; set; } + + /// + /// Gets or sets the name of the extension handler publisher. + /// + [JsonProperty(PropertyName = "properties.publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets specifies the type of the extension; an example is + /// "CustomScriptExtension". + /// + [JsonProperty(PropertyName = "properties.type")] + public string Type { get; set; } + + /// + /// Gets or sets specifies the version of the script handler. + /// + [JsonProperty(PropertyName = "properties.typeHandlerVersion")] + public string TypeHandlerVersion { get; set; } + + /// + /// Gets or sets indicates whether the extension should use a newer + /// minor version if one is available at deployment time. Once + /// deployed, however, the extension will not upgrade minor versions + /// unless redeployed, even with this property set to true. + /// + [JsonProperty(PropertyName = "properties.autoUpgradeMinorVersion")] + public bool? AutoUpgradeMinorVersion { get; set; } + + /// + /// Gets or sets json formatted public settings for the extension. + /// + [JsonProperty(PropertyName = "properties.settings")] + public object Settings { get; set; } + + /// + /// Gets or sets the extension can contain either protectedSettings or + /// protectedSettingsFromKeyVault or no protected settings at all. + /// + [JsonProperty(PropertyName = "properties.protectedSettings")] + public object ProtectedSettings { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NICType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NICType.cs new file mode 100644 index 000000000000..3327c969ae87 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NICType.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for NICType. + /// + public static class NICType + { + public const string Vmxnet3 = "vmxnet3"; + public const string Vmxnet2 = "vmxnet2"; + public const string Vmxnet = "vmxnet"; + public const string E1000 = "e1000"; + public const string E1000e = "e1000e"; + public const string Pcnet32 = "pcnet32"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkInterface.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkInterface.cs new file mode 100644 index 000000000000..bfbf08f23d4f --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkInterface.cs @@ -0,0 +1,149 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Network Interface model + /// + public partial class NetworkInterface + { + /// + /// Initializes a new instance of the NetworkInterface class. + /// + public NetworkInterface() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkInterface class. + /// + /// Gets or sets the name of the network + /// interface. + /// Gets or sets the label of the virtual network + /// in vCenter that the nic is connected to. + /// Gets or sets the nic ip + /// addresses. + /// Gets or sets the NIC MAC address. + /// Gets or sets the ARM Id of the network + /// resource to connect the virtual machine. + /// NIC type. Possible values include: 'vmxnet3', + /// 'vmxnet2', 'vmxnet', 'e1000', 'e1000e', 'pcnet32' + /// Gets or sets the power on boot. Possible + /// values include: 'enabled', 'disabled' + /// Gets or sets the vCenter MoRef + /// (Managed Object Reference) ID of the virtual network + /// that the nic is connected to. + /// Gets or sets the name of the virtual + /// network in vCenter that the nic is connected to. + /// Gets or sets the device key value. + /// Gets or sets the ipsettings. + public NetworkInterface(string name = default(string), string label = default(string), IList ipAddresses = default(IList), string macAddress = default(string), string networkId = default(string), string nicType = default(string), string powerOnBoot = default(string), string networkMoRefId = default(string), string networkMoName = default(string), int? deviceKey = default(int?), NicIPSettings ipSettings = default(NicIPSettings)) + { + Name = name; + Label = label; + IpAddresses = ipAddresses; + MacAddress = macAddress; + NetworkId = networkId; + NicType = nicType; + PowerOnBoot = powerOnBoot; + NetworkMoRefId = networkMoRefId; + NetworkMoName = networkMoName; + DeviceKey = deviceKey; + IpSettings = ipSettings; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the network interface. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the label of the virtual network in vCenter that the + /// nic is connected to. + /// + [JsonProperty(PropertyName = "label")] + public string Label { get; private set; } + + /// + /// Gets or sets the nic ip addresses. + /// + [JsonProperty(PropertyName = "ipAddresses")] + public IList IpAddresses { get; private set; } + + /// + /// Gets or sets the NIC MAC address. + /// + [JsonProperty(PropertyName = "macAddress")] + public string MacAddress { get; private set; } + + /// + /// Gets or sets the ARM Id of the network resource to connect the + /// virtual machine. + /// + [JsonProperty(PropertyName = "networkId")] + public string NetworkId { get; set; } + + /// + /// Gets or sets NIC type. Possible values include: 'vmxnet3', + /// 'vmxnet2', 'vmxnet', 'e1000', 'e1000e', 'pcnet32' + /// + [JsonProperty(PropertyName = "nicType")] + public string NicType { get; set; } + + /// + /// Gets or sets the power on boot. Possible values include: 'enabled', + /// 'disabled' + /// + [JsonProperty(PropertyName = "powerOnBoot")] + public string PowerOnBoot { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID of the + /// virtual network + /// that the nic is connected to. + /// + [JsonProperty(PropertyName = "networkMoRefId")] + public string NetworkMoRefId { get; private set; } + + /// + /// Gets or sets the name of the virtual network in vCenter that the + /// nic is connected to. + /// + [JsonProperty(PropertyName = "networkMoName")] + public string NetworkMoName { get; private set; } + + /// + /// Gets or sets the device key value. + /// + [JsonProperty(PropertyName = "deviceKey")] + public int? DeviceKey { get; set; } + + /// + /// Gets or sets the ipsettings. + /// + [JsonProperty(PropertyName = "ipSettings")] + public NicIPSettings IpSettings { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkInterfaceUpdate.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkInterfaceUpdate.cs new file mode 100644 index 000000000000..c1039d36e547 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkInterfaceUpdate.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the network interface update. + /// + public partial class NetworkInterfaceUpdate + { + /// + /// Initializes a new instance of the NetworkInterfaceUpdate class. + /// + public NetworkInterfaceUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkInterfaceUpdate class. + /// + /// Gets or sets the name of the network + /// interface. + /// Gets or sets the ARM Id of the network + /// resource to connect the virtual machine. + /// NIC type. Possible values include: 'vmxnet3', + /// 'vmxnet2', 'vmxnet', 'e1000', 'e1000e', 'pcnet32' + /// Gets or sets the power on boot. Possible + /// values include: 'enabled', 'disabled' + /// Gets or sets the device key value. + public NetworkInterfaceUpdate(string name = default(string), string networkId = default(string), string nicType = default(string), string powerOnBoot = default(string), int? deviceKey = default(int?)) + { + Name = name; + NetworkId = networkId; + NicType = nicType; + PowerOnBoot = powerOnBoot; + DeviceKey = deviceKey; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the network interface. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the ARM Id of the network resource to connect the + /// virtual machine. + /// + [JsonProperty(PropertyName = "networkId")] + public string NetworkId { get; set; } + + /// + /// Gets or sets NIC type. Possible values include: 'vmxnet3', + /// 'vmxnet2', 'vmxnet', 'e1000', 'e1000e', 'pcnet32' + /// + [JsonProperty(PropertyName = "nicType")] + public string NicType { get; set; } + + /// + /// Gets or sets the power on boot. Possible values include: 'enabled', + /// 'disabled' + /// + [JsonProperty(PropertyName = "powerOnBoot")] + public string PowerOnBoot { get; set; } + + /// + /// Gets or sets the device key value. + /// + [JsonProperty(PropertyName = "deviceKey")] + public int? DeviceKey { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkProfile.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkProfile.cs new file mode 100644 index 000000000000..b5c4ecd2867d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkProfile.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class NetworkProfile + { + /// + /// Initializes a new instance of the NetworkProfile class. + /// + public NetworkProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkProfile class. + /// + /// Gets or sets the list of network + /// interfaces associated with the virtual machine. + public NetworkProfile(IList networkInterfaces = default(IList)) + { + NetworkInterfaces = networkInterfaces; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of network interfaces associated with the + /// virtual machine. + /// + [JsonProperty(PropertyName = "networkInterfaces")] + public IList NetworkInterfaces { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkProfileUpdate.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkProfileUpdate.cs new file mode 100644 index 000000000000..1447985f87b2 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NetworkProfileUpdate.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the update resource properties. + /// + public partial class NetworkProfileUpdate + { + /// + /// Initializes a new instance of the NetworkProfileUpdate class. + /// + public NetworkProfileUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkProfileUpdate class. + /// + /// Gets or sets the list of network + /// interfaces associated with the virtual machine. + public NetworkProfileUpdate(IList networkInterfaces = default(IList)) + { + NetworkInterfaces = networkInterfaces; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of network interfaces associated with the + /// virtual machine. + /// + [JsonProperty(PropertyName = "networkInterfaces")] + public IList NetworkInterfaces { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NicIPAddressSettings.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NicIPAddressSettings.cs new file mode 100644 index 000000000000..f1748e0f62f9 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NicIPAddressSettings.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// IP address information for a virtual network adapter reported by the + /// fabric. + /// + public partial class NicIPAddressSettings + { + /// + /// Initializes a new instance of the NicIPAddressSettings class. + /// + public NicIPAddressSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NicIPAddressSettings class. + /// + /// Gets the ip address allocation + /// method. + /// Gets the ip address for the nic. + /// Gets the mask. + public NicIPAddressSettings(string allocationMethod = default(string), string ipAddress = default(string), string subnetMask = default(string)) + { + AllocationMethod = allocationMethod; + IpAddress = ipAddress; + SubnetMask = subnetMask; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the ip address allocation method. + /// + [JsonProperty(PropertyName = "allocationMethod")] + public string AllocationMethod { get; private set; } + + /// + /// Gets the ip address for the nic. + /// + [JsonProperty(PropertyName = "ipAddress")] + public string IpAddress { get; private set; } + + /// + /// Gets the mask. + /// + [JsonProperty(PropertyName = "subnetMask")] + public string SubnetMask { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NicIPSettings.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NicIPSettings.cs new file mode 100644 index 000000000000..73b9d388f1a1 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/NicIPSettings.cs @@ -0,0 +1,119 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the network interface ip settings. + /// + public partial class NicIPSettings + { + /// + /// Initializes a new instance of the NicIPSettings class. + /// + public NicIPSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NicIPSettings class. + /// + /// Gets or sets the nic allocation + /// method. Possible values include: 'unset', 'dynamic', 'static', + /// 'linklayer', 'random', 'other' + /// Gets or sets the dns servers. + /// Gets or sets the gateway. + /// Gets or sets the ip address for the + /// nic. + /// Gets or sets the mask. + /// Gets or sets the primary + /// server. + /// Gets or sets the secondary + /// server. + /// Gets or sets the IP address information + /// being reported for this NIC. This contains the same IPv4 + /// information above plus IPV6 information. + public NicIPSettings(string allocationMethod = default(string), IList dnsServers = default(IList), IList gateway = default(IList), string ipAddress = default(string), string subnetMask = default(string), string primaryWinsServer = default(string), string secondaryWinsServer = default(string), IList ipAddressInfo = default(IList)) + { + AllocationMethod = allocationMethod; + DnsServers = dnsServers; + Gateway = gateway; + IpAddress = ipAddress; + SubnetMask = subnetMask; + PrimaryWinsServer = primaryWinsServer; + SecondaryWinsServer = secondaryWinsServer; + IpAddressInfo = ipAddressInfo; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the nic allocation method. Possible values include: + /// 'unset', 'dynamic', 'static', 'linklayer', 'random', 'other' + /// + [JsonProperty(PropertyName = "allocationMethod")] + public string AllocationMethod { get; set; } + + /// + /// Gets or sets the dns servers. + /// + [JsonProperty(PropertyName = "dnsServers")] + public IList DnsServers { get; set; } + + /// + /// Gets or sets the gateway. + /// + [JsonProperty(PropertyName = "gateway")] + public IList Gateway { get; set; } + + /// + /// Gets or sets the ip address for the nic. + /// + [JsonProperty(PropertyName = "ipAddress")] + public string IpAddress { get; set; } + + /// + /// Gets or sets the mask. + /// + [JsonProperty(PropertyName = "subnetMask")] + public string SubnetMask { get; set; } + + /// + /// Gets or sets the primary server. + /// + [JsonProperty(PropertyName = "primaryWinsServer")] + public string PrimaryWinsServer { get; private set; } + + /// + /// Gets or sets the secondary server. + /// + [JsonProperty(PropertyName = "secondaryWinsServer")] + public string SecondaryWinsServer { get; private set; } + + /// + /// Gets or sets the IP address information being reported for this + /// NIC. This contains the same IPv4 information above plus IPV6 + /// information. + /// + [JsonProperty(PropertyName = "ipAddressInfo")] + public IList IpAddressInfo { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Operation.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..31a8beceed96 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Operation.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Operation provided by provider + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// Name of the operation + /// Indicates whether the operation is data + /// action or not. + /// Properties of the operation + public Operation(string name = default(string), bool? isDataAction = default(bool?), OperationDisplay display = default(OperationDisplay)) + { + Name = name; + IsDataAction = isDataAction; + Display = display; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the operation + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets indicates whether the operation is data action or not. + /// + [JsonProperty(PropertyName = "isDataAction")] + public bool? IsDataAction { get; set; } + + /// + /// Gets or sets properties of the operation + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OperationDisplay.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..21a67e1423d0 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OperationDisplay.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Properties of the operation + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// Provider name + /// Resource name + /// Operation name + /// Description of the operation + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets provider name + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets resource name + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets operation name + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets description of the operation + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OsProfile.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OsProfile.cs new file mode 100644 index 000000000000..1330247ad94a --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OsProfile.cs @@ -0,0 +1,118 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class OsProfile + { + /// + /// Initializes a new instance of the OsProfile class. + /// + public OsProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OsProfile class. + /// + /// Gets or sets computer name. + /// Gets or sets administrator + /// username. + /// Gets or sets administrator + /// password. + /// Gets or sets the type of the os. Possible + /// values include: 'Windows', 'Linux', 'Other' + /// Gets or sets os name. + /// Gets or sets the current running + /// status of VMware Tools running in the guest operating + /// system. + /// Gets or sets the current version + /// status of VMware Tools installed in the guest operating + /// system. + /// Gets or sets the current version of + /// VMware Tools. + public OsProfile(string computerName = default(string), string adminUsername = default(string), string adminPassword = default(string), string osType = default(string), string osName = default(string), string toolsRunningStatus = default(string), string toolsVersionStatus = default(string), string toolsVersion = default(string)) + { + ComputerName = computerName; + AdminUsername = adminUsername; + AdminPassword = adminPassword; + OsType = osType; + OsName = osName; + ToolsRunningStatus = toolsRunningStatus; + ToolsVersionStatus = toolsVersionStatus; + ToolsVersion = toolsVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets computer name. + /// + [JsonProperty(PropertyName = "computerName")] + public string ComputerName { get; set; } + + /// + /// Gets or sets administrator username. + /// + [JsonProperty(PropertyName = "adminUsername")] + public string AdminUsername { get; set; } + + /// + /// Gets or sets administrator password. + /// + [JsonProperty(PropertyName = "adminPassword")] + public string AdminPassword { get; set; } + + /// + /// Gets or sets the type of the os. Possible values include: + /// 'Windows', 'Linux', 'Other' + /// + [JsonProperty(PropertyName = "osType")] + public string OsType { get; set; } + + /// + /// Gets or sets os name. + /// + [JsonProperty(PropertyName = "osName")] + public string OsName { get; private set; } + + /// + /// Gets or sets the current running status of VMware Tools running in + /// the guest operating system. + /// + [JsonProperty(PropertyName = "toolsRunningStatus")] + public string ToolsRunningStatus { get; private set; } + + /// + /// Gets or sets the current version status of VMware Tools installed + /// in the guest operating system. + /// + [JsonProperty(PropertyName = "toolsVersionStatus")] + public string ToolsVersionStatus { get; private set; } + + /// + /// Gets or sets the current version of VMware Tools. + /// + [JsonProperty(PropertyName = "toolsVersion")] + public string ToolsVersion { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OsType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OsType.cs new file mode 100644 index 000000000000..ca41964c02e8 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/OsType.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for OsType. + /// + public static class OsType + { + public const string Windows = "Windows"; + public const string Linux = "Linux"; + public const string Other = "Other"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Page.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..1a4d11a6badb --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/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.ConnectedVMwarevSphere.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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/PlacementProfile.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/PlacementProfile.cs new file mode 100644 index 000000000000..71946a9e06ee --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/PlacementProfile.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class PlacementProfile + { + /// + /// Initializes a new instance of the PlacementProfile class. + /// + public PlacementProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PlacementProfile class. + /// + /// Gets or sets the ARM Id of the + /// resourcePool resource on which this virtual machine will + /// deploy. + /// Gets or sets the ARM Id of the cluster + /// resource on which this virtual machine will deploy. + /// Gets or sets the ARM Id of the host resource + /// on which this virtual machine will deploy. + /// Gets or sets the ARM Id of the datastore + /// resource on which the data for the virtual machine will be + /// kept. + public PlacementProfile(string resourcePoolId = default(string), string clusterId = default(string), string hostId = default(string), string datastoreId = default(string)) + { + ResourcePoolId = resourcePoolId; + ClusterId = clusterId; + HostId = hostId; + DatastoreId = datastoreId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ARM Id of the resourcePool resource on which this + /// virtual machine will deploy. + /// + [JsonProperty(PropertyName = "resourcePoolId")] + public string ResourcePoolId { get; set; } + + /// + /// Gets or sets the ARM Id of the cluster resource on which this + /// virtual machine will deploy. + /// + [JsonProperty(PropertyName = "clusterId")] + public string ClusterId { get; set; } + + /// + /// Gets or sets the ARM Id of the host resource on which this virtual + /// machine will deploy. + /// + [JsonProperty(PropertyName = "hostId")] + public string HostId { get; set; } + + /// + /// Gets or sets the ARM Id of the datastore resource on which the data + /// for the virtual machine will be kept. + /// + [JsonProperty(PropertyName = "datastoreId")] + public string DatastoreId { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/PowerOnBootOption.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/PowerOnBootOption.cs new file mode 100644 index 000000000000..a1aae28a3314 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/PowerOnBootOption.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for PowerOnBootOption. + /// + public static class PowerOnBootOption + { + public const string Enabled = "enabled"; + public const string Disabled = "disabled"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProvisioningAction.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProvisioningAction.cs new file mode 100644 index 000000000000..5c0276a85eef --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProvisioningAction.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for ProvisioningAction. + /// + public static class ProvisioningAction + { + public const string Install = "install"; + public const string Uninstall = "uninstall"; + public const string Repair = "repair"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProvisioningState.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..0c1e40869a8d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for ProvisioningState. + /// + public static class ProvisioningState + { + public const string Succeeded = "Succeeded"; + public const string Failed = "Failed"; + public const string Canceled = "Canceled"; + public const string Provisioning = "Provisioning"; + public const string Updating = "Updating"; + public const string Deleting = "Deleting"; + public const string Accepted = "Accepted"; + public const string Created = "Created"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProxyResource.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProxyResource.cs new file mode 100644 index 000000000000..4fedc0b55b46 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ProxyResource.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.ConnectedVMwarevSphere.Models +{ + using System.Linq; + + /// + /// Proxy Resource + /// + /// + /// The resource model definition for a Azure Resource Manager proxy + /// resource. It will not have tags and a location + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + : base(id, name, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Resource.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Resource.cs new file mode 100644 index 000000000000..2c3667de5cb3 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/Resource.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.ConnectedVMwarevSphere.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Resource + /// + /// + /// Common fields that are returned in the response for all Azure Resource + /// Manager resources + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + public Resource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePatch.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePatch.cs new file mode 100644 index 000000000000..967b5ea8d86d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePatch.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Object containing updates for patch operations. + /// + public partial class ResourcePatch + { + /// + /// Initializes a new instance of the ResourcePatch class. + /// + public ResourcePatch() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcePatch class. + /// + /// Resource tags. + public ResourcePatch(IDictionary tags = default(IDictionary)) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePool.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePool.cs new file mode 100644 index 000000000000..d28e020ac06d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePool.cs @@ -0,0 +1,272 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Define the resourcePool. + /// + [Rest.Serialization.JsonTransformation] + public partial class ResourcePool : IResource + { + /// + /// Initializes a new instance of the ResourcePool class. + /// + public ResourcePool() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcePool class. + /// + /// Gets or sets the location. + /// Gets or sets a unique identifier for this + /// resource. + /// Gets or sets the ARM Id of the vCenter + /// resource in which this resource pool resides. + /// Gets or sets the vCenter MoRef (Managed + /// Object Reference) ID for the resource pool. + /// Gets or sets the inventory Item ID + /// for the resource pool. + /// Gets or sets the vCenter Managed Object name + /// for the resource pool. + /// Gets or sets CPUSharesLevel which + /// specifies the CPU allocation level for this pool. + /// This property is used in relative allocation between resource + /// consumers. + /// Gets or sets CPUReservationMHz + /// which specifies the CPU size in MHz that is guaranteed + /// to be available. + /// Gets or sets CPULimitMHz which specifies + /// a CPU usage limit in MHz. + /// Utilization will not exceed this limit even if there are available + /// resources. + /// Gets or sets CPUSharesLevel which + /// specifies the memory allocation level for this pool. + /// This property is used in relative allocation between resource + /// consumers. + /// Gets or sets MemReservationMB which + /// specifies the guaranteed available memory in + /// megabytes. + /// Gets or sets MemLimitMB specifies a memory + /// usage limit in megabytes. + /// Utilization will not exceed the specified limit even if there are + /// available resources. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// The resource status information. + /// Gets or sets the provisioning + /// state. + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public ResourcePool(string location, string uuid = default(string), string vCenterId = default(string), string moRefId = default(string), string inventoryItemId = default(string), string moName = default(string), string cpuSharesLevel = default(string), long? cpuReservationMHz = default(long?), long? cpuLimitMHz = default(long?), string memSharesLevel = default(string), long? memReservationMB = default(long?), long? memLimitMB = default(long?), string customResourceName = default(string), IList statuses = default(IList), string provisioningState = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string)) + { + Uuid = uuid; + VCenterId = vCenterId; + MoRefId = moRefId; + InventoryItemId = inventoryItemId; + MoName = moName; + CpuSharesLevel = cpuSharesLevel; + CpuReservationMHz = cpuReservationMHz; + CpuLimitMHz = cpuLimitMHz; + MemSharesLevel = memSharesLevel; + MemReservationMB = memReservationMB; + MemLimitMB = memLimitMB; + CustomResourceName = customResourceName; + Statuses = statuses; + ProvisioningState = provisioningState; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets the ARM Id of the vCenter resource in which this + /// resource pool resides. + /// + [JsonProperty(PropertyName = "properties.vCenterId")] + public string VCenterId { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID for + /// the resource pool. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the inventory Item ID for the resource pool. + /// + [JsonProperty(PropertyName = "properties.inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the resource pool. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; private set; } + + /// + /// Gets or sets CPUSharesLevel which specifies the CPU allocation + /// level for this pool. + /// This property is used in relative allocation between resource + /// consumers. + /// + [JsonProperty(PropertyName = "properties.cpuSharesLevel")] + public string CpuSharesLevel { get; private set; } + + /// + /// Gets or sets CPUReservationMHz which specifies the CPU size in MHz + /// that is guaranteed + /// to be available. + /// + [JsonProperty(PropertyName = "properties.cpuReservationMHz")] + public long? CpuReservationMHz { get; private set; } + + /// + /// Gets or sets CPULimitMHz which specifies a CPU usage limit in MHz. + /// Utilization will not exceed this limit even if there are available + /// resources. + /// + [JsonProperty(PropertyName = "properties.cpuLimitMHz")] + public long? CpuLimitMHz { get; private set; } + + /// + /// Gets or sets CPUSharesLevel which specifies the memory allocation + /// level for this pool. + /// This property is used in relative allocation between resource + /// consumers. + /// + [JsonProperty(PropertyName = "properties.memSharesLevel")] + public string MemSharesLevel { get; private set; } + + /// + /// Gets or sets MemReservationMB which specifies the guaranteed + /// available memory in + /// megabytes. + /// + [JsonProperty(PropertyName = "properties.memReservationMB")] + public long? MemReservationMB { get; private set; } + + /// + /// Gets or sets MemLimitMB specifies a memory usage limit in + /// megabytes. + /// Utilization will not exceed the specified limit even if there are + /// available resources. + /// + [JsonProperty(PropertyName = "properties.memLimitMB")] + public long? MemLimitMB { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePoolInventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePoolInventoryItem.cs new file mode 100644 index 000000000000..250497378d22 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourcePoolInventoryItem.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource pool inventory item. + /// + [Newtonsoft.Json.JsonObject("ResourcePool")] + public partial class ResourcePoolInventoryItem : InventoryItemProperties + { + /// + /// Initializes a new instance of the ResourcePoolInventoryItem class. + /// + public ResourcePoolInventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcePoolInventoryItem class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + /// Parent resourcePool inventory resource + /// details. + public ResourcePoolInventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string), InventoryItemDetails parent = default(InventoryItemDetails)) + : base(managedResourceId, moRefId, moName, provisioningState) + { + Parent = parent; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets parent resourcePool inventory resource details. + /// + [JsonProperty(PropertyName = "parent")] + public InventoryItemDetails Parent { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourceStatus.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourceStatus.cs new file mode 100644 index 000000000000..832179489a50 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/ResourceStatus.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource status information. + /// + public partial class ResourceStatus + { + /// + /// Initializes a new instance of the ResourceStatus class. + /// + public ResourceStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceStatus class. + /// + /// The type of the condition. + /// Status of the condition. + /// The reason for the condition's status. + /// A human readable message indicating details + /// about the status. + /// Severity with which to treat failures of + /// this type of condition. + /// The last update time for this + /// condition. + public ResourceStatus(string type = default(string), string status = default(string), string reason = default(string), string message = default(string), string severity = default(string), System.DateTime? lastUpdatedAt = default(System.DateTime?)) + { + Type = type; + Status = status; + Reason = reason; + Message = message; + Severity = severity; + LastUpdatedAt = lastUpdatedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the type of the condition. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets status of the condition. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Gets the reason for the condition's status. + /// + [JsonProperty(PropertyName = "reason")] + public string Reason { get; private set; } + + /// + /// Gets a human readable message indicating details about the status. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets severity with which to treat failures of this type of + /// condition. + /// + [JsonProperty(PropertyName = "severity")] + public string Severity { get; private set; } + + /// + /// Gets the last update time for this condition. + /// + [JsonProperty(PropertyName = "lastUpdatedAt")] + public System.DateTime? LastUpdatedAt { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/SCSIControllerType.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/SCSIControllerType.cs new file mode 100644 index 000000000000..e28a6aff3301 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/SCSIControllerType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for SCSIControllerType. + /// + public static class SCSIControllerType + { + public const string Lsilogic = "lsilogic"; + public const string Buslogic = "buslogic"; + public const string Pvscsi = "pvscsi"; + public const string Lsilogicsas = "lsilogicsas"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StatusLevelTypes.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StatusLevelTypes.cs new file mode 100644 index 000000000000..77444329482d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StatusLevelTypes.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for StatusLevelTypes. + /// + public static class StatusLevelTypes + { + public const string Info = "Info"; + public const string Warning = "Warning"; + public const string Error = "Error"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StatusTypes.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StatusTypes.cs new file mode 100644 index 000000000000..6b6ec3dfe3fa --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StatusTypes.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for StatusTypes. + /// + public static class StatusTypes + { + public const string Connected = "Connected"; + public const string Disconnected = "Disconnected"; + public const string Error = "Error"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StopVirtualMachineOptions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StopVirtualMachineOptions.cs new file mode 100644 index 000000000000..9943eb52c058 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StopVirtualMachineOptions.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the stop action properties. + /// + public partial class StopVirtualMachineOptions + { + /// + /// Initializes a new instance of the StopVirtualMachineOptions class. + /// + public StopVirtualMachineOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StopVirtualMachineOptions class. + /// + /// Gets or sets a value indicating whether + /// to request non-graceful VM shutdown. True value for this flag + /// indicates non-graceful shutdown whereas false indicates otherwise. + /// Defaults to false. + public StopVirtualMachineOptions(bool? skipShutdown = default(bool?)) + { + SkipShutdown = skipShutdown; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown + /// whereas false indicates otherwise. Defaults to false. + /// + [JsonProperty(PropertyName = "skipShutdown")] + public bool? SkipShutdown { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StorageProfile.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StorageProfile.cs new file mode 100644 index 000000000000..e793d815c3f7 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StorageProfile.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the resource properties. + /// + public partial class StorageProfile + { + /// + /// Initializes a new instance of the StorageProfile class. + /// + public StorageProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StorageProfile class. + /// + /// Gets or sets the list of virtual disks + /// associated with the virtual machine. + /// Gets or sets the list of virtual SCSI + /// controllers associated with the virtual machine. + public StorageProfile(IList disks = default(IList), IList scsiControllers = default(IList)) + { + Disks = disks; + ScsiControllers = scsiControllers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of virtual disks associated with the virtual + /// machine. + /// + [JsonProperty(PropertyName = "disks")] + public IList Disks { get; set; } + + /// + /// Gets or sets the list of virtual SCSI controllers associated with + /// the virtual machine. + /// + [JsonProperty(PropertyName = "scsiControllers")] + public IList ScsiControllers { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StorageProfileUpdate.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StorageProfileUpdate.cs new file mode 100644 index 000000000000..795276ff1826 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/StorageProfileUpdate.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the resource update properties. + /// + public partial class StorageProfileUpdate + { + /// + /// Initializes a new instance of the StorageProfileUpdate class. + /// + public StorageProfileUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StorageProfileUpdate class. + /// + /// Gets or sets the list of virtual disks + /// associated with the virtual machine. + public StorageProfileUpdate(IList disks = default(IList)) + { + Disks = disks; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of virtual disks associated with the virtual + /// machine. + /// + [JsonProperty(PropertyName = "disks")] + public IList Disks { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/SystemData.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/SystemData.cs new file mode 100644 index 000000000000..ca50efda7467 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/SystemData.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metadata pertaining to creation and last modification of the resource. + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// The identity that created the + /// resource. + /// The type of identity that created the + /// resource. Possible values include: 'User', 'Application', + /// 'ManagedIdentity', 'Key' + /// The timestamp of resource creation + /// (UTC). + /// The identity that last modified the + /// resource. + /// The type of identity that last + /// modified the resource. Possible values include: 'User', + /// 'Application', 'ManagedIdentity', 'Key' + /// The timestamp of resource last + /// modification (UTC) + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity that created the resource. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC). + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets the identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource last modification (UTC) + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/TrackedResource.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/TrackedResource.cs new file mode 100644 index 000000000000..82ac1ca1c67e --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/TrackedResource.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Tracked Resource + /// + /// + /// The resource model definition for an Azure Resource Manager tracked top + /// level resource which has 'tags' and a 'location' + /// + public partial class TrackedResource : Resource + { + /// + /// Initializes a new instance of the TrackedResource class. + /// + public TrackedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TrackedResource class. + /// + /// The geo-location where the resource + /// lives + /// Fully qualified resource ID for the resource. Ex - + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + /// The name of the resource + /// The type of the resource. E.g. + /// "Microsoft.Compute/virtualMachines" or + /// "Microsoft.Storage/storageAccounts" + /// Resource tags. + public TrackedResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type) + { + Tags = tags; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the geo-location where the resource lives + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VCenter.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VCenter.cs new file mode 100644 index 000000000000..c13c3cde515d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VCenter.cs @@ -0,0 +1,208 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Defines the vCenter. + /// + [Rest.Serialization.JsonTransformation] + public partial class VCenter : IResource + { + /// + /// Initializes a new instance of the VCenter class. + /// + public VCenter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VCenter class. + /// + /// Gets or sets the FQDN/IPAddress of the + /// vCenter. + /// Gets or sets the location. + /// Gets or sets a unique identifier for this + /// resource. + /// Gets or sets the port of the vCenter. + /// Gets or sets the version of the + /// vCenter. + /// Gets or sets the instance UUID of the + /// vCenter. + /// Gets or sets the connection status + /// to the vCenter. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// Username / Password Credentials to + /// connect to vcenter. + /// The resource status information. + /// Gets or sets the provisioning + /// state. + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public VCenter(string fqdn, string location, string uuid = default(string), int? port = default(int?), string version = default(string), string instanceUuid = default(string), string connectionStatus = default(string), string customResourceName = default(string), VICredential credentials = default(VICredential), IList statuses = default(IList), string provisioningState = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string)) + { + Uuid = uuid; + Fqdn = fqdn; + Port = port; + Version = version; + InstanceUuid = instanceUuid; + ConnectionStatus = connectionStatus; + CustomResourceName = customResourceName; + Credentials = credentials; + Statuses = statuses; + ProvisioningState = provisioningState; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets the FQDN/IPAddress of the vCenter. + /// + [JsonProperty(PropertyName = "properties.fqdn")] + public string Fqdn { get; set; } + + /// + /// Gets or sets the port of the vCenter. + /// + [JsonProperty(PropertyName = "properties.port")] + public int? Port { get; set; } + + /// + /// Gets or sets the version of the vCenter. + /// + [JsonProperty(PropertyName = "properties.version")] + public string Version { get; private set; } + + /// + /// Gets or sets the instance UUID of the vCenter. + /// + [JsonProperty(PropertyName = "properties.instanceUuid")] + public string InstanceUuid { get; private set; } + + /// + /// Gets or sets the connection status to the vCenter. + /// + [JsonProperty(PropertyName = "properties.connectionStatus")] + public string ConnectionStatus { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets or sets username / Password Credentials to connect to vcenter. + /// + [JsonProperty(PropertyName = "properties.credentials")] + public VICredential Credentials { get; set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VICredential.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VICredential.cs new file mode 100644 index 000000000000..195344c14acb --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VICredential.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Username / Password Credentials to connect to vcenter. + /// + public partial class VICredential + { + /// + /// Initializes a new instance of the VICredential class. + /// + public VICredential() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VICredential class. + /// + /// Gets or sets username to connect with the + /// vCenter. + /// Gets or sets the password to connect with + /// the vCenter. + public VICredential(string username = default(string), string password = default(string)) + { + Username = username; + Password = password; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets username to connect with the vCenter. + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + /// + /// Gets or sets the password to connect with the vCenter. + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualDisk.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualDisk.cs new file mode 100644 index 000000000000..85f679109814 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualDisk.cs @@ -0,0 +1,133 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + 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. + /// + /// Gets or sets the name of the virtual + /// disk. + /// Gets or sets the label of the virtual disk in + /// vCenter. + /// Gets or sets the disk object id. + /// Gets or sets the disk total size. + /// Gets or sets the device key value. + /// Gets or sets the disk mode. Possible values + /// include: 'persistent', 'independent_persistent', + /// 'independent_nonpersistent' + /// Gets or sets the controller id. + /// Gets or sets the unit number of the disk + /// on the controller. + /// Gets or sets the device name. + /// Gets or sets the disk backing type. Possible + /// values include: 'flat', 'pmem', 'rawphysical', 'rawvirtual', + /// 'sparse', 'sesparse', 'unknown' + public VirtualDisk(string name = default(string), string label = default(string), string diskObjectId = default(string), int? diskSizeGB = default(int?), int? deviceKey = default(int?), string diskMode = default(string), int? controllerKey = default(int?), int? unitNumber = default(int?), string deviceName = default(string), string diskType = default(string)) + { + Name = name; + Label = label; + DiskObjectId = diskObjectId; + DiskSizeGB = diskSizeGB; + DeviceKey = deviceKey; + DiskMode = diskMode; + ControllerKey = controllerKey; + UnitNumber = unitNumber; + DeviceName = deviceName; + DiskType = diskType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the virtual disk. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the label of the virtual disk in vCenter. + /// + [JsonProperty(PropertyName = "label")] + public string Label { get; private set; } + + /// + /// Gets or sets the disk object id. + /// + [JsonProperty(PropertyName = "diskObjectId")] + public string DiskObjectId { get; private set; } + + /// + /// Gets or sets the disk total size. + /// + [JsonProperty(PropertyName = "diskSizeGB")] + public int? DiskSizeGB { get; set; } + + /// + /// Gets or sets the device key value. + /// + [JsonProperty(PropertyName = "deviceKey")] + public int? DeviceKey { get; set; } + + /// + /// Gets or sets the disk mode. Possible values include: 'persistent', + /// 'independent_persistent', 'independent_nonpersistent' + /// + [JsonProperty(PropertyName = "diskMode")] + public string DiskMode { get; set; } + + /// + /// Gets or sets the controller id. + /// + [JsonProperty(PropertyName = "controllerKey")] + public int? ControllerKey { get; set; } + + /// + /// Gets or sets the unit number of the disk on the controller. + /// + [JsonProperty(PropertyName = "unitNumber")] + public int? UnitNumber { get; set; } + + /// + /// Gets or sets the device name. + /// + [JsonProperty(PropertyName = "deviceName")] + public string DeviceName { get; set; } + + /// + /// Gets or sets the disk backing type. Possible values include: + /// 'flat', 'pmem', 'rawphysical', 'rawvirtual', 'sparse', 'sesparse', + /// 'unknown' + /// + [JsonProperty(PropertyName = "diskType")] + public string DiskType { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualDiskUpdate.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualDiskUpdate.cs new file mode 100644 index 000000000000..920ff52169b2 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualDiskUpdate.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines the virtual disk update. + /// + public partial class VirtualDiskUpdate + { + /// + /// Initializes a new instance of the VirtualDiskUpdate class. + /// + public VirtualDiskUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualDiskUpdate class. + /// + /// Gets or sets the name of the virtual + /// disk. + /// Gets or sets the disk total size. + /// Gets or sets the device key value. + /// Gets or sets the disk mode. Possible values + /// include: 'persistent', 'independent_persistent', + /// 'independent_nonpersistent' + /// Gets or sets the controller id. + /// Gets or sets the unit number of the disk + /// on the controller. + /// Gets or sets the device name. + /// Gets or sets the disk backing type. Possible + /// values include: 'flat', 'pmem', 'rawphysical', 'rawvirtual', + /// 'sparse', 'sesparse', 'unknown' + public VirtualDiskUpdate(string name = default(string), int? diskSizeGB = default(int?), int? deviceKey = default(int?), string diskMode = default(string), int? controllerKey = default(int?), int? unitNumber = default(int?), string deviceName = default(string), string diskType = default(string)) + { + Name = name; + DiskSizeGB = diskSizeGB; + DeviceKey = deviceKey; + DiskMode = diskMode; + ControllerKey = controllerKey; + UnitNumber = unitNumber; + DeviceName = deviceName; + DiskType = diskType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the virtual disk. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the disk total size. + /// + [JsonProperty(PropertyName = "diskSizeGB")] + public int? DiskSizeGB { get; set; } + + /// + /// Gets or sets the device key value. + /// + [JsonProperty(PropertyName = "deviceKey")] + public int? DeviceKey { get; set; } + + /// + /// Gets or sets the disk mode. Possible values include: 'persistent', + /// 'independent_persistent', 'independent_nonpersistent' + /// + [JsonProperty(PropertyName = "diskMode")] + public string DiskMode { get; set; } + + /// + /// Gets or sets the controller id. + /// + [JsonProperty(PropertyName = "controllerKey")] + public int? ControllerKey { get; set; } + + /// + /// Gets or sets the unit number of the disk on the controller. + /// + [JsonProperty(PropertyName = "unitNumber")] + public int? UnitNumber { get; set; } + + /// + /// Gets or sets the device name. + /// + [JsonProperty(PropertyName = "deviceName")] + public string DeviceName { get; set; } + + /// + /// Gets or sets the disk backing type. Possible values include: + /// 'flat', 'pmem', 'rawphysical', 'rawvirtual', 'sparse', 'sesparse', + /// 'unknown' + /// + [JsonProperty(PropertyName = "diskType")] + public string DiskType { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachine.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachine.cs new file mode 100644 index 000000000000..c9d6d011abaa --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachine.cs @@ -0,0 +1,327 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Define the virtualMachine. + /// + [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. + /// + /// Gets or sets the location. + /// Gets or sets the ARM Id of the + /// resourcePool resource on which this virtual machine will + /// deploy. + /// Gets or sets the ARM Id of the template + /// resource to deploy the virtual machine. + /// Gets or sets the ARM Id of the vCenter + /// resource in which this resource pool resides. + /// Placement properties. + /// OS properties. + /// Hardware properties. + /// Network properties. + /// Storage properties. + /// Guest agent status + /// properties. + /// Gets or sets the vCenter MoRef (Managed + /// Object Reference) ID for the virtual machine. + /// Gets or sets the inventory Item ID + /// for the virtual machine. + /// Gets or sets the vCenter Managed Object name + /// for the virtual machine. + /// Gets or sets the folder path of the + /// vm. + /// Gets or sets the instance uuid of the + /// vm. + /// Gets or sets the SMBIOS UUID of the + /// vm. + /// Firmware type. Possible values include: + /// 'bios', 'efi' + /// Gets the power state of the virtual + /// machine. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// Gets or sets a unique identifier for this + /// resource. + /// The resource status information. + /// Gets or sets the provisioning + /// state. + /// Gets or sets a unique identifier for the vm + /// resource. + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// The identity of the resource. + public VirtualMachine(string location, string resourcePoolId = default(string), string templateId = default(string), string vCenterId = default(string), PlacementProfile placementProfile = default(PlacementProfile), OsProfile osProfile = default(OsProfile), HardwareProfile hardwareProfile = default(HardwareProfile), NetworkProfile networkProfile = default(NetworkProfile), StorageProfile storageProfile = default(StorageProfile), GuestAgentProfile guestAgentProfile = default(GuestAgentProfile), string moRefId = default(string), string inventoryItemId = default(string), string moName = default(string), string folderPath = default(string), string instanceUuid = default(string), string smbiosUuid = default(string), string firmwareType = default(string), string powerState = default(string), string customResourceName = default(string), string uuid = default(string), IList statuses = default(IList), string provisioningState = default(string), string vmId = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string), Identity identity = default(Identity)) + { + ResourcePoolId = resourcePoolId; + TemplateId = templateId; + VCenterId = vCenterId; + PlacementProfile = placementProfile; + OsProfile = osProfile; + HardwareProfile = hardwareProfile; + NetworkProfile = networkProfile; + StorageProfile = storageProfile; + GuestAgentProfile = guestAgentProfile; + MoRefId = moRefId; + InventoryItemId = inventoryItemId; + MoName = moName; + FolderPath = folderPath; + InstanceUuid = instanceUuid; + SmbiosUuid = smbiosUuid; + FirmwareType = firmwareType; + PowerState = powerState; + CustomResourceName = customResourceName; + Uuid = uuid; + Statuses = statuses; + ProvisioningState = provisioningState; + VmId = vmId; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ARM Id of the resourcePool resource on which this + /// virtual machine will + /// deploy. + /// + [JsonProperty(PropertyName = "properties.resourcePoolId")] + public string ResourcePoolId { get; set; } + + /// + /// Gets or sets the ARM Id of the template resource to deploy the + /// virtual machine. + /// + [JsonProperty(PropertyName = "properties.templateId")] + public string TemplateId { get; set; } + + /// + /// Gets or sets the ARM Id of the vCenter resource in which this + /// resource pool resides. + /// + [JsonProperty(PropertyName = "properties.vCenterId")] + public string VCenterId { get; set; } + + /// + /// Gets or sets placement properties. + /// + [JsonProperty(PropertyName = "properties.placementProfile")] + public PlacementProfile PlacementProfile { get; set; } + + /// + /// Gets or sets OS properties. + /// + [JsonProperty(PropertyName = "properties.osProfile")] + public OsProfile OsProfile { get; set; } + + /// + /// Gets or sets hardware properties. + /// + [JsonProperty(PropertyName = "properties.hardwareProfile")] + public HardwareProfile HardwareProfile { get; set; } + + /// + /// Gets or sets network properties. + /// + [JsonProperty(PropertyName = "properties.networkProfile")] + public NetworkProfile NetworkProfile { get; set; } + + /// + /// Gets or sets storage properties. + /// + [JsonProperty(PropertyName = "properties.storageProfile")] + public StorageProfile StorageProfile { get; set; } + + /// + /// Gets or sets guest agent status properties. + /// + [JsonProperty(PropertyName = "properties.guestAgentProfile")] + public GuestAgentProfile GuestAgentProfile { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID for + /// the virtual machine. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the inventory Item ID for the virtual machine. + /// + [JsonProperty(PropertyName = "properties.inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the virtual + /// machine. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; private set; } + + /// + /// Gets or sets the folder path of the vm. + /// + [JsonProperty(PropertyName = "properties.folderPath")] + public string FolderPath { get; private set; } + + /// + /// Gets or sets the instance uuid of the vm. + /// + [JsonProperty(PropertyName = "properties.instanceUuid")] + public string InstanceUuid { get; private set; } + + /// + /// Gets or sets the SMBIOS UUID of the vm. + /// + [JsonProperty(PropertyName = "properties.smbiosUuid")] + public string SmbiosUuid { get; set; } + + /// + /// Gets or sets firmware type. Possible values include: 'bios', 'efi' + /// + [JsonProperty(PropertyName = "properties.firmwareType")] + public string FirmwareType { get; set; } + + /// + /// Gets the power state of the virtual machine. + /// + [JsonProperty(PropertyName = "properties.powerState")] + public string PowerState { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets a unique identifier for the vm resource. + /// + [JsonProperty(PropertyName = "properties.vmId")] + public string VmId { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets the identity of the resource. + /// + [JsonProperty(PropertyName = "identity")] + public Identity Identity { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineInventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineInventoryItem.cs new file mode 100644 index 000000000000..c4cc1dcde5f7 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineInventoryItem.cs @@ -0,0 +1,168 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The VM inventory item. + /// + [Newtonsoft.Json.JsonObject("VirtualMachine")] + public partial class VirtualMachineInventoryItem : InventoryItemProperties + { + /// + /// Initializes a new instance of the VirtualMachineInventoryItem + /// class. + /// + public VirtualMachineInventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachineInventoryItem + /// class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + /// Gets or sets the type of the os. Possible + /// values include: 'Windows', 'Linux', 'Other' + /// Gets or sets os name. + /// Gets or sets the nic ip + /// addresses. + /// Gets or sets the folder path of the + /// vm. + /// Host inventory resource details. + /// ResourcePool inventory resource + /// details. + /// Gets or sets the instance uuid of the + /// vm. + /// Gets or sets the SMBIOS UUID of the + /// vm. + /// Gets the power state of the virtual + /// machine. + /// Gets or sets the current running + /// status of VMware Tools running in the guest operating + /// system. + /// Gets or sets the current version + /// status of VMware Tools installed in the guest operating + /// system. + /// Gets or sets the current version of + /// VMware Tools. + public VirtualMachineInventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string), string osType = default(string), string osName = default(string), IList ipAddresses = default(IList), string folderPath = default(string), InventoryItemDetails host = default(InventoryItemDetails), InventoryItemDetails resourcePool = default(InventoryItemDetails), string instanceUuid = default(string), string smbiosUuid = default(string), string powerState = default(string), string toolsRunningStatus = default(string), string toolsVersionStatus = default(string), string toolsVersion = default(string)) + : base(managedResourceId, moRefId, moName, provisioningState) + { + OsType = osType; + OsName = osName; + IpAddresses = ipAddresses; + FolderPath = folderPath; + Host = host; + ResourcePool = resourcePool; + InstanceUuid = instanceUuid; + SmbiosUuid = smbiosUuid; + PowerState = powerState; + ToolsRunningStatus = toolsRunningStatus; + ToolsVersionStatus = toolsVersionStatus; + ToolsVersion = toolsVersion; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the os. Possible values include: + /// 'Windows', 'Linux', 'Other' + /// + [JsonProperty(PropertyName = "osType")] + public string OsType { get; set; } + + /// + /// Gets or sets os name. + /// + [JsonProperty(PropertyName = "osName")] + public string OsName { get; set; } + + /// + /// Gets or sets the nic ip addresses. + /// + [JsonProperty(PropertyName = "ipAddresses")] + public IList IpAddresses { get; set; } + + /// + /// Gets or sets the folder path of the vm. + /// + [JsonProperty(PropertyName = "folderPath")] + public string FolderPath { get; set; } + + /// + /// Gets or sets host inventory resource details. + /// + [JsonProperty(PropertyName = "host")] + public InventoryItemDetails Host { get; set; } + + /// + /// Gets or sets resourcePool inventory resource details. + /// + [JsonProperty(PropertyName = "resourcePool")] + public InventoryItemDetails ResourcePool { get; set; } + + /// + /// Gets or sets the instance uuid of the vm. + /// + [JsonProperty(PropertyName = "instanceUuid")] + public string InstanceUuid { get; set; } + + /// + /// Gets or sets the SMBIOS UUID of the vm. + /// + [JsonProperty(PropertyName = "smbiosUuid")] + public string SmbiosUuid { get; set; } + + /// + /// Gets the power state of the virtual machine. + /// + [JsonProperty(PropertyName = "powerState")] + public string PowerState { get; private set; } + + /// + /// Gets or sets the current running status of VMware Tools running in + /// the guest operating system. + /// + [JsonProperty(PropertyName = "toolsRunningStatus")] + public string ToolsRunningStatus { get; private set; } + + /// + /// Gets or sets the current version status of VMware Tools installed + /// in the guest operating system. + /// + [JsonProperty(PropertyName = "toolsVersionStatus")] + public string ToolsVersionStatus { get; private set; } + + /// + /// Gets or sets the current version of VMware Tools. + /// + [JsonProperty(PropertyName = "toolsVersion")] + public string ToolsVersion { get; private set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineTemplate.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineTemplate.cs new file mode 100644 index 000000000000..5afa2156a34d --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineTemplate.cs @@ -0,0 +1,299 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Define the virtualMachineTemplate. + /// + [Rest.Serialization.JsonTransformation] + public partial class VirtualMachineTemplate : IResource + { + /// + /// Initializes a new instance of the VirtualMachineTemplate class. + /// + public VirtualMachineTemplate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachineTemplate class. + /// + /// Gets or sets the location. + /// Gets or sets a unique identifier for this + /// resource. + /// Gets or sets the ARM Id of the vCenter + /// resource in which this template resides. + /// Gets or sets the vCenter MoRef (Managed + /// Object Reference) ID for the virtual machine + /// template. + /// Gets or sets the inventory Item ID + /// for the virtual machine template. + /// Gets or sets the vCenter Managed Object name + /// for the virtual machine template. + /// Gets or sets memory size in MBs for the + /// template. + /// Gets or sets the number of vCPUs for the + /// template. + /// Gets or sets the number of cores + /// per socket for the template. + /// Defaults to 1 if unspecified. + /// Gets or sets the type of the os. Possible + /// values include: 'Windows', 'Linux', 'Other' + /// Gets or sets os name. + /// Gets or sets the folder path of the + /// template. + /// Gets or sets the network interfaces + /// of the template. + /// Gets or sets the disks the template. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// Gets or sets the current version + /// status of VMware Tools installed in the guest operating + /// system. + /// Gets or sets the current version of + /// VMware Tools. + /// Firmware type. Possible values include: + /// 'bios', 'efi' + /// The resource status information. + /// Gets or sets the provisioning + /// state. + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public VirtualMachineTemplate(string location, string uuid = default(string), string vCenterId = default(string), string moRefId = default(string), string inventoryItemId = default(string), string moName = default(string), int? memorySizeMB = default(int?), int? numCPUs = default(int?), int? numCoresPerSocket = default(int?), string osType = default(string), string osName = default(string), string folderPath = default(string), IList networkInterfaces = default(IList), IList disks = default(IList), string customResourceName = default(string), string toolsVersionStatus = default(string), string toolsVersion = default(string), string firmwareType = default(string), IList statuses = default(IList), string provisioningState = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string)) + { + Uuid = uuid; + VCenterId = vCenterId; + MoRefId = moRefId; + InventoryItemId = inventoryItemId; + MoName = moName; + MemorySizeMB = memorySizeMB; + NumCPUs = numCPUs; + NumCoresPerSocket = numCoresPerSocket; + OsType = osType; + OsName = osName; + FolderPath = folderPath; + NetworkInterfaces = networkInterfaces; + Disks = disks; + CustomResourceName = customResourceName; + ToolsVersionStatus = toolsVersionStatus; + ToolsVersion = toolsVersion; + FirmwareType = firmwareType; + Statuses = statuses; + ProvisioningState = provisioningState; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets the ARM Id of the vCenter resource in which this + /// template resides. + /// + [JsonProperty(PropertyName = "properties.vCenterId")] + public string VCenterId { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID for + /// the virtual machine + /// template. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the inventory Item ID for the virtual machine + /// template. + /// + [JsonProperty(PropertyName = "properties.inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the virtual + /// machine template. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; private set; } + + /// + /// Gets or sets memory size in MBs for the template. + /// + [JsonProperty(PropertyName = "properties.memorySizeMB")] + public int? MemorySizeMB { get; private set; } + + /// + /// Gets or sets the number of vCPUs for the template. + /// + [JsonProperty(PropertyName = "properties.numCPUs")] + public int? NumCPUs { get; private set; } + + /// + /// Gets or sets the number of cores per socket for the template. + /// Defaults to 1 if unspecified. + /// + [JsonProperty(PropertyName = "properties.numCoresPerSocket")] + public int? NumCoresPerSocket { get; private set; } + + /// + /// Gets or sets the type of the os. Possible values include: + /// 'Windows', 'Linux', 'Other' + /// + [JsonProperty(PropertyName = "properties.osType")] + public string OsType { get; private set; } + + /// + /// Gets or sets os name. + /// + [JsonProperty(PropertyName = "properties.osName")] + public string OsName { get; private set; } + + /// + /// Gets or sets the folder path of the template. + /// + [JsonProperty(PropertyName = "properties.folderPath")] + public string FolderPath { get; private set; } + + /// + /// Gets or sets the network interfaces of the template. + /// + [JsonProperty(PropertyName = "properties.networkInterfaces")] + public IList NetworkInterfaces { get; private set; } + + /// + /// Gets or sets the disks the template. + /// + [JsonProperty(PropertyName = "properties.disks")] + public IList Disks { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets or sets the current version status of VMware Tools installed + /// in the guest operating system. + /// + [JsonProperty(PropertyName = "properties.toolsVersionStatus")] + public string ToolsVersionStatus { get; private set; } + + /// + /// Gets or sets the current version of VMware Tools. + /// + [JsonProperty(PropertyName = "properties.toolsVersion")] + public string ToolsVersion { get; private set; } + + /// + /// Gets firmware type. Possible values include: 'bios', 'efi' + /// + [JsonProperty(PropertyName = "properties.firmwareType")] + public string FirmwareType { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineTemplateInventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineTemplateInventoryItem.cs new file mode 100644 index 000000000000..6c356396de79 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineTemplateInventoryItem.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The VM Template inventory item. + /// + [Newtonsoft.Json.JsonObject("VirtualMachineTemplate")] + public partial class VirtualMachineTemplateInventoryItem : InventoryItemProperties + { + /// + /// Initializes a new instance of the + /// VirtualMachineTemplateInventoryItem class. + /// + public VirtualMachineTemplateInventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// VirtualMachineTemplateInventoryItem class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + /// Gets or sets memory size in MBs for the + /// template. + /// Gets or sets the number of vCPUs for the + /// template. + /// Gets or sets the number of cores + /// per socket for the template. + /// Defaults to 1 if unspecified. + /// Gets or sets the type of the os. Possible + /// values include: 'Windows', 'Linux', 'Other' + /// Gets or sets os name. + /// Gets or sets the folder path of the + /// template. + public VirtualMachineTemplateInventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string), int? memorySizeMB = default(int?), int? numCPUs = default(int?), int? numCoresPerSocket = default(int?), string osType = default(string), string osName = default(string), string folderPath = default(string)) + : base(managedResourceId, moRefId, moName, provisioningState) + { + MemorySizeMB = memorySizeMB; + NumCPUs = numCPUs; + NumCoresPerSocket = numCoresPerSocket; + OsType = osType; + OsName = osName; + FolderPath = folderPath; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets memory size in MBs for the template. + /// + [JsonProperty(PropertyName = "memorySizeMB")] + public int? MemorySizeMB { get; set; } + + /// + /// Gets or sets the number of vCPUs for the template. + /// + [JsonProperty(PropertyName = "numCPUs")] + public int? NumCPUs { get; set; } + + /// + /// Gets or sets the number of cores per socket for the template. + /// Defaults to 1 if unspecified. + /// + [JsonProperty(PropertyName = "numCoresPerSocket")] + public int? NumCoresPerSocket { get; set; } + + /// + /// Gets or sets the type of the os. Possible values include: + /// 'Windows', 'Linux', 'Other' + /// + [JsonProperty(PropertyName = "osType")] + public string OsType { get; set; } + + /// + /// Gets or sets os name. + /// + [JsonProperty(PropertyName = "osName")] + public string OsName { get; set; } + + /// + /// Gets or sets the folder path of the template. + /// + [JsonProperty(PropertyName = "folderPath")] + public string FolderPath { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineUpdate.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineUpdate.cs new file mode 100644 index 000000000000..4b1205cdd58b --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualMachineUpdate.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines the virtualMachineUpdate. + /// + [Rest.Serialization.JsonTransformation] + public partial class VirtualMachineUpdate + { + /// + /// Initializes a new instance of the VirtualMachineUpdate class. + /// + public VirtualMachineUpdate() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachineUpdate class. + /// + /// Gets or sets the Resource tags. + /// The identity of the resource. + public VirtualMachineUpdate(HardwareProfile hardwareProfile = default(HardwareProfile), StorageProfileUpdate storageProfile = default(StorageProfileUpdate), NetworkProfileUpdate networkProfile = default(NetworkProfileUpdate), IDictionary tags = default(IDictionary), Identity identity = default(Identity)) + { + HardwareProfile = hardwareProfile; + StorageProfile = storageProfile; + NetworkProfile = networkProfile; + Tags = tags; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.hardwareProfile")] + public HardwareProfile HardwareProfile { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.storageProfile")] + public StorageProfileUpdate StorageProfile { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.networkProfile")] + public NetworkProfileUpdate NetworkProfile { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the identity of the resource. + /// + [JsonProperty(PropertyName = "identity")] + public Identity Identity { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualNetwork.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualNetwork.cs new file mode 100644 index 000000000000..b2d6e6ba4dd2 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualNetwork.cs @@ -0,0 +1,194 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.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; + + /// + /// Define the virtualNetwork. + /// + [Rest.Serialization.JsonTransformation] + public partial class VirtualNetwork : IResource + { + /// + /// Initializes a new instance of the VirtualNetwork class. + /// + public VirtualNetwork() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualNetwork class. + /// + /// Gets or sets the location. + /// Gets or sets a unique identifier for this + /// resource. + /// Gets or sets the ARM Id of the vCenter + /// resource in which this template resides. + /// Gets or sets the vCenter MoRef (Managed + /// Object Reference) ID for the virtual network. + /// Gets or sets the inventory Item ID + /// for the virtual network. + /// Gets or sets the vCenter Managed Object name + /// for the virtual network. + /// Gets the name of the corresponding + /// resource in Kubernetes. + /// The resource status information. + /// Gets or sets the provisioning + /// state. + /// Gets or sets the extended + /// location. + /// The system data. + /// Gets or sets the Resource tags. + /// Gets or sets the name. + /// Gets or sets the Id. + /// Gets or sets the type of the resource. + /// Metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + public VirtualNetwork(string location, string uuid = default(string), string vCenterId = default(string), string moRefId = default(string), string inventoryItemId = default(string), string moName = default(string), string customResourceName = default(string), IList statuses = default(IList), string provisioningState = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData), IDictionary tags = default(IDictionary), string name = default(string), string id = default(string), string type = default(string), string kind = default(string)) + { + Uuid = uuid; + VCenterId = vCenterId; + MoRefId = moRefId; + InventoryItemId = inventoryItemId; + MoName = moName; + CustomResourceName = customResourceName; + Statuses = statuses; + ProvisioningState = provisioningState; + Location = location; + ExtendedLocation = extendedLocation; + SystemData = systemData; + Tags = tags; + Name = name; + Id = id; + Type = type; + Kind = kind; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a unique identifier for this resource. + /// + [JsonProperty(PropertyName = "properties.uuid")] + public string Uuid { get; private set; } + + /// + /// Gets or sets the ARM Id of the vCenter resource in which this + /// template resides. + /// + [JsonProperty(PropertyName = "properties.vCenterId")] + public string VCenterId { get; set; } + + /// + /// Gets or sets the vCenter MoRef (Managed Object Reference) ID for + /// the virtual network. + /// + [JsonProperty(PropertyName = "properties.moRefId")] + public string MoRefId { get; set; } + + /// + /// Gets or sets the inventory Item ID for the virtual network. + /// + [JsonProperty(PropertyName = "properties.inventoryItemId")] + public string InventoryItemId { get; set; } + + /// + /// Gets or sets the vCenter Managed Object name for the virtual + /// network. + /// + [JsonProperty(PropertyName = "properties.moName")] + public string MoName { get; private set; } + + /// + /// Gets the name of the corresponding resource in Kubernetes. + /// + [JsonProperty(PropertyName = "properties.customResourceName")] + public string CustomResourceName { get; private set; } + + /// + /// Gets the resource status information. + /// + [JsonProperty(PropertyName = "properties.statuses")] + public IList Statuses { get; private set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the extended location. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + + /// + /// Gets or sets the system data. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; set; } + + /// + /// Gets or sets the Resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets metadata used by portal/tooling/etc to render + /// different UX experiences for resources of the same type; e.g. + /// ApiApps are a kind of Microsoft.Web/sites type. If supported, the + /// resource provider must validate and persist this value. + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualNetworkInventoryItem.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualNetworkInventoryItem.cs new file mode 100644 index 000000000000..e2a1c975eb0a --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualNetworkInventoryItem.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.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The Virtual network inventory item. + /// + [Newtonsoft.Json.JsonObject("VirtualNetwork")] + public partial class VirtualNetworkInventoryItem : InventoryItemProperties + { + /// + /// Initializes a new instance of the VirtualNetworkInventoryItem + /// class. + /// + public VirtualNetworkInventoryItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualNetworkInventoryItem + /// class. + /// + /// Gets or sets the tracked resource + /// id corresponding to the inventory resource. + /// Gets or sets the MoRef (Managed Object + /// Reference) ID for the inventory item. + /// Gets or sets the vCenter Managed Object name + /// for the inventory item. + /// Gets or sets the provisioning + /// state. + public VirtualNetworkInventoryItem(string managedResourceId = default(string), string moRefId = default(string), string moName = default(string), string provisioningState = default(string)) + : base(managedResourceId, moRefId, moName, provisioningState) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualSCSIController.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualSCSIController.cs new file mode 100644 index 000000000000..d11f7f864244 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualSCSIController.cs @@ -0,0 +1,94 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// This data object type contains the properties of a SCSI controller + /// device attached to a virtual machine that is reported by the + /// controller. + /// + public partial class VirtualSCSIController + { + /// + /// Initializes a new instance of the VirtualSCSIController class. + /// + public VirtualSCSIController() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualSCSIController class. + /// + /// Gets or sets the controller type. Possible + /// values include: 'lsilogic', 'buslogic', 'pvscsi', + /// 'lsilogicsas' + /// Gets or sets the key of the + /// controller. + /// Gets or sets the bus number of the + /// controller. + /// Gets or sets the SCSI controller + /// unit number. + /// Gets or sets the sharing mode. Possible + /// values include: 'noSharing', 'physicalSharing', + /// 'virtualSharing' + public VirtualSCSIController(string type = default(string), int? controllerKey = default(int?), int? busNumber = default(int?), int? scsiCtlrUnitNumber = default(int?), string sharing = default(string)) + { + Type = type; + ControllerKey = controllerKey; + BusNumber = busNumber; + ScsiCtlrUnitNumber = scsiCtlrUnitNumber; + Sharing = sharing; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the controller type. Possible values include: + /// 'lsilogic', 'buslogic', 'pvscsi', 'lsilogicsas' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the key of the controller. + /// + [JsonProperty(PropertyName = "controllerKey")] + public int? ControllerKey { get; set; } + + /// + /// Gets or sets the bus number of the controller. + /// + [JsonProperty(PropertyName = "busNumber")] + public int? BusNumber { get; set; } + + /// + /// Gets or sets the SCSI controller unit number. + /// + [JsonProperty(PropertyName = "scsiCtlrUnitNumber")] + public int? ScsiCtlrUnitNumber { get; set; } + + /// + /// Gets or sets the sharing mode. Possible values include: + /// 'noSharing', 'physicalSharing', 'virtualSharing' + /// + [JsonProperty(PropertyName = "sharing")] + public string Sharing { get; set; } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualSCSISharing.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualSCSISharing.cs new file mode 100644 index 000000000000..9c7b7bdb778c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Models/VirtualSCSISharing.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere.Models +{ + + /// + /// Defines values for VirtualSCSISharing. + /// + public static class VirtualSCSISharing + { + public const string NoSharing = "noSharing"; + public const string PhysicalSharing = "physicalSharing"; + public const string VirtualSharing = "virtualSharing"; + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Operations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Operations.cs new file mode 100644 index 000000000000..5721e92a1f64 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/Operations.cs @@ -0,0 +1,390 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Returns list of all 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.ConnectedVMwarevSphere/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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Returns list of all 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/OperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..87a940ff2cfa --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/OperationsExtensions.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 + { + /// + /// Returns list of all operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Returns list of all 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; + } + } + + /// + /// Returns list of all 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(); + } + + /// + /// Returns list of all 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ResourcePoolsOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ResourcePoolsOperations.cs new file mode 100644 index 000000000000..c3a56e811dc1 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ResourcePoolsOperations.cs @@ -0,0 +1,1620 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, resourcePoolName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a resourcePool. + /// + /// + /// Implements resourcePool GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 resourcePoolName, 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 (resourcePoolName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourcePoolName"); + } + 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("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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a resourcePool. + /// + /// + /// API to update certain properties of the resourcePool resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Resource tags. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string resourcePoolName, 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 (resourcePoolName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourcePoolName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + ResourcePatch body = default(ResourcePatch); + if (tags != null) + { + body = new ResourcePatch(); + body.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("resourcePoolName", resourcePoolName); + tracingParameters.Add("body", body); + 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.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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("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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string resourcePoolName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, resourcePoolName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/resourcePools").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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool), 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 (resourcePoolName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourcePoolName"); + } + 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("resourcePoolName", resourcePoolName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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("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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 resourcePoolName, bool? force = default(bool?), 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 (resourcePoolName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourcePoolName"); + } + 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("resourcePoolName", resourcePoolName); + tracingParameters.Add("force", force); + 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.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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 (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ResourcePoolsOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ResourcePoolsOperationsExtensions.cs new file mode 100644 index 000000000000..ee11e7ad9c93 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/ResourcePoolsOperationsExtensions.cs @@ -0,0 +1,481 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 ResourcePoolsOperations. + /// + public static partial class ResourcePoolsOperationsExtensions + { + /// + /// Implements resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + public static ResourcePool Create(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool)) + { + return operations.CreateAsync(resourceGroupName, resourcePoolName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, resourcePoolName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a resourcePool. + /// + /// + /// Implements resourcePool GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + public static ResourcePool Get(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName) + { + return operations.GetAsync(resourceGroupName, resourcePoolName).GetAwaiter().GetResult(); + } + + /// + /// Gets a resourcePool. + /// + /// + /// Implements resourcePool GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, resourcePoolName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a resourcePool. + /// + /// + /// API to update certain properties of the resourcePool resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Resource tags. + /// + public static ResourcePool Update(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, resourcePoolName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates a resourcePool. + /// + /// + /// API to update certain properties of the resourcePool resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Resource tags. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, resourcePoolName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, resourcePoolName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, resourcePoolName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IResourcePoolsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IResourcePoolsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IResourcePoolsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IResourcePoolsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + public static ResourcePool BeginCreate(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool)) + { + return operations.BeginCreateAsync(resourceGroupName, resourcePoolName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements resourcePool PUT method. + /// + /// + /// Create Or Update resourcePool. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, ResourcePool body = default(ResourcePool), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, resourcePoolName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, resourcePoolName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an resourcePool. + /// + /// + /// Implements resourcePool DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the resourcePool. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IResourcePoolsOperations operations, string resourceGroupName, string resourcePoolName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, resourcePoolName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// 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 resourcePools in a subscription. + /// + /// + /// List of resourcePools in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IResourcePoolsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in 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 IResourcePoolsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET resourcePools in a resource group. + /// + /// + /// List of resourcePools in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IResourcePoolsOperations 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/SdkInfo_AzureArcVMwareManagementServiceAPI.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/SdkInfo_AzureArcVMwareManagementServiceAPI.cs new file mode 100644 index 000000000000..7f76943ab716 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/SdkInfo_AzureArcVMwareManagementServiceAPI.cs @@ -0,0 +1,39 @@ + +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_AzureArcVMwareManagementServiceAPI + { + get + { + return new Tuple[] + { + new Tuple("ConnectedVMwarevSphere", "Clusters", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "Datastores", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "GuestAgents", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "Hosts", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "HybridIdentityMetadata", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "InventoryItems", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "MachineExtensions", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "Operations", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "ResourcePools", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "VCenters", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "VirtualMachineTemplates", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "VirtualMachines", "2020-10-01-preview"), + new Tuple("ConnectedVMwarevSphere", "VirtualNetworks", "2020-10-01-preview"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VCentersOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VCentersOperations.cs new file mode 100644 index 000000000000..db01b6bca720 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VCentersOperations.cs @@ -0,0 +1,1620 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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; + + /// + /// VCentersOperations operations. + /// + internal partial class VCentersOperations : IServiceOperations, IVCentersOperations + { + /// + /// Initializes a new instance of the VCentersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal VCentersOperations(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, VCenter body = default(VCenter), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, vcenterName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a vCenter. + /// + /// + /// Implements vCenter GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 vcenterName, 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + 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("vcenterName", vcenterName); + 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.ConnectedVMwarevSphere/vcenters/{vcenterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a vCenter. + /// + /// + /// API to update certain properties of the vCenter resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Resource tags. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + ResourcePatch body = default(ResourcePatch); + if (tags != null) + { + body = new ResourcePatch(); + body.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("vcenterName", vcenterName); + tracingParameters.Add("body", body); + 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.ConnectedVMwarevSphere/vcenters/{vcenterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string vcenterName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, vcenterName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/vcenters").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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string vcenterName, VCenter body = default(VCenter), 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + 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("vcenterName", vcenterName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + 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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 vcenterName, bool? force = default(bool?), 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 (vcenterName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "vcenterName"); + } + 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("vcenterName", vcenterName); + tracingParameters.Add("force", force); + 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.ConnectedVMwarevSphere/vcenters/{vcenterName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{vcenterName}", System.Uri.EscapeDataString(vcenterName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VCentersOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VCentersOperationsExtensions.cs new file mode 100644 index 000000000000..5cebb4c71cbf --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VCentersOperationsExtensions.cs @@ -0,0 +1,481 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 VCentersOperations. + /// + public static partial class VCentersOperationsExtensions + { + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + public static VCenter Create(this IVCentersOperations operations, string resourceGroupName, string vcenterName, VCenter body = default(VCenter)) + { + return operations.CreateAsync(resourceGroupName, vcenterName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IVCentersOperations operations, string resourceGroupName, string vcenterName, VCenter body = default(VCenter), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, vcenterName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a vCenter. + /// + /// + /// Implements vCenter GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + public static VCenter Get(this IVCentersOperations operations, string resourceGroupName, string vcenterName) + { + return operations.GetAsync(resourceGroupName, vcenterName).GetAwaiter().GetResult(); + } + + /// + /// Gets a vCenter. + /// + /// + /// Implements vCenter GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVCentersOperations operations, string resourceGroupName, string vcenterName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, vcenterName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a vCenter. + /// + /// + /// API to update certain properties of the vCenter resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Resource tags. + /// + public static VCenter Update(this IVCentersOperations operations, string resourceGroupName, string vcenterName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, vcenterName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates a vCenter. + /// + /// + /// API to update certain properties of the vCenter resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Resource tags. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IVCentersOperations operations, string resourceGroupName, string vcenterName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, vcenterName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IVCentersOperations operations, string resourceGroupName, string vcenterName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, vcenterName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IVCentersOperations operations, string resourceGroupName, string vcenterName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, vcenterName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IVCentersOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IVCentersOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IVCentersOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IVCentersOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + public static VCenter BeginCreate(this IVCentersOperations operations, string resourceGroupName, string vcenterName, VCenter body = default(VCenter)) + { + return operations.BeginCreateAsync(resourceGroupName, vcenterName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements vCenter PUT method. + /// + /// + /// Create Or Update vCenter. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IVCentersOperations operations, string resourceGroupName, string vcenterName, VCenter body = default(VCenter), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, vcenterName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IVCentersOperations operations, string resourceGroupName, string vcenterName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, vcenterName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an vCenter. + /// + /// + /// Implements vCenter DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the vCenter. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IVCentersOperations operations, string resourceGroupName, string vcenterName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, vcenterName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IVCentersOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET vCenters in a subscription. + /// + /// + /// List of vCenters in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IVCentersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in 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 IVCentersOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET vCenters in a resource group. + /// + /// + /// List of vCenters in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IVCentersOperations 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachineTemplatesOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachineTemplatesOperations.cs new file mode 100644 index 000000000000..1665bea23f42 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachineTemplatesOperations.cs @@ -0,0 +1,1620 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a virtual machine template. + /// + /// + /// Implements virtual machine template GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 virtualMachineTemplateName, 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 (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("resourceGroupName", resourceGroupName); + 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a virtual machine template. + /// + /// + /// API to update certain properties of the virtual machine template resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Resource tags. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineTemplateName, 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 (virtualMachineTemplateName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualMachineTemplateName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + ResourcePatch body = default(ResourcePatch); + if (tags != null) + { + body = new ResourcePatch(); + body.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("virtualMachineTemplateName", virtualMachineTemplateName); + tracingParameters.Add("body", body); + 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.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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("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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualMachineTemplateName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/virtualMachineTemplates").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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate), 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 (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("resourceGroupName", resourceGroupName); + tracingParameters.Add("virtualMachineTemplateName", virtualMachineTemplateName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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("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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualMachineTemplateName, bool? force = default(bool?), 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 (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("resourceGroupName", resourceGroupName); + tracingParameters.Add("virtualMachineTemplateName", virtualMachineTemplateName); + tracingParameters.Add("force", force); + 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.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _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 (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachineTemplatesOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachineTemplatesOperationsExtensions.cs new file mode 100644 index 000000000000..d05378c9999c --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachineTemplatesOperationsExtensions.cs @@ -0,0 +1,481 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 VirtualMachineTemplatesOperations. + /// + public static partial class VirtualMachineTemplatesOperationsExtensions + { + /// + /// Implements virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + public static VirtualMachineTemplate Create(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate)) + { + return operations.CreateAsync(resourceGroupName, virtualMachineTemplateName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a virtual machine template. + /// + /// + /// Implements virtual machine template GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + public static VirtualMachineTemplate Get(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName) + { + return operations.GetAsync(resourceGroupName, virtualMachineTemplateName).GetAwaiter().GetResult(); + } + + /// + /// Gets a virtual machine template. + /// + /// + /// Implements virtual machine template GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a virtual machine template. + /// + /// + /// API to update certain properties of the virtual machine template resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Resource tags. + /// + public static VirtualMachineTemplate Update(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, virtualMachineTemplateName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates a virtual machine template. + /// + /// + /// API to update certain properties of the virtual machine template resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Resource tags. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, virtualMachineTemplateName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IVirtualMachineTemplatesOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IVirtualMachineTemplatesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IVirtualMachineTemplatesOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + public static VirtualMachineTemplate BeginCreate(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate)) + { + return operations.BeginCreateAsync(resourceGroupName, virtualMachineTemplateName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine template PUT method. + /// + /// + /// Create Or Update virtual machine template. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, VirtualMachineTemplate body = default(VirtualMachineTemplate), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, virtualMachineTemplateName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an virtual machine template. + /// + /// + /// Implements virtual machine template DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine template resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IVirtualMachineTemplatesOperations operations, string resourceGroupName, string virtualMachineTemplateName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineTemplateName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// 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 GET virtualMachineTemplates in a subscription. + /// + /// + /// List of virtualMachineTemplates in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IVirtualMachineTemplatesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in 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 IVirtualMachineTemplatesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualMachineTemplates in a resource group. + /// + /// + /// List of virtualMachineTemplates in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IVirtualMachineTemplatesOperations 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachinesOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachinesOperations.cs new file mode 100644 index 000000000000..b3da8402d578 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachinesOperations.cs @@ -0,0 +1,2277 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements virtual machine PUT method. + /// + /// + /// Create Or Update virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a virtual machine. + /// + /// + /// Implements virtual machine GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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.ConnectedVMwarevSphere/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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, VirtualMachineUpdate body = default(VirtualMachineUpdate), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown whereas + /// false indicates otherwise. Defaults to false. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StopWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, bool? skipShutdown = false, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, virtualMachineName, skipShutdown, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StartWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStartWithHttpMessagesAsync(resourceGroupName, virtualMachineName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task RestartWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginRestartWithHttpMessagesAsync(resourceGroupName, virtualMachineName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements virtual machine PUT method. + /// + /// + /// Create Or Update virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine), 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("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/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 (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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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, VirtualMachineUpdate body = default(VirtualMachineUpdate), 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("body", body); + 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.ConnectedVMwarevSphere/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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualMachineName, bool? force = default(bool?), 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("force", force); + 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.ConnectedVMwarevSphere/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 (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown whereas + /// false indicates otherwise. Defaults to false. + /// + /// + /// 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 virtualMachineName, bool? skipShutdown = false, 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"); + } + StopVirtualMachineOptions body = default(StopVirtualMachineOptions); + if (skipShutdown != null) + { + body = new StopVirtualMachineOptions(); + body.SkipShutdown = skipShutdown; + } + // 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("body", body); + 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.ConnectedVMwarevSphere/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 (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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 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, "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.ConnectedVMwarevSphere/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 (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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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 BeginRestartWithHttpMessagesAsync(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, "BeginRestart", 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.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart").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 (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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachinesOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachinesOperationsExtensions.cs new file mode 100644 index 000000000000..642749b9d06e --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualMachinesOperationsExtensions.cs @@ -0,0 +1,809 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for VirtualMachinesOperations. + /// + public static partial class VirtualMachinesOperationsExtensions + { + /// + /// Implements virtual machine PUT method. + /// + /// + /// Create Or Update virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + public static VirtualMachine Create(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine)) + { + return operations.CreateAsync(resourceGroupName, virtualMachineName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine PUT method. + /// + /// + /// Create Or Update virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a virtual machine. + /// + /// + /// Implements virtual machine GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + public static VirtualMachine Get(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName) + { + return operations.GetAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Gets a virtual machine. + /// + /// + /// Implements virtual machine GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// 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; + } + } + + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + public static VirtualMachine Update(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachineUpdate body = default(VirtualMachineUpdate)) + { + return operations.UpdateAsync(resourceGroupName, virtualMachineName, body).GetAwaiter().GetResult(); + } + + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachineUpdate body = default(VirtualMachineUpdate), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, virtualMachineName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown whereas + /// false indicates otherwise. Defaults to false. + /// + public static void Stop(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? skipShutdown = false) + { + operations.StopAsync(resourceGroupName, virtualMachineName, skipShutdown).GetAwaiter().GetResult(); + } + + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown whereas + /// false indicates otherwise. Defaults to false. + /// + /// + /// The cancellation token. + /// + public static async Task StopAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? skipShutdown = false, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StopWithHttpMessagesAsync(resourceGroupName, virtualMachineName, skipShutdown, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + public static void Start(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName) + { + operations.StartAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// The cancellation token. + /// + public static async Task StartAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StartWithHttpMessagesAsync(resourceGroupName, virtualMachineName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + public static void Restart(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName) + { + operations.RestartAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// The cancellation token. + /// + public static async Task RestartAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RestartWithHttpMessagesAsync(resourceGroupName, virtualMachineName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IVirtualMachinesOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IVirtualMachinesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IVirtualMachinesOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IVirtualMachinesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, 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 Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + public static VirtualMachine BeginCreate(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine)) + { + return operations.BeginCreateAsync(resourceGroupName, virtualMachineName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual machine PUT method. + /// + /// + /// Create Or Update virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachine body = default(VirtualMachine), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + public static VirtualMachine BeginUpdate(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachineUpdate body = default(VirtualMachineUpdate)) + { + return operations.BeginUpdateAsync(resourceGroupName, virtualMachineName, body).GetAwaiter().GetResult(); + } + + /// + /// Updates a virtual machine. + /// + /// + /// API to update certain properties of the virtual machine resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Resource properties to update. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, VirtualMachineUpdate body = default(VirtualMachineUpdate), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, virtualMachineName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, virtualMachineName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an virtual machine. + /// + /// + /// Implements virtual machine DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualMachineName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown whereas + /// false indicates otherwise. Defaults to false. + /// + public static void BeginStop(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? skipShutdown = false) + { + operations.BeginStopAsync(resourceGroupName, virtualMachineName, skipShutdown).GetAwaiter().GetResult(); + } + + /// + /// Implements the operation to stop a virtual machine. + /// + /// + /// Stop virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// Gets or sets a value indicating whether to request non-graceful VM + /// shutdown. True value for this flag indicates non-graceful shutdown whereas + /// false indicates otherwise. Defaults to false. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStopAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, bool? skipShutdown = false, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, virtualMachineName, skipShutdown, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + public static void BeginStart(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName) + { + operations.BeginStartAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements the operation to start a virtual machine. + /// + /// + /// Start virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStartAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStartWithHttpMessagesAsync(resourceGroupName, virtualMachineName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + public static void BeginRestart(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName) + { + operations.BeginRestartAsync(resourceGroupName, virtualMachineName).GetAwaiter().GetResult(); + } + + /// + /// Implements the operation to restart a virtual machine. + /// + /// + /// Restart virtual machine. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual machine resource. + /// + /// + /// The cancellation token. + /// + public static async Task BeginRestartAsync(this IVirtualMachinesOperations operations, string resourceGroupName, string virtualMachineName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginRestartWithHttpMessagesAsync(resourceGroupName, virtualMachineName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IVirtualMachinesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualMachines in a subscription. + /// + /// + /// List of virtualMachines in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IVirtualMachinesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in 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 IVirtualMachinesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualMachines in a resource group. + /// + /// + /// List of virtualMachines in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> 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/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualNetworksOperations.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualNetworksOperations.cs new file mode 100644 index 000000000000..8ba5e673b936 --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualNetworksOperations.cs @@ -0,0 +1,1620 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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(AzureArcVMwareManagementServiceAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the AzureArcVMwareManagementServiceAPIClient + /// + public AzureArcVMwareManagementServiceAPIClient Client { get; private set; } + + /// + /// Implements virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, body, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a virtual network. + /// + /// + /// Implements virtual network GET method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 virtualNetworkName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (virtualNetworkName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); + } + if (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("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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates a virtual network. + /// + /// + /// API to update certain properties of the virtual network resource. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Resource tags. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, 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 (virtualNetworkName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + ResourcePatch body = default(ResourcePatch); + if (tags != null) + { + body = new ResourcePatch(); + body.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("virtualNetworkName", virtualNetworkName); + tracingParameters.Add("body", body); + 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.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); + List _queryParameters = new List(); + if (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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, force, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Implements GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in a resource group. + /// + /// + /// The Resource Group 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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.ConnectedVMwarevSphere/virtualNetworks").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 (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (virtualNetworkName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); + } + if (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("virtualNetworkName", virtualNetworkName); + tracingParameters.Add("body", body); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); + List _queryParameters = new List(); + if (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(body != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(body, 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// 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 virtualNetworkName, bool? force = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (virtualNetworkName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkName"); + } + if (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("virtualNetworkName", virtualNetworkName); + tracingParameters.Add("force", force); + 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.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{virtualNetworkName}", System.Uri.EscapeDataString(virtualNetworkName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (force != null) + { + _queryParameters.Add(string.Format("force={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(force, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualNetworksOperationsExtensions.cs b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualNetworksOperationsExtensions.cs new file mode 100644 index 000000000000..bc919b204a2f --- /dev/null +++ b/sdk/connectedvmware/Microsoft.Azure.Management.ConnectedVMwarevSphere/src/Generated/VirtualNetworksOperationsExtensions.cs @@ -0,0 +1,481 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ConnectedVMwarevSphere +{ + 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 VirtualNetworksOperations. + /// + public static partial class VirtualNetworksOperationsExtensions + { + /// + /// Implements virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + public static VirtualNetwork Create(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork)) + { + return operations.CreateAsync(resourceGroupName, virtualNetworkName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a virtual network. + /// + /// + /// Implements virtual network GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + public static VirtualNetwork Get(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName) + { + return operations.GetAsync(resourceGroupName, virtualNetworkName).GetAwaiter().GetResult(); + } + + /// + /// Gets a virtual network. + /// + /// + /// Implements virtual network GET method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates a virtual network. + /// + /// + /// API to update certain properties of the virtual network resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Resource tags. + /// + public static VirtualNetwork Update(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, virtualNetworkName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates a virtual network. + /// + /// + /// API to update certain properties of the virtual network resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Resource tags. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + public static void Delete(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, bool? force = default(bool?)) + { + operations.DeleteAsync(resourceGroupName, virtualNetworkName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IVirtualNetworksOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IVirtualNetworksOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + public static IPage ListByResourceGroup(this IVirtualNetworksOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IVirtualNetworksOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + public static VirtualNetwork BeginCreate(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork)) + { + return operations.BeginCreateAsync(resourceGroupName, virtualNetworkName, body).GetAwaiter().GetResult(); + } + + /// + /// Implements virtual network PUT method. + /// + /// + /// Create Or Update virtual network. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Request payload. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, VirtualNetwork body = default(VirtualNetwork), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, body, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + public static void BeginDelete(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, bool? force = default(bool?)) + { + operations.BeginDeleteAsync(resourceGroupName, virtualNetworkName, force).GetAwaiter().GetResult(); + } + + /// + /// Deletes an virtual network. + /// + /// + /// Implements virtual network DELETE method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The Resource Group Name. + /// + /// + /// Name of the virtual network resource. + /// + /// + /// Whether force delete was specified. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IVirtualNetworksOperations operations, string resourceGroupName, string virtualNetworkName, bool? force = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, virtualNetworkName, force, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Implements GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// 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 GET virtualNetworks in a subscription. + /// + /// + /// List of virtualNetworks in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IVirtualNetworksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in 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 IVirtualNetworksOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Implements GET virtualNetworks in a resource group. + /// + /// + /// List of virtualNetworks in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IVirtualNetworksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}