diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/DpsCertificateOperations.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/DpsCertificateOperations.cs new file mode 100644 index 000000000000..8069f6cf91d1 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/DpsCertificateOperations.cs @@ -0,0 +1,1538 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + 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; + + /// + /// DpsCertificateOperations operations. + /// + internal partial class DpsCertificateOperations : IServiceOperations, IDpsCertificateOperations + { + /// + /// Initializes a new instance of the DpsCertificateOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DpsCertificateOperations(IotDpsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the IotDpsClient + /// + public IotDpsClient Client { get; private set; } + + /// + /// Get the certificate from the provisioning service. + /// + /// + /// Name of the certificate to retrieve. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of the provisioning service the certificate is associated with. + /// + /// + /// ETag of the certificate. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 certificateName, string resourceGroupName, string provisioningServiceName, string ifMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (certificateName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "certificateName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + 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("certificateName", certificateName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("ifMatch", ifMatch); + 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.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}").ToString(); + _url = _url.Replace("{certificateName}", System.Uri.EscapeDataString(certificateName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + 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 (ifMatch != null) + { + if (_httpRequest.Headers.Contains("If-Match")) + { + _httpRequest.Headers.Remove("If-Match"); + } + _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Upload the certificate to the provisioning service. + /// + /// + /// Add new certificate or update an existing certificate. + /// + /// + /// Resource group identifier. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the certificate create or update. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// Base-64 representation of the X509 leaf certificate .cer file or just .pem + /// file content. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + if (certificateName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "certificateName"); + } + CertificateBodyDescription certificateDescription = new CertificateBodyDescription(); + if (certificate != null) + { + certificateDescription.Certificate = certificate; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("certificateName", certificateName); + tracingParameters.Add("ifMatch", ifMatch); + tracingParameters.Add("certificateDescription", certificateDescription); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + _url = _url.Replace("{certificateName}", System.Uri.EscapeDataString(certificateName)); + 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 (ifMatch != null) + { + if (_httpRequest.Headers.Contains("If-Match")) + { + _httpRequest.Headers.Remove("If-Match"); + } + _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(certificateDescription != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(certificateDescription, 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Delete the Provisioning Service Certificate. + /// + /// + /// Deletes the specified certificate associated with the Provisioning Service + /// + /// + /// Resource group identifier. + /// + /// + /// ETag of the certificate + /// + /// + /// The name of the provisioning service. + /// + /// + /// This is a mandatory field, and is the logical name of the certificate that + /// the provisioning service will access by. + /// + /// + /// This is optional, and it is the Common Name of the certificate. + /// + /// + /// Raw data within the certificate. + /// + /// + /// Indicates if certificate has been verified by owner of the private key. + /// + /// + /// A description that mentions the purpose of the certificate. Possible values + /// include: 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Time the certificate is created. + /// + /// + /// Time the certificate is last updated. + /// + /// + /// Indicates if the certificate contains a private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// 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 ifMatch, string provisioningServiceName, string certificateName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = 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 (ifMatch == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ifMatch"); + } + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + if (certificateName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "certificateName"); + } + 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("ifMatch", ifMatch); + tracingParameters.Add("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("certificateName", certificateName); + tracingParameters.Add("certificatename", certificatename); + tracingParameters.Add("certificaterawBytes", certificaterawBytes); + tracingParameters.Add("certificateisVerified", certificateisVerified); + tracingParameters.Add("certificatepurpose", certificatepurpose); + tracingParameters.Add("certificatecreated", certificatecreated); + tracingParameters.Add("certificatelastUpdated", certificatelastUpdated); + tracingParameters.Add("certificatehasPrivateKey", certificatehasPrivateKey); + tracingParameters.Add("certificatenonce", certificatenonce); + 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.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + _url = _url.Replace("{certificateName}", System.Uri.EscapeDataString(certificateName)); + List _queryParameters = new List(); + if (certificatename != null) + { + _queryParameters.Add(string.Format("certificate.name={0}", System.Uri.EscapeDataString(certificatename))); + } + if (certificaterawBytes != null) + { + _queryParameters.Add(string.Format("certificate.rawBytes={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificaterawBytes, Client.SerializationSettings).Trim('"')))); + } + if (certificateisVerified != null) + { + _queryParameters.Add(string.Format("certificate.isVerified={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificateisVerified, Client.SerializationSettings).Trim('"')))); + } + if (certificatepurpose != null) + { + _queryParameters.Add(string.Format("certificate.purpose={0}", System.Uri.EscapeDataString(certificatepurpose))); + } + if (certificatecreated != null) + { + _queryParameters.Add(string.Format("certificate.created={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatecreated, Client.SerializationSettings).Trim('"')))); + } + if (certificatelastUpdated != null) + { + _queryParameters.Add(string.Format("certificate.lastUpdated={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatelastUpdated, Client.SerializationSettings).Trim('"')))); + } + if (certificatehasPrivateKey != null) + { + _queryParameters.Add(string.Format("certificate.hasPrivateKey={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatehasPrivateKey, Client.SerializationSettings).Trim('"')))); + } + if (certificatenonce != null) + { + _queryParameters.Add(string.Format("certificate.nonce={0}", System.Uri.EscapeDataString(certificatenonce))); + } + 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 (ifMatch != null) + { + if (_httpRequest.Headers.Contains("If-Match")) + { + _httpRequest.Headers.Remove("If-Match"); + } + _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Get all the certificates tied to the provisioning service. + /// + /// + /// Name of resource group. + /// + /// + /// Name of provisioning service to retrieve certificates for. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 provisioningServiceName, 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 (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + 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("provisioningServiceName", provisioningServiceName); + 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.Devices/provisioningServices/{provisioningServiceName}/certificates").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Generate verification code for Proof of Possession. + /// + /// + /// The mandatory logical name of the certificate, that the provisioning + /// service uses to access. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// name of resource group. + /// + /// + /// Name of provisioning service. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the private key. + /// + /// + /// Description mentioning the purpose of the certificate. Possible values + /// include: 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> GenerateVerificationCodeWithHttpMessagesAsync(string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (certificateName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "certificateName"); + } + if (ifMatch == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ifMatch"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + 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("certificateName", certificateName); + tracingParameters.Add("ifMatch", ifMatch); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("certificatename", certificatename); + tracingParameters.Add("certificaterawBytes", certificaterawBytes); + tracingParameters.Add("certificateisVerified", certificateisVerified); + tracingParameters.Add("certificatepurpose", certificatepurpose); + tracingParameters.Add("certificatecreated", certificatecreated); + tracingParameters.Add("certificatelastUpdated", certificatelastUpdated); + tracingParameters.Add("certificatehasPrivateKey", certificatehasPrivateKey); + tracingParameters.Add("certificatenonce", certificatenonce); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GenerateVerificationCode", 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.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode").ToString(); + _url = _url.Replace("{certificateName}", System.Uri.EscapeDataString(certificateName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + List _queryParameters = new List(); + if (certificatename != null) + { + _queryParameters.Add(string.Format("certificate.name={0}", System.Uri.EscapeDataString(certificatename))); + } + if (certificaterawBytes != null) + { + _queryParameters.Add(string.Format("certificate.rawBytes={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificaterawBytes, Client.SerializationSettings).Trim('"')))); + } + if (certificateisVerified != null) + { + _queryParameters.Add(string.Format("certificate.isVerified={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificateisVerified, Client.SerializationSettings).Trim('"')))); + } + if (certificatepurpose != null) + { + _queryParameters.Add(string.Format("certificate.purpose={0}", System.Uri.EscapeDataString(certificatepurpose))); + } + if (certificatecreated != null) + { + _queryParameters.Add(string.Format("certificate.created={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatecreated, Client.SerializationSettings).Trim('"')))); + } + if (certificatelastUpdated != null) + { + _queryParameters.Add(string.Format("certificate.lastUpdated={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatelastUpdated, Client.SerializationSettings).Trim('"')))); + } + if (certificatehasPrivateKey != null) + { + _queryParameters.Add(string.Format("certificate.hasPrivateKey={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatehasPrivateKey, Client.SerializationSettings).Trim('"')))); + } + if (certificatenonce != null) + { + _queryParameters.Add(string.Format("certificate.nonce={0}", System.Uri.EscapeDataString(certificatenonce))); + } + 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 (ifMatch != null) + { + if (_httpRequest.Headers.Contains("If-Match")) + { + _httpRequest.Headers.Remove("If-Match"); + } + _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Verify certificate's private key possession. + /// + /// + /// Verifies the certificate's private key possession by providing the leaf + /// cert issued by the verifying pre uploaded certificate. + /// + /// + /// The mandatory logical name of the certificate, that the provisioning + /// service uses to access. + /// + /// + /// ETag of the certificate. + /// + /// + /// Resource group name. + /// + /// + /// Provisioning service name. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the private key. + /// + /// + /// Describe the purpose of the certificate. Possible values include: + /// 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// base-64 representation of X509 certificate .cer file or just .pem file + /// content. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> VerifyCertificateWithHttpMessagesAsync(string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), string certificate = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (certificateName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "certificateName"); + } + if (ifMatch == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ifMatch"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + VerificationCodeRequest request = new VerificationCodeRequest(); + if (certificate != null) + { + request.Certificate = certificate; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("certificateName", certificateName); + tracingParameters.Add("ifMatch", ifMatch); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("certificatename", certificatename); + tracingParameters.Add("certificaterawBytes", certificaterawBytes); + tracingParameters.Add("certificateisVerified", certificateisVerified); + tracingParameters.Add("certificatepurpose", certificatepurpose); + tracingParameters.Add("certificatecreated", certificatecreated); + tracingParameters.Add("certificatelastUpdated", certificatelastUpdated); + tracingParameters.Add("certificatehasPrivateKey", certificatehasPrivateKey); + tracingParameters.Add("certificatenonce", certificatenonce); + tracingParameters.Add("request", request); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "VerifyCertificate", 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.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify").ToString(); + _url = _url.Replace("{certificateName}", System.Uri.EscapeDataString(certificateName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + List _queryParameters = new List(); + if (certificatename != null) + { + _queryParameters.Add(string.Format("certificate.name={0}", System.Uri.EscapeDataString(certificatename))); + } + if (certificaterawBytes != null) + { + _queryParameters.Add(string.Format("certificate.rawBytes={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificaterawBytes, Client.SerializationSettings).Trim('"')))); + } + if (certificateisVerified != null) + { + _queryParameters.Add(string.Format("certificate.isVerified={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificateisVerified, Client.SerializationSettings).Trim('"')))); + } + if (certificatepurpose != null) + { + _queryParameters.Add(string.Format("certificate.purpose={0}", System.Uri.EscapeDataString(certificatepurpose))); + } + if (certificatecreated != null) + { + _queryParameters.Add(string.Format("certificate.created={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatecreated, Client.SerializationSettings).Trim('"')))); + } + if (certificatelastUpdated != null) + { + _queryParameters.Add(string.Format("certificate.lastUpdated={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatelastUpdated, Client.SerializationSettings).Trim('"')))); + } + if (certificatehasPrivateKey != null) + { + _queryParameters.Add(string.Format("certificate.hasPrivateKey={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(certificatehasPrivateKey, Client.SerializationSettings).Trim('"')))); + } + if (certificatenonce != null) + { + _queryParameters.Add(string.Format("certificate.nonce={0}", System.Uri.EscapeDataString(certificatenonce))); + } + 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 (ifMatch != null) + { + if (_httpRequest.Headers.Contains("If-Match")) + { + _httpRequest.Headers.Remove("If-Match"); + } + _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(request != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(request, 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/DpsCertificateOperationsExtensions.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/DpsCertificateOperationsExtensions.cs new file mode 100644 index 000000000000..da68b00bbfc8 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/DpsCertificateOperationsExtensions.cs @@ -0,0 +1,518 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DpsCertificateOperations. + /// + public static partial class DpsCertificateOperationsExtensions + { + /// + /// Get the certificate from the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the certificate to retrieve. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of the provisioning service the certificate is associated with. + /// + /// + /// ETag of the certificate. + /// + public static CertificateResponse Get(this IDpsCertificateOperations operations, string certificateName, string resourceGroupName, string provisioningServiceName, string ifMatch = default(string)) + { + return operations.GetAsync(certificateName, resourceGroupName, provisioningServiceName, ifMatch).GetAwaiter().GetResult(); + } + + /// + /// Get the certificate from the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the certificate to retrieve. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of the provisioning service the certificate is associated with. + /// + /// + /// ETag of the certificate. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDpsCertificateOperations operations, string certificateName, string resourceGroupName, string provisioningServiceName, string ifMatch = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(certificateName, resourceGroupName, provisioningServiceName, ifMatch, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Upload the certificate to the provisioning service. + /// + /// + /// Add new certificate or update an existing certificate. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the certificate create or update. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// Base-64 representation of the X509 leaf certificate .cer file or just .pem + /// file content. + /// + public static CertificateResponse CreateOrUpdate(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string)) + { + return operations.CreateOrUpdateAsync(resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificate).GetAwaiter().GetResult(); + } + + /// + /// Upload the certificate to the provisioning service. + /// + /// + /// Add new certificate or update an existing certificate. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the certificate create or update. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// Base-64 representation of the X509 leaf certificate .cer file or just .pem + /// file content. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, certificateName, ifMatch, certificate, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete the Provisioning Service Certificate. + /// + /// + /// Deletes the specified certificate associated with the Provisioning Service + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// ETag of the certificate + /// + /// + /// The name of the provisioning service. + /// + /// + /// This is a mandatory field, and is the logical name of the certificate that + /// the provisioning service will access by. + /// + /// + /// This is optional, and it is the Common Name of the certificate. + /// + /// + /// Raw data within the certificate. + /// + /// + /// Indicates if certificate has been verified by owner of the private key. + /// + /// + /// A description that mentions the purpose of the certificate. Possible values + /// include: 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Time the certificate is created. + /// + /// + /// Time the certificate is last updated. + /// + /// + /// Indicates if the certificate contains a private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + public static void Delete(this IDpsCertificateOperations operations, string resourceGroupName, string ifMatch, string provisioningServiceName, string certificateName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string)) + { + operations.DeleteAsync(resourceGroupName, ifMatch, provisioningServiceName, certificateName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce).GetAwaiter().GetResult(); + } + + /// + /// Delete the Provisioning Service Certificate. + /// + /// + /// Deletes the specified certificate associated with the Provisioning Service + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// ETag of the certificate + /// + /// + /// The name of the provisioning service. + /// + /// + /// This is a mandatory field, and is the logical name of the certificate that + /// the provisioning service will access by. + /// + /// + /// This is optional, and it is the Common Name of the certificate. + /// + /// + /// Raw data within the certificate. + /// + /// + /// Indicates if certificate has been verified by owner of the private key. + /// + /// + /// A description that mentions the purpose of the certificate. Possible values + /// include: 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Time the certificate is created. + /// + /// + /// Time the certificate is last updated. + /// + /// + /// Indicates if the certificate contains a private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDpsCertificateOperations operations, string resourceGroupName, string ifMatch, string provisioningServiceName, string certificateName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, ifMatch, provisioningServiceName, certificateName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get all the certificates tied to the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of resource group. + /// + /// + /// Name of provisioning service to retrieve certificates for. + /// + public static CertificateListDescription List(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName) + { + return operations.ListAsync(resourceGroupName, provisioningServiceName).GetAwaiter().GetResult(); + } + + /// + /// Get all the certificates tied to the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of resource group. + /// + /// + /// Name of provisioning service to retrieve certificates for. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IDpsCertificateOperations operations, string resourceGroupName, string provisioningServiceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Generate verification code for Proof of Possession. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The mandatory logical name of the certificate, that the provisioning + /// service uses to access. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// name of resource group. + /// + /// + /// Name of provisioning service. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the private key. + /// + /// + /// Description mentioning the purpose of the certificate. Possible values + /// include: 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + public static VerificationCodeResponse GenerateVerificationCode(this IDpsCertificateOperations operations, string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string)) + { + return operations.GenerateVerificationCodeAsync(certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce).GetAwaiter().GetResult(); + } + + /// + /// Generate verification code for Proof of Possession. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The mandatory logical name of the certificate, that the provisioning + /// service uses to access. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// name of resource group. + /// + /// + /// Name of provisioning service. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the private key. + /// + /// + /// Description mentioning the purpose of the certificate. Possible values + /// include: 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// The cancellation token. + /// + public static async Task GenerateVerificationCodeAsync(this IDpsCertificateOperations operations, string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GenerateVerificationCodeWithHttpMessagesAsync(certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Verify certificate's private key possession. + /// + /// + /// Verifies the certificate's private key possession by providing the leaf + /// cert issued by the verifying pre uploaded certificate. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The mandatory logical name of the certificate, that the provisioning + /// service uses to access. + /// + /// + /// ETag of the certificate. + /// + /// + /// Resource group name. + /// + /// + /// Provisioning service name. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the private key. + /// + /// + /// Describe the purpose of the certificate. Possible values include: + /// 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// base-64 representation of X509 certificate .cer file or just .pem file + /// content. + /// + public static CertificateResponse VerifyCertificate(this IDpsCertificateOperations operations, string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), string certificate = default(string)) + { + return operations.VerifyCertificateAsync(certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce, certificate).GetAwaiter().GetResult(); + } + + /// + /// Verify certificate's private key possession. + /// + /// + /// Verifies the certificate's private key possession by providing the leaf + /// cert issued by the verifying pre uploaded certificate. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The mandatory logical name of the certificate, that the provisioning + /// service uses to access. + /// + /// + /// ETag of the certificate. + /// + /// + /// Resource group name. + /// + /// + /// Provisioning service name. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the private key. + /// + /// + /// Describe the purpose of the certificate. Possible values include: + /// 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// base-64 representation of X509 certificate .cer file or just .pem file + /// content. + /// + /// + /// The cancellation token. + /// + public static async Task VerifyCertificateAsync(this IDpsCertificateOperations operations, string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), string certificate = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.VerifyCertificateWithHttpMessagesAsync(certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce, certificate, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IDpsCertificateOperations.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IDpsCertificateOperations.cs new file mode 100644 index 000000000000..9ec14ce8004f --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IDpsCertificateOperations.cs @@ -0,0 +1,308 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DpsCertificateOperations operations. + /// + public partial interface IDpsCertificateOperations + { + /// + /// Get the certificate from the provisioning service. + /// + /// + /// Name of the certificate to retrieve. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of the provisioning service the certificate is associated + /// with. + /// + /// + /// ETag of the certificate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// 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 certificateName, string resourceGroupName, string provisioningServiceName, string ifMatch = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Upload the certificate to the provisioning service. + /// + /// + /// Add new certificate or update an existing certificate. + /// + /// + /// Resource group identifier. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the certificate create or update. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// Base-64 representation of the X509 leaf certificate .cer file or + /// just .pem file content. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// 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 provisioningServiceName, string certificateName, string ifMatch = default(string), string certificate = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete the Provisioning Service Certificate. + /// + /// + /// Deletes the specified certificate associated with the Provisioning + /// Service + /// + /// + /// Resource group identifier. + /// + /// + /// ETag of the certificate + /// + /// + /// The name of the provisioning service. + /// + /// + /// This is a mandatory field, and is the logical name of the + /// certificate that the provisioning service will access by. + /// + /// + /// This is optional, and it is the Common Name of the certificate. + /// + /// + /// Raw data within the certificate. + /// + /// + /// Indicates if certificate has been verified by owner of the private + /// key. + /// + /// + /// A description that mentions the purpose of the certificate. + /// Possible values include: 'clientAuthentication', + /// 'serverAuthentication' + /// + /// + /// Time the certificate is created. + /// + /// + /// Time the certificate is last updated. + /// + /// + /// Indicates if the certificate contains a private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// 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 ifMatch, string provisioningServiceName, string certificateName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the certificates tied to the provisioning service. + /// + /// + /// Name of resource group. + /// + /// + /// Name of provisioning service to retrieve certificates for. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// 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 provisioningServiceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Generate verification code for Proof of Possession. + /// + /// + /// The mandatory logical name of the certificate, that the + /// provisioning service uses to access. + /// + /// + /// ETag of the certificate. This is required to update an existing + /// certificate, and ignored while creating a brand new certificate. + /// + /// + /// name of resource group. + /// + /// + /// Name of provisioning service. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the + /// private key. + /// + /// + /// Description mentioning the purpose of the certificate. Possible + /// values include: 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GenerateVerificationCodeWithHttpMessagesAsync(string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Verify certificate's private key possession. + /// + /// + /// Verifies the certificate's private key possession by providing the + /// leaf cert issued by the verifying pre uploaded certificate. + /// + /// + /// The mandatory logical name of the certificate, that the + /// provisioning service uses to access. + /// + /// + /// ETag of the certificate. + /// + /// + /// Resource group name. + /// + /// + /// Provisioning service name. + /// + /// + /// Common Name for the certificate. + /// + /// + /// Raw data of certificate. + /// + /// + /// Indicates if the certificate has been verified by owner of the + /// private key. + /// + /// + /// Describe the purpose of the certificate. Possible values include: + /// 'clientAuthentication', 'serverAuthentication' + /// + /// + /// Certificate creation time. + /// + /// + /// Certificate last updated time. + /// + /// + /// Indicates if the certificate contains private key. + /// + /// + /// Random number generated to indicate Proof of Possession. + /// + /// + /// base-64 representation of X509 certificate .cer file or just .pem + /// file content. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> VerifyCertificateWithHttpMessagesAsync(string certificateName, string ifMatch, string resourceGroupName, string provisioningServiceName, string certificatename = default(string), byte[] certificaterawBytes = default(byte[]), bool? certificateisVerified = default(bool?), string certificatepurpose = default(string), System.DateTime? certificatecreated = default(System.DateTime?), System.DateTime? certificatelastUpdated = default(System.DateTime?), bool? certificatehasPrivateKey = default(bool?), string certificatenonce = default(string), string certificate = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IIotDpsClient.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IIotDpsClient.cs new file mode 100644 index 000000000000..c8d8617c8462 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IIotDpsClient.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.DeviceProvisioningServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// API for using the Azure IoT Hub Device Provisioning Service features. + /// + public partial interface IIotDpsClient : 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 identifier. + /// + string SubscriptionId { get; set; } + + /// + /// The version of the API. + /// + 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 IDpsCertificateOperations. + /// + IDpsCertificateOperations DpsCertificate { get; } + + /// + /// Gets the IIotDpsResourceOperations. + /// + IIotDpsResourceOperations IotDpsResource { get; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IIotDpsResourceOperations.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IIotDpsResourceOperations.cs new file mode 100644 index 000000000000..90576f52d554 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IIotDpsResourceOperations.cs @@ -0,0 +1,790 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// IotDpsResourceOperations operations. + /// + public partial interface IIotDpsResourceOperations + { + /// + /// Get the non-security related metadata of the provisioning service. + /// + /// + /// Get the metadata of the provisioning service without SAS keys. + /// + /// + /// Name of the provisioning service to retrieve. + /// + /// + /// 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> GetWithHttpMessagesAsync(string provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The + /// usual pattern to modify a property is to retrieve the provisioning + /// service metadata and security metadata, and then combine them with + /// the modified values in a new body to update the provisioning + /// service. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other + /// fields use the CreateOrUpdate method + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// 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 provisioningServiceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + /// + /// 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 provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a list of all provisioning services in the given resource + /// group. + /// + /// + /// Resource group identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// 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)); + /// + /// Gets the status of a long running operation, such as create, update + /// or delete a provisioning service. + /// + /// + /// Operation id corresponding to long running operation. Use this to + /// poll for the status. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service that the operation is running on. + /// + /// + /// Async header used to poll on the status of the operation, obtained + /// while creating the long running 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> GetOperationResultWithHttpMessagesAsync(string operationId, string resourceGroupName, string provisioningServiceName, string asyncinfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// Name of provisioning service. + /// + /// + /// Name of resource group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListValidSkusWithHttpMessagesAsync(string provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Check if a provisioning service name is available. + /// + /// + /// Check if a provisioning service name is available. This will + /// validate if the name is syntactically valid and if the name is + /// usable + /// + /// + /// The name of the Provisioning Service to check. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CheckProvisioningServiceNameAvailabilityWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// The provisioning service name to get the shared access keys for. + /// + /// + /// 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>> ListKeysWithHttpMessagesAsync(string provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a shared access policy by name from a provisioning service. + /// + /// + /// List primary and secondary keys for a specific key name + /// + /// + /// Name of the provisioning service. + /// + /// + /// Logical key name to get key-values for. + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListKeysForKeyNameWithHttpMessagesAsync(string provisioningServiceName, string keyName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List private link resources + /// + /// + /// List private link resources for the given provisioning service + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListPrivateLinkResourcesWithHttpMessagesAsync(string resourceGroupName, string resourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the specified private link resource + /// + /// + /// Get the specified private link resource for the given provisioning + /// service + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private link 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> GetPrivateLinkResourcesWithHttpMessagesAsync(string resourceGroupName, string resourceName, string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List private endpoint connections + /// + /// + /// List private endpoint connection properties + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListPrivateEndpointConnectionsWithHttpMessagesAsync(string resourceGroupName, string resourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get private endpoint connection + /// + /// + /// Get private endpoint connection properties + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetPrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with + /// the specified name + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdatePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> DeletePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The + /// usual pattern to modify a property is to retrieve the provisioning + /// service metadata and security metadata, and then combine them with + /// the modified values in a new body to update the provisioning + /// service. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other + /// fields use the CreateOrUpdate method + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + /// + /// 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 provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with + /// the specified name + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdatePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The name of the resource group that contains the provisioning + /// service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginDeletePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get a list of all provisioning services in the given 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)); + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// 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>> ListValidSkusNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// 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>> ListKeysNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IOperations.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IOperations.cs new file mode 100644 index 000000000000..4ffca0bd4ec3 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/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.DeviceProvisioningServices +{ + 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 + { + /// + /// Lists all of the available Microsoft.Devices REST API 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)); + /// + /// Lists all of the available Microsoft.Devices REST API 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/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsClient.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsClient.cs new file mode 100644 index 000000000000..0197ce54e8f7 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsClient.cs @@ -0,0 +1,370 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + 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; + + /// + /// API for using the Azure IoT Hub Device Provisioning Service features. + /// + public partial class IotDpsClient : ServiceClient, IIotDpsClient, 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 identifier. + /// + public string SubscriptionId { get; set; } + + /// + /// The version of the API. + /// + 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 IDpsCertificateOperations. + /// + public virtual IDpsCertificateOperations DpsCertificate { get; private set; } + + /// + /// Gets the IIotDpsResourceOperations. + /// + public virtual IIotDpsResourceOperations IotDpsResource { get; private set; } + + /// + /// Initializes a new instance of the IotDpsClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling IotDpsClient.Dispose(). False: will not dispose provided httpClient + protected IotDpsClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the IotDpsClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected IotDpsClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the IotDpsClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected IotDpsClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the IotDpsClient 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 IotDpsClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the IotDpsClient 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 IotDpsClient(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 IotDpsClient 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 IotDpsClient(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 IotDpsClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling IotDpsClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public IotDpsClient(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 IotDpsClient 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 IotDpsClient(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 IotDpsClient 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 IotDpsClient(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 IotDpsClient 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 IotDpsClient(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); + DpsCertificate = new DpsCertificateOperations(this); + IotDpsResource = new IotDpsResourceOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-09-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() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsResourceOperations.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsResourceOperations.cs new file mode 100644 index 000000000000..ac8af71fd267 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsResourceOperations.cs @@ -0,0 +1,4307 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + 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; + + /// + /// IotDpsResourceOperations operations. + /// + internal partial class IotDpsResourceOperations : IServiceOperations, IIotDpsResourceOperations + { + /// + /// Initializes a new instance of the IotDpsResourceOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal IotDpsResourceOperations(IotDpsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the IotDpsClient + /// + public IotDpsClient Client { get; private set; } + + /// + /// Get the non-security related metadata of the provisioning service. + /// + /// + /// Get the metadata of the provisioning service without SAS keys. + /// + /// + /// Name of the provisioning service to retrieve. + /// + /// + /// 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> GetWithHttpMessagesAsync(string provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + 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("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + 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.Devices/provisioningServices/{provisioningServiceName}").ToString(); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + _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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The usual + /// pattern to modify a property is to retrieve the provisioning service + /// metadata and security metadata, and then combine them with the modified + /// values in a new body to update the provisioning service. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or update. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, iotDpsDescription, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other fields use + /// the CreateOrUpdate method + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Resource tags + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, tags, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(provisioningServiceName, resourceGroupName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionWithHttpMessagesAsync(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, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices").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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a list of all provisioning services in the given resource group. + /// + /// + /// Resource group identifier. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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.Devices/provisioningServices").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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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 the status of a long running operation, such as create, update or + /// delete a provisioning service. + /// + /// + /// Operation id corresponding to long running operation. Use this to poll for + /// the status. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service that the operation is running on. + /// + /// + /// Async header used to poll on the status of the operation, obtained while + /// creating the long running 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> GetOperationResultWithHttpMessagesAsync(string operationId, string resourceGroupName, string provisioningServiceName, string asyncinfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + if (asyncinfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "asyncinfo"); + } + 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("operationId", operationId); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("asyncinfo", asyncinfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetOperationResult", 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.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}").ToString(); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + List _queryParameters = new List(); + if (asyncinfo != null) + { + _queryParameters.Add(string.Format("asyncinfo={0}", System.Uri.EscapeDataString(asyncinfo))); + } + 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// Name of provisioning service. + /// + /// + /// Name of resource group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListValidSkusWithHttpMessagesAsync(string provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + 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("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListValidSkus", 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.Devices/provisioningServices/{provisioningServiceName}/skus").ToString(); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + _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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Check if a provisioning service name is available. + /// + /// + /// Check if a provisioning service name is available. This will validate if + /// the name is syntactically valid and if the name is usable + /// + /// + /// The name of the Provisioning Service to check. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> CheckProvisioningServiceNameAvailabilityWithHttpMessagesAsync(string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + OperationInputs arguments = new OperationInputs(); + if (name != null) + { + arguments.Name = name; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("arguments", arguments); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckProvisioningServiceNameAvailability", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(arguments != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(arguments, 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// The provisioning service name to get the shared access keys for. + /// + /// + /// 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>> ListKeysWithHttpMessagesAsync(string provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + 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("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListKeys", 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.Devices/provisioningServices/{provisioningServiceName}/listkeys").ToString(); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + _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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a shared access policy by name from a provisioning service. + /// + /// + /// List primary and secondary keys for a specific key name + /// + /// + /// Name of the provisioning service. + /// + /// + /// Logical key name to get key-values for. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> ListKeysForKeyNameWithHttpMessagesAsync(string provisioningServiceName, string keyName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + if (keyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyName"); + } + 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("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("keyName", keyName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListKeysForKeyName", 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.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys").ToString(); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + _url = _url.Replace("{keyName}", System.Uri.EscapeDataString(keyName)); + _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("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// List private link resources + /// + /// + /// List private link resources for the given provisioning service + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> ListPrivateLinkResourcesWithHttpMessagesAsync(string resourceGroupName, string resourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListPrivateLinkResources", 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.Devices/provisioningServices/{resourceName}/privateLinkResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the specified private link resource + /// + /// + /// Get the specified private link resource for the given provisioning service + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private link 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> GetPrivateLinkResourcesWithHttpMessagesAsync(string resourceGroupName, string resourceName, string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPrivateLinkResources", 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.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// List private endpoint connections + /// + /// + /// List private endpoint connection properties + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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>> ListPrivateEndpointConnectionsWithHttpMessagesAsync(string resourceGroupName, string resourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListPrivateEndpointConnections", 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.Devices/provisioningServices/{resourceName}/privateEndpointConnections").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get private endpoint connection + /// + /// + /// Get private endpoint connection properties + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> GetPrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPrivateEndpointConnection", 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.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with the + /// specified name + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdatePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdatePrivateEndpointConnectionWithHttpMessagesAsync(resourceGroupName, resourceName, privateEndpointConnectionName, properties, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeletePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeletePrivateEndpointConnectionWithHttpMessagesAsync(resourceGroupName, resourceName, privateEndpointConnectionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The usual + /// pattern to modify a property is to retrieve the provisioning service + /// metadata and security metadata, and then combine them with the modified + /// values in a new body to update the provisioning service. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription, 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 (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + if (iotDpsDescription == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "iotDpsDescription"); + } + 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("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("iotDpsDescription", iotDpsDescription); + 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.Devices/provisioningServices/{provisioningServiceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + 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(iotDpsDescription != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(iotDpsDescription, 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other fields use + /// the CreateOrUpdate method + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string provisioningServiceName, 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 (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + TagsResource provisioningServiceTags = new TagsResource(); + if (tags != null) + { + provisioningServiceTags.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("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("provisioningServiceTags", provisioningServiceTags); + 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.Devices/provisioningServices/{provisioningServiceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + 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(provisioningServiceTags != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(provisioningServiceTags, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + /// + /// 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 provisioningServiceName, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (provisioningServiceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "provisioningServiceName"); + } + 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("provisioningServiceName", provisioningServiceName); + tracingParameters.Add("resourceGroupName", resourceGroupName); + 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.Devices/provisioningServices/{provisioningServiceName}").ToString(); + _url = _url.Replace("{provisioningServiceName}", System.Uri.EscapeDataString(provisioningServiceName)); + _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("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 && (int)_statusCode != 404) + { + var ex = new ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with the + /// specified name + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> BeginCreateOrUpdatePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + if (properties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "properties"); + } + PrivateEndpointConnection privateEndpointConnection = new PrivateEndpointConnection(); + if (properties != null) + { + privateEndpointConnection.Properties = properties; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("privateEndpointConnection", privateEndpointConnection); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdatePrivateEndpointConnection", 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.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + 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(privateEndpointConnection != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(privateEndpointConnection, 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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; + } + + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> BeginDeletePrivateEndpointConnectionWithHttpMessagesAsync(string resourceGroupName, string resourceName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeletePrivateEndpointConnection", 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.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get a list of all provisioning services in the given 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// 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>> ListValidSkusNextWithHttpMessagesAsync(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, "ListValidSkusNext", 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// 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>> ListKeysNextWithHttpMessagesAsync(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, "ListKeysNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsResourceOperationsExtensions.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsResourceOperationsExtensions.cs new file mode 100644 index 000000000000..7dede66d5329 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/IotDpsResourceOperationsExtensions.cs @@ -0,0 +1,1269 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + 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 IotDpsResourceOperations. + /// + public static partial class IotDpsResourceOperationsExtensions + { + /// + /// Get the non-security related metadata of the provisioning service. + /// + /// + /// Get the metadata of the provisioning service without SAS keys. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the provisioning service to retrieve. + /// + /// + /// Resource group name. + /// + public static ProvisioningServiceDescription Get(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName) + { + return operations.GetAsync(provisioningServiceName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get the non-security related metadata of the provisioning service. + /// + /// + /// Get the metadata of the provisioning service without SAS keys. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the provisioning service to retrieve. + /// + /// + /// Resource group name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(provisioningServiceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The usual + /// pattern to modify a property is to retrieve the provisioning service + /// metadata and security metadata, and then combine them with the modified + /// values in a new body to update the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or update. + /// + public static ProvisioningServiceDescription CreateOrUpdate(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription) + { + return operations.CreateOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription).GetAwaiter().GetResult(); + } + + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The usual + /// pattern to modify a property is to retrieve the provisioning service + /// metadata and security metadata, and then combine them with the modified + /// values in a new body to update the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or update. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, iotDpsDescription, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other fields use + /// the CreateOrUpdate method + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Resource tags + /// + public static ProvisioningServiceDescription Update(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, provisioningServiceName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other fields use + /// the CreateOrUpdate method + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Resource tags + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + public static void Delete(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName) + { + operations.DeleteAsync(provisioningServiceName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(provisioningServiceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListBySubscription(this IIotDpsResourceOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IIotDpsResourceOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a list of all provisioning services in the given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + public static IPage ListByResourceGroup(this IIotDpsResourceOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get a list of all provisioning services in the given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IIotDpsResourceOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the status of a long running operation, such as create, update or + /// delete a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Operation id corresponding to long running operation. Use this to poll for + /// the status. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service that the operation is running on. + /// + /// + /// Async header used to poll on the status of the operation, obtained while + /// creating the long running operation. + /// + public static AsyncOperationResult GetOperationResult(this IIotDpsResourceOperations operations, string operationId, string resourceGroupName, string provisioningServiceName, string asyncinfo) + { + return operations.GetOperationResultAsync(operationId, resourceGroupName, provisioningServiceName, asyncinfo).GetAwaiter().GetResult(); + } + + /// + /// Gets the status of a long running operation, such as create, update or + /// delete a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Operation id corresponding to long running operation. Use this to poll for + /// the status. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service that the operation is running on. + /// + /// + /// Async header used to poll on the status of the operation, obtained while + /// creating the long running operation. + /// + /// + /// The cancellation token. + /// + public static async Task GetOperationResultAsync(this IIotDpsResourceOperations operations, string operationId, string resourceGroupName, string provisioningServiceName, string asyncinfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOperationResultWithHttpMessagesAsync(operationId, resourceGroupName, provisioningServiceName, asyncinfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of provisioning service. + /// + /// + /// Name of resource group. + /// + public static IPage ListValidSkus(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName) + { + return operations.ListValidSkusAsync(provisioningServiceName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of provisioning service. + /// + /// + /// Name of resource group. + /// + /// + /// The cancellation token. + /// + public static async Task> ListValidSkusAsync(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListValidSkusWithHttpMessagesAsync(provisioningServiceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Check if a provisioning service name is available. + /// + /// + /// Check if a provisioning service name is available. This will validate if + /// the name is syntactically valid and if the name is usable + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Provisioning Service to check. + /// + public static NameAvailabilityInfo CheckProvisioningServiceNameAvailability(this IIotDpsResourceOperations operations, string name) + { + return operations.CheckProvisioningServiceNameAvailabilityAsync(name).GetAwaiter().GetResult(); + } + + /// + /// Check if a provisioning service name is available. + /// + /// + /// Check if a provisioning service name is available. This will validate if + /// the name is syntactically valid and if the name is usable + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the Provisioning Service to check. + /// + /// + /// The cancellation token. + /// + public static async Task CheckProvisioningServiceNameAvailabilityAsync(this IIotDpsResourceOperations operations, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckProvisioningServiceNameAvailabilityWithHttpMessagesAsync(name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provisioning service name to get the shared access keys for. + /// + /// + /// resource group name + /// + public static IPage ListKeys(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName) + { + return operations.ListKeysAsync(provisioningServiceName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The provisioning service name to get the shared access keys for. + /// + /// + /// resource group name + /// + /// + /// The cancellation token. + /// + public static async Task> ListKeysAsync(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListKeysWithHttpMessagesAsync(provisioningServiceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a shared access policy by name from a provisioning service. + /// + /// + /// List primary and secondary keys for a specific key name + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the provisioning service. + /// + /// + /// Logical key name to get key-values for. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + public static SharedAccessSignatureAuthorizationRuleAccessRightsDescription ListKeysForKeyName(this IIotDpsResourceOperations operations, string provisioningServiceName, string keyName, string resourceGroupName) + { + return operations.ListKeysForKeyNameAsync(provisioningServiceName, keyName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get a shared access policy by name from a provisioning service. + /// + /// + /// List primary and secondary keys for a specific key name + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the provisioning service. + /// + /// + /// Logical key name to get key-values for. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The cancellation token. + /// + public static async Task ListKeysForKeyNameAsync(this IIotDpsResourceOperations operations, string provisioningServiceName, string keyName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListKeysForKeyNameWithHttpMessagesAsync(provisioningServiceName, keyName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List private link resources + /// + /// + /// List private link resources for the given provisioning service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + public static PrivateLinkResources ListPrivateLinkResources(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName) + { + return operations.ListPrivateLinkResourcesAsync(resourceGroupName, resourceName).GetAwaiter().GetResult(); + } + + /// + /// List private link resources + /// + /// + /// List private link resources for the given provisioning service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The cancellation token. + /// + public static async Task ListPrivateLinkResourcesAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListPrivateLinkResourcesWithHttpMessagesAsync(resourceGroupName, resourceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the specified private link resource + /// + /// + /// Get the specified private link resource for the given provisioning service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private link resource + /// + public static GroupIdInformation GetPrivateLinkResources(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string groupId) + { + return operations.GetPrivateLinkResourcesAsync(resourceGroupName, resourceName, groupId).GetAwaiter().GetResult(); + } + + /// + /// Get the specified private link resource + /// + /// + /// Get the specified private link resource for the given provisioning service + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private link resource + /// + /// + /// The cancellation token. + /// + public static async Task GetPrivateLinkResourcesAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string groupId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPrivateLinkResourcesWithHttpMessagesAsync(resourceGroupName, resourceName, groupId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List private endpoint connections + /// + /// + /// List private endpoint connection properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + public static IList ListPrivateEndpointConnections(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName) + { + return operations.ListPrivateEndpointConnectionsAsync(resourceGroupName, resourceName).GetAwaiter().GetResult(); + } + + /// + /// List private endpoint connections + /// + /// + /// List private endpoint connection properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The cancellation token. + /// + public static async Task> ListPrivateEndpointConnectionsAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListPrivateEndpointConnectionsWithHttpMessagesAsync(resourceGroupName, resourceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get private endpoint connection + /// + /// + /// Get private endpoint connection properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + public static PrivateEndpointConnection GetPrivateEndpointConnection(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName) + { + return operations.GetPrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Get private endpoint connection + /// + /// + /// Get private endpoint connection properties + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The cancellation token. + /// + public static async Task GetPrivateEndpointConnectionAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPrivateEndpointConnectionWithHttpMessagesAsync(resourceGroupName, resourceName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with the + /// specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + public static PrivateEndpointConnection CreateOrUpdatePrivateEndpointConnection(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties) + { + return operations.CreateOrUpdatePrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName, properties).GetAwaiter().GetResult(); + } + + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with the + /// specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdatePrivateEndpointConnectionAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdatePrivateEndpointConnectionWithHttpMessagesAsync(resourceGroupName, resourceName, privateEndpointConnectionName, properties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + public static PrivateEndpointConnection DeletePrivateEndpointConnection(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName) + { + return operations.DeletePrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The cancellation token. + /// + public static async Task DeletePrivateEndpointConnectionAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeletePrivateEndpointConnectionWithHttpMessagesAsync(resourceGroupName, resourceName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The usual + /// pattern to modify a property is to retrieve the provisioning service + /// metadata and security metadata, and then combine them with the modified + /// values in a new body to update the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or update. + /// + public static ProvisioningServiceDescription BeginCreateOrUpdate(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, provisioningServiceName, iotDpsDescription).GetAwaiter().GetResult(); + } + + /// + /// Create or update the metadata of the provisioning service. + /// + /// + /// Create or update the metadata of the provisioning service. The usual + /// pattern to modify a property is to retrieve the provisioning service + /// metadata and security metadata, and then combine them with the modified + /// values in a new body to update the provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Description of the provisioning service to create or update. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, ProvisioningServiceDescription iotDpsDescription, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, iotDpsDescription, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other fields use + /// the CreateOrUpdate method + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Resource tags + /// + public static ProvisioningServiceDescription BeginUpdate(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, IDictionary tags = default(IDictionary)) + { + return operations.BeginUpdateAsync(resourceGroupName, provisioningServiceName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update an existing provisioning service's tags. + /// + /// + /// Update an existing provisioning service's tags. to update other fields use + /// the CreateOrUpdate method + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource group identifier. + /// + /// + /// Name of provisioning service to create or update. + /// + /// + /// Resource tags + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string provisioningServiceName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, provisioningServiceName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + public static void BeginDelete(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName) + { + operations.BeginDeleteAsync(provisioningServiceName, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Delete the Provisioning Service + /// + /// + /// Deletes the Provisioning Service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of provisioning service to delete. + /// + /// + /// Resource group identifier. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IIotDpsResourceOperations operations, string provisioningServiceName, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(provisioningServiceName, resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with the + /// specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + public static PrivateEndpointConnection BeginCreateOrUpdatePrivateEndpointConnection(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties) + { + return operations.BeginCreateOrUpdatePrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName, properties).GetAwaiter().GetResult(); + } + + /// + /// Create or update private endpoint connection + /// + /// + /// Create or update the status of a private endpoint connection with the + /// specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The properties of a private endpoint connection + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdatePrivateEndpointConnectionAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName, PrivateEndpointConnectionProperties properties, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdatePrivateEndpointConnectionWithHttpMessagesAsync(resourceGroupName, resourceName, privateEndpointConnectionName, properties, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + public static PrivateEndpointConnection BeginDeletePrivateEndpointConnection(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName) + { + return operations.BeginDeletePrivateEndpointConnectionAsync(resourceGroupName, resourceName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Delete private endpoint connection + /// + /// + /// Delete private endpoint connection with the specified name + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the provisioning service. + /// + /// + /// The name of the provisioning service. + /// + /// + /// The name of the private endpoint connection + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeletePrivateEndpointConnectionAsync(this IIotDpsResourceOperations operations, string resourceGroupName, string resourceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeletePrivateEndpointConnectionWithHttpMessagesAsync(resourceGroupName, resourceName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IIotDpsResourceOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the provisioning services in a subscription. + /// + /// + /// List all the provisioning services for a given subscription id. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this IIotDpsResourceOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get a list of all provisioning services in the given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IIotDpsResourceOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get a list of all provisioning services in the given 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 IIotDpsResourceOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListValidSkusNext(this IIotDpsResourceOperations operations, string nextPageLink) + { + return operations.ListValidSkusNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get the list of valid SKUs for a provisioning service. + /// + /// + /// Gets the list of valid SKUs and tiers for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListValidSkusNextAsync(this IIotDpsResourceOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListValidSkusNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListKeysNext(this IIotDpsResourceOperations operations, string nextPageLink) + { + return operations.ListKeysNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get the security metadata for a provisioning service. + /// + /// + /// List the primary and secondary keys for a provisioning service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListKeysNextAsync(this IIotDpsResourceOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListKeysNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AccessRightsDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AccessRightsDescription.cs new file mode 100644 index 000000000000..629d33aad14b --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AccessRightsDescription.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.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for AccessRightsDescription. + /// + public static class AccessRightsDescription + { + public const string ServiceConfig = "ServiceConfig"; + public const string EnrollmentRead = "EnrollmentRead"; + public const string EnrollmentWrite = "EnrollmentWrite"; + public const string DeviceConnect = "DeviceConnect"; + public const string RegistrationStatusRead = "RegistrationStatusRead"; + public const string RegistrationStatusWrite = "RegistrationStatusWrite"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AllocationPolicy.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AllocationPolicy.cs new file mode 100644 index 000000000000..869a29ddfab9 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AllocationPolicy.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.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for AllocationPolicy. + /// + public static class AllocationPolicy + { + public const string Hashed = "Hashed"; + public const string GeoLatency = "GeoLatency"; + public const string Static = "Static"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ArmIdentity.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ArmIdentity.cs new file mode 100644 index 000000000000..9741e93636e2 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ArmIdentity.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The set of ARM identities associated with the IoT DPS resource. + /// + public partial class ArmIdentity + { + /// + /// Initializes a new instance of the ArmIdentity class. + /// + public ArmIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ArmIdentity class. + /// + /// Principal Id + /// Tenant Id + /// Identity type. Only allowed values are + /// SystemAssigned and UserAssigned. Comma separated if both for ex: + /// SystemAssigned,UserAssigned. + /// The set of UserAssigned + /// identities associated with the IoT DPS resource. + public ArmIdentity(string principalId = default(string), string tenantId = default(string), string identityType = default(string), IDictionary userAssignedIdentities = default(IDictionary)) + { + PrincipalId = principalId; + TenantId = tenantId; + IdentityType = identityType; + UserAssignedIdentities = userAssignedIdentities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets principal Id + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets tenant Id + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets or sets identity type. Only allowed values are SystemAssigned + /// and UserAssigned. Comma separated if both for ex: + /// SystemAssigned,UserAssigned. + /// + [JsonProperty(PropertyName = "identityType")] + public string IdentityType { get; set; } + + /// + /// Gets or sets the set of UserAssigned identities associated with the + /// IoT DPS resource. + /// + [JsonProperty(PropertyName = "userAssignedIdentities")] + public IDictionary UserAssignedIdentities { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ArmUserIdentity.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ArmUserIdentity.cs new file mode 100644 index 000000000000..1d5df6199673 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ArmUserIdentity.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The ARM UserAssigned identity information + /// + public partial class ArmUserIdentity + { + /// + /// Initializes a new instance of the ArmUserIdentity class. + /// + public ArmUserIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ArmUserIdentity class. + /// + /// Principal Id + /// Client Id + public ArmUserIdentity(string principalId = default(string), string clientId = default(string)) + { + PrincipalId = principalId; + ClientId = clientId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets principal Id + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; private set; } + + /// + /// Gets client Id + /// + [JsonProperty(PropertyName = "clientId")] + public string ClientId { get; private set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AsyncOperationResult.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AsyncOperationResult.cs new file mode 100644 index 000000000000..b34925448456 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/AsyncOperationResult.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Result of a long running operation. + /// + public partial class AsyncOperationResult + { + /// + /// Initializes a new instance of the AsyncOperationResult class. + /// + public AsyncOperationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AsyncOperationResult class. + /// + /// current status of a long running + /// operation. + /// Error message containing code, description and + /// details + public AsyncOperationResult(string status = default(string), ErrorMesssage error = default(ErrorMesssage)) + { + Status = status; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets current status of a long running operation. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets error message containing code, description and details + /// + [JsonProperty(PropertyName = "error")] + public ErrorMesssage Error { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateBodyDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateBodyDescription.cs new file mode 100644 index 000000000000..9f0f9360730b --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateBodyDescription.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The JSON-serialized X509 Certificate. + /// + public partial class CertificateBodyDescription + { + /// + /// Initializes a new instance of the CertificateBodyDescription class. + /// + public CertificateBodyDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CertificateBodyDescription class. + /// + /// Base-64 representation of the X509 leaf + /// certificate .cer file or just .pem file content. + public CertificateBodyDescription(string certificate = default(string)) + { + Certificate = certificate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets base-64 representation of the X509 leaf certificate + /// .cer file or just .pem file content. + /// + [JsonProperty(PropertyName = "certificate")] + public string Certificate { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateListDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateListDescription.cs new file mode 100644 index 000000000000..4edf2dea0527 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateListDescription.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The JSON-serialized array of Certificate objects. + /// + public partial class CertificateListDescription + { + /// + /// Initializes a new instance of the CertificateListDescription class. + /// + public CertificateListDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CertificateListDescription class. + /// + /// The array of Certificate objects. + public CertificateListDescription(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the array of Certificate objects. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateProperties.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateProperties.cs new file mode 100644 index 000000000000..7d007bb8dbe1 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateProperties.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The description of an X509 CA Certificate. + /// + public partial class CertificateProperties + { + /// + /// Initializes a new instance of the CertificateProperties class. + /// + public CertificateProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CertificateProperties class. + /// + /// The certificate's subject name. + /// The certificate's expiration date and + /// time. + /// The certificate's thumbprint. + /// Determines whether certificate has been + /// verified. + /// The certificate's creation date and + /// time. + /// The certificate's last update date and + /// time. + public CertificateProperties(string subject = default(string), System.DateTime? expiry = default(System.DateTime?), string thumbprint = default(string), bool? isVerified = default(bool?), System.DateTime? created = default(System.DateTime?), System.DateTime? updated = default(System.DateTime?)) + { + Subject = subject; + Expiry = expiry; + Thumbprint = thumbprint; + IsVerified = isVerified; + Created = created; + Updated = updated; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the certificate's subject name. + /// + [JsonProperty(PropertyName = "subject")] + public string Subject { get; private set; } + + /// + /// Gets the certificate's expiration date and time. + /// + [JsonConverter(typeof(DateTimeRfc1123JsonConverter))] + [JsonProperty(PropertyName = "expiry")] + public System.DateTime? Expiry { get; private set; } + + /// + /// Gets the certificate's thumbprint. + /// + [JsonProperty(PropertyName = "thumbprint")] + public string Thumbprint { get; private set; } + + /// + /// Gets determines whether certificate has been verified. + /// + [JsonProperty(PropertyName = "isVerified")] + public bool? IsVerified { get; private set; } + + /// + /// Gets the certificate's creation date and time. + /// + [JsonConverter(typeof(DateTimeRfc1123JsonConverter))] + [JsonProperty(PropertyName = "created")] + public System.DateTime? Created { get; private set; } + + /// + /// Gets the certificate's last update date and time. + /// + [JsonConverter(typeof(DateTimeRfc1123JsonConverter))] + [JsonProperty(PropertyName = "updated")] + public System.DateTime? Updated { get; private set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificatePurpose.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificatePurpose.cs new file mode 100644 index 000000000000..8d42c4fb0575 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificatePurpose.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.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for CertificatePurpose. + /// + public static class CertificatePurpose + { + public const string ClientAuthentication = "clientAuthentication"; + public const string ServerAuthentication = "serverAuthentication"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateResponse.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateResponse.cs new file mode 100644 index 000000000000..2ddbfd09bf8f --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/CertificateResponse.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.DeviceProvisioningServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The X509 Certificate. + /// + public partial class CertificateResponse : IResource + { + /// + /// Initializes a new instance of the CertificateResponse class. + /// + public CertificateResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CertificateResponse class. + /// + /// properties of a certificate + /// The resource identifier. + /// The name of the certificate. + /// The entity tag. + /// The resource type. + public CertificateResponse(CertificateProperties properties = default(CertificateProperties), string id = default(string), string name = default(string), string etag = default(string), string type = default(string)) + { + Properties = properties; + Id = id; + Name = name; + Etag = etag; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets properties of a certificate + /// + [JsonProperty(PropertyName = "properties")] + public CertificateProperties Properties { get; set; } + + /// + /// Gets the resource identifier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the certificate. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the entity tag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + /// + /// Gets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/EncryptionKeyIdentity.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/EncryptionKeyIdentity.cs new file mode 100644 index 000000000000..7db5f0414d49 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/EncryptionKeyIdentity.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the identity used to access the key encryption key in + /// KeyVault. + /// + public partial class EncryptionKeyIdentity + { + /// + /// Initializes a new instance of the EncryptionKeyIdentity class. + /// + public EncryptionKeyIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EncryptionKeyIdentity class. + /// + /// The user assigned + /// identity. + public EncryptionKeyIdentity(string userAssignedIdentity = default(string)) + { + UserAssignedIdentity = userAssignedIdentity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the user assigned identity. + /// + [JsonProperty(PropertyName = "userAssignedIdentity")] + public string UserAssignedIdentity { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/EncryptionPropertiesDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/EncryptionPropertiesDescription.cs new file mode 100644 index 000000000000..dbda2a33e5f6 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/EncryptionPropertiesDescription.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The customer-managed encryption key (CMK) properties for the IoT DPS + /// instance. + /// + public partial class EncryptionPropertiesDescription + { + /// + /// Initializes a new instance of the EncryptionPropertiesDescription + /// class. + /// + public EncryptionPropertiesDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EncryptionPropertiesDescription + /// class. + /// + /// The source of the encryption key. + /// Typically, Microsoft.KeyVault + /// The properties of the encryption + /// key configured in KeyVault. + /// The identity used to access the encryption + /// key in KeyVault. + public EncryptionPropertiesDescription(string keySource = default(string), IList keyVaultProperties = default(IList), EncryptionKeyIdentity identity = default(EncryptionKeyIdentity)) + { + KeySource = keySource; + KeyVaultProperties = keyVaultProperties; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the source of the encryption key. Typically, + /// Microsoft.KeyVault + /// + [JsonProperty(PropertyName = "keySource")] + public string KeySource { get; set; } + + /// + /// Gets or sets the properties of the encryption key configured in + /// KeyVault. + /// + [JsonProperty(PropertyName = "keyVaultProperties")] + public IList KeyVaultProperties { get; set; } + + /// + /// Gets or sets the identity used to access the encryption key in + /// KeyVault. + /// + [JsonProperty(PropertyName = "identity")] + public EncryptionKeyIdentity Identity { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorDetails.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorDetails.cs new file mode 100644 index 000000000000..0568f50d8561 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorDetails.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error details. + /// + public partial class ErrorDetails + { + /// + /// Initializes a new instance of the ErrorDetails class. + /// + public ErrorDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetails class. + /// + /// The error code. + /// The HTTP status code. + /// The error message. + /// The error details. + public ErrorDetails(string code = default(string), string httpStatusCode = default(string), string message = default(string), string details = default(string)) + { + Code = code; + HttpStatusCode = httpStatusCode; + Message = message; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets the HTTP status code. + /// + [JsonProperty(PropertyName = "httpStatusCode")] + public string HttpStatusCode { get; private set; } + + /// + /// Gets the error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + /// + /// Gets the error details. + /// + [JsonProperty(PropertyName = "details")] + public string Details { get; private set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorDetailsException.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorDetailsException.cs new file mode 100644 index 000000000000..d8daf7716fa1 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorDetailsException.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.DeviceProvisioningServices.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorDetails information. + /// + public partial class ErrorDetailsException : 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 ErrorDetails Body { get; set; } + + /// + /// Initializes a new instance of the ErrorDetailsException class. + /// + public ErrorDetailsException() + { + } + + /// + /// Initializes a new instance of the ErrorDetailsException class. + /// + /// The exception message. + public ErrorDetailsException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorDetailsException class. + /// + /// The exception message. + /// Inner exception. + public ErrorDetailsException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorMesssage.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorMesssage.cs new file mode 100644 index 000000000000..00ace596ad62 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ErrorMesssage.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response containing message and code. + /// + public partial class ErrorMesssage + { + /// + /// Initializes a new instance of the ErrorMesssage class. + /// + public ErrorMesssage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorMesssage class. + /// + /// standard error code + /// standard error description + /// detailed summary of error + public ErrorMesssage(string code = default(string), string message = default(string), string details = default(string)) + { + Code = code; + Message = message; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets standard error code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets standard error description + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets detailed summary of error + /// + [JsonProperty(PropertyName = "details")] + public string Details { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/GroupIdInformation.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/GroupIdInformation.cs new file mode 100644 index 000000000000..f2327ec5fdf2 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/GroupIdInformation.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The group information for creating a private endpoint on a provisioning + /// service + /// + public partial class GroupIdInformation + { + /// + /// Initializes a new instance of the GroupIdInformation class. + /// + public GroupIdInformation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GroupIdInformation class. + /// + /// The properties for a group information + /// object + /// The resource identifier. + /// The resource name. + /// The resource type. + public GroupIdInformation(GroupIdInformationProperties properties, string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the resource identifier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the properties for a group information object + /// + [JsonProperty(PropertyName = "properties")] + public GroupIdInformationProperties Properties { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/GroupIdInformationProperties.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/GroupIdInformationProperties.cs new file mode 100644 index 000000000000..3888de1065be --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/GroupIdInformationProperties.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The properties for a group information object + /// + public partial class GroupIdInformationProperties + { + /// + /// Initializes a new instance of the GroupIdInformationProperties + /// class. + /// + public GroupIdInformationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GroupIdInformationProperties + /// class. + /// + /// The group id + /// The required members for a specific + /// group id + /// The required DNS zones for a + /// specific group id + public GroupIdInformationProperties(string groupId = default(string), IList requiredMembers = default(IList), IList requiredZoneNames = default(IList)) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + RequiredZoneNames = requiredZoneNames; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the group id + /// + [JsonProperty(PropertyName = "groupId")] + public string GroupId { get; set; } + + /// + /// Gets or sets the required members for a specific group id + /// + [JsonProperty(PropertyName = "requiredMembers")] + public IList RequiredMembers { get; set; } + + /// + /// Gets or sets the required DNS zones for a specific group id + /// + [JsonProperty(PropertyName = "requiredZoneNames")] + public IList RequiredZoneNames { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsPropertiesDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsPropertiesDescription.cs new file mode 100644 index 000000000000..7ab8fb575787 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsPropertiesDescription.cs @@ -0,0 +1,169 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// the service specific properties of a provisioning service, including + /// keys, linked iot hubs, current state, and system generated properties + /// such as hostname and idScope + /// + public partial class IotDpsPropertiesDescription + { + /// + /// Initializes a new instance of the IotDpsPropertiesDescription + /// class. + /// + public IotDpsPropertiesDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotDpsPropertiesDescription + /// class. + /// + /// Current state of the provisioning service. + /// Possible values include: 'Activating', 'Active', 'Deleting', + /// 'Deleted', 'ActivationFailed', 'DeletionFailed', 'Transitioning', + /// 'Suspending', 'Suspended', 'Resuming', 'FailingOver', + /// 'FailoverFailed' + /// The encryption properties for the IoT DPS + /// instance. + /// Whether requests from Public + /// Network are allowed. Possible values include: 'Enabled', + /// 'Disabled' + /// The IP filter rules. + /// Private endpoint + /// connections created on this IotHub + /// The ARM provisioning state of the + /// provisioning service. + /// List of IoT hubs associated with this + /// provisioning service. + /// Allocation policy to be used by this + /// provisioning service. Possible values include: 'Hashed', + /// 'GeoLatency', 'Static' + /// Service endpoint for + /// provisioning service. + /// Device endpoint for this + /// provisioning service. + /// Unique identifier of this provisioning + /// service. + /// List of authorization keys for + /// a provisioning service. + public IotDpsPropertiesDescription(string state = default(string), EncryptionPropertiesDescription encryption = default(EncryptionPropertiesDescription), string publicNetworkAccess = default(string), IList ipFilterRules = default(IList), IList privateEndpointConnections = default(IList), string provisioningState = default(string), IList iotHubs = default(IList), string allocationPolicy = default(string), string serviceOperationsHostName = default(string), string deviceProvisioningHostName = default(string), string idScope = default(string), IList authorizationPolicies = default(IList)) + { + State = state; + Encryption = encryption; + PublicNetworkAccess = publicNetworkAccess; + IpFilterRules = ipFilterRules; + PrivateEndpointConnections = privateEndpointConnections; + ProvisioningState = provisioningState; + IotHubs = iotHubs; + AllocationPolicy = allocationPolicy; + ServiceOperationsHostName = serviceOperationsHostName; + DeviceProvisioningHostName = deviceProvisioningHostName; + IdScope = idScope; + AuthorizationPolicies = authorizationPolicies; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets current state of the provisioning service. Possible + /// values include: 'Activating', 'Active', 'Deleting', 'Deleted', + /// 'ActivationFailed', 'DeletionFailed', 'Transitioning', + /// 'Suspending', 'Suspended', 'Resuming', 'FailingOver', + /// 'FailoverFailed' + /// + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + /// + /// Gets or sets the encryption properties for the IoT DPS instance. + /// + [JsonProperty(PropertyName = "encryption")] + public EncryptionPropertiesDescription Encryption { get; set; } + + /// + /// Gets or sets whether requests from Public Network are allowed. + /// Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "publicNetworkAccess")] + public string PublicNetworkAccess { get; set; } + + /// + /// Gets or sets the IP filter rules. + /// + [JsonProperty(PropertyName = "ipFilterRules")] + public IList IpFilterRules { get; set; } + + /// + /// Gets or sets private endpoint connections created on this IotHub + /// + [JsonProperty(PropertyName = "privateEndpointConnections")] + public IList PrivateEndpointConnections { get; set; } + + /// + /// Gets or sets the ARM provisioning state of the provisioning + /// service. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets list of IoT hubs associated with this provisioning + /// service. + /// + [JsonProperty(PropertyName = "iotHubs")] + public IList IotHubs { get; set; } + + /// + /// Gets or sets allocation policy to be used by this provisioning + /// service. Possible values include: 'Hashed', 'GeoLatency', 'Static' + /// + [JsonProperty(PropertyName = "allocationPolicy")] + public string AllocationPolicy { get; set; } + + /// + /// Gets service endpoint for provisioning service. + /// + [JsonProperty(PropertyName = "serviceOperationsHostName")] + public string ServiceOperationsHostName { get; private set; } + + /// + /// Gets device endpoint for this provisioning service. + /// + [JsonProperty(PropertyName = "deviceProvisioningHostName")] + public string DeviceProvisioningHostName { get; private set; } + + /// + /// Gets unique identifier of this provisioning service. + /// + [JsonProperty(PropertyName = "idScope")] + public string IdScope { get; private set; } + + /// + /// Gets or sets list of authorization keys for a provisioning service. + /// + [JsonProperty(PropertyName = "authorizationPolicies")] + public IList AuthorizationPolicies { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSku.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSku.cs new file mode 100644 index 000000000000..1412ef27c11f --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSku.cs @@ -0,0 +1,21 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for IotDpsSku. + /// + public static class IotDpsSku + { + public const string S1 = "S1"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSkuDefinition.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSkuDefinition.cs new file mode 100644 index 000000000000..299b122eaf11 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSkuDefinition.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Available SKUs of tier and units. + /// + public partial class IotDpsSkuDefinition + { + /// + /// Initializes a new instance of the IotDpsSkuDefinition class. + /// + public IotDpsSkuDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotDpsSkuDefinition class. + /// + /// Sku name. Possible values include: 'S1' + public IotDpsSkuDefinition(string name = default(string)) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets sku name. Possible values include: 'S1' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSkuInfo.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSkuInfo.cs new file mode 100644 index 000000000000..2298cbd19cd5 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotDpsSkuInfo.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// List of possible provisioning service SKUs. + /// + public partial class IotDpsSkuInfo + { + /// + /// Initializes a new instance of the IotDpsSkuInfo class. + /// + public IotDpsSkuInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotDpsSkuInfo class. + /// + /// Sku name. Possible values include: 'S1' + /// Pricing tier name of the provisioning + /// service. + /// The number of units to provision + public IotDpsSkuInfo(string name = default(string), string tier = default(string), long? capacity = default(long?)) + { + Name = name; + Tier = tier; + Capacity = capacity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets sku name. Possible values include: 'S1' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets pricing tier name of the provisioning service. + /// + [JsonProperty(PropertyName = "tier")] + public string Tier { get; private set; } + + /// + /// Gets or sets the number of units to provision + /// + [JsonProperty(PropertyName = "capacity")] + public long? Capacity { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotHubDefinitionDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotHubDefinitionDescription.cs new file mode 100644 index 000000000000..d328c788ab5d --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IotHubDefinitionDescription.cs @@ -0,0 +1,89 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Description of the IoT hub. + /// + public partial class IotHubDefinitionDescription + { + /// + /// Initializes a new instance of the IotHubDefinitionDescription + /// class. + /// + public IotHubDefinitionDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IotHubDefinitionDescription + /// class. + /// + /// Connection string of the IoT + /// hub. + /// ARM region of the IoT hub. + /// flag for applying + /// allocationPolicy or not for a given iot hub. + /// weight to apply for a given iot + /// h. + /// Host name of the IoT hub. + public IotHubDefinitionDescription(string connectionString, string location, bool? applyAllocationPolicy = default(bool?), int? allocationWeight = default(int?), string name = default(string)) + { + ApplyAllocationPolicy = applyAllocationPolicy; + AllocationWeight = allocationWeight; + Name = name; + ConnectionString = connectionString; + Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets flag for applying allocationPolicy or not for a given + /// iot hub. + /// + [JsonProperty(PropertyName = "applyAllocationPolicy")] + public bool? ApplyAllocationPolicy { get; set; } + + /// + /// Gets or sets weight to apply for a given iot h. + /// + [JsonProperty(PropertyName = "allocationWeight")] + public int? AllocationWeight { get; set; } + + /// + /// Gets host name of the IoT hub. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets connection string of the IoT hub. + /// + [JsonProperty(PropertyName = "connectionString")] + public string ConnectionString { get; set; } + + /// + /// Gets or sets ARM region of the IoT hub. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterActionType.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterActionType.cs new file mode 100644 index 000000000000..0f5c4363b261 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterActionType.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for IpFilterActionType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum IpFilterActionType + { + [EnumMember(Value = "Accept")] + Accept, + [EnumMember(Value = "Reject")] + Reject + } + internal static class IpFilterActionTypeEnumExtension + { + internal static string ToSerializedValue(this IpFilterActionType? value) + { + return value == null ? null : ((IpFilterActionType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this IpFilterActionType value) + { + switch( value ) + { + case IpFilterActionType.Accept: + return "Accept"; + case IpFilterActionType.Reject: + return "Reject"; + } + return null; + } + + internal static IpFilterActionType? ParseIpFilterActionType(this string value) + { + switch( value ) + { + case "Accept": + return IpFilterActionType.Accept; + case "Reject": + return IpFilterActionType.Reject; + } + return null; + } + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterRule.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterRule.cs new file mode 100644 index 000000000000..6e220800031c --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterRule.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The IP filter rules for a provisioning Service. + /// + public partial class IpFilterRule + { + /// + /// Initializes a new instance of the IpFilterRule class. + /// + public IpFilterRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IpFilterRule class. + /// + /// The name of the IP filter rule. + /// The desired action for requests captured by + /// this rule. Possible values include: 'Accept', 'Reject' + /// A string that contains the IP address range in + /// CIDR notation for the rule. + /// Target for requests captured by this rule. + /// Possible values include: 'all', 'serviceApi', 'deviceApi' + public IpFilterRule(string filterName, IpFilterActionType action, string ipMask, IpFilterTargetType? target = default(IpFilterTargetType?)) + { + FilterName = filterName; + Action = action; + IpMask = ipMask; + Target = target; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the IP filter rule. + /// + [JsonProperty(PropertyName = "filterName")] + public string FilterName { get; set; } + + /// + /// Gets or sets the desired action for requests captured by this rule. + /// Possible values include: 'Accept', 'Reject' + /// + [JsonProperty(PropertyName = "action")] + public IpFilterActionType Action { get; set; } + + /// + /// Gets or sets a string that contains the IP address range in CIDR + /// notation for the rule. + /// + [JsonProperty(PropertyName = "ipMask")] + public string IpMask { get; set; } + + /// + /// Gets or sets target for requests captured by this rule. Possible + /// values include: 'all', 'serviceApi', 'deviceApi' + /// + [JsonProperty(PropertyName = "target")] + public IpFilterTargetType? Target { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterTargetType.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterTargetType.cs new file mode 100644 index 000000000000..83c1487d8f58 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/IpFilterTargetType.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for IpFilterTargetType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum IpFilterTargetType + { + [EnumMember(Value = "all")] + All, + [EnumMember(Value = "serviceApi")] + ServiceApi, + [EnumMember(Value = "deviceApi")] + DeviceApi + } + internal static class IpFilterTargetTypeEnumExtension + { + internal static string ToSerializedValue(this IpFilterTargetType? value) + { + return value == null ? null : ((IpFilterTargetType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this IpFilterTargetType value) + { + switch( value ) + { + case IpFilterTargetType.All: + return "all"; + case IpFilterTargetType.ServiceApi: + return "serviceApi"; + case IpFilterTargetType.DeviceApi: + return "deviceApi"; + } + return null; + } + + internal static IpFilterTargetType? ParseIpFilterTargetType(this string value) + { + switch( value ) + { + case "all": + return IpFilterTargetType.All; + case "serviceApi": + return IpFilterTargetType.ServiceApi; + case "deviceApi": + return IpFilterTargetType.DeviceApi; + } + return null; + } + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/KeyVaultKeyProperties.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/KeyVaultKeyProperties.cs new file mode 100644 index 000000000000..0fac64d27a60 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/KeyVaultKeyProperties.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of the KeyVault key. + /// + public partial class KeyVaultKeyProperties + { + /// + /// Initializes a new instance of the KeyVaultKeyProperties class. + /// + public KeyVaultKeyProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the KeyVaultKeyProperties class. + /// + /// The identifier of the key. + public KeyVaultKeyProperties(string keyIdentifier = default(string)) + { + KeyIdentifier = keyIdentifier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identifier of the key. + /// + [JsonProperty(PropertyName = "keyIdentifier")] + public string KeyIdentifier { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/NameAvailabilityInfo.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/NameAvailabilityInfo.cs new file mode 100644 index 000000000000..51623c28e5b0 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/NameAvailabilityInfo.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Description of name availability. + /// + public partial class NameAvailabilityInfo + { + /// + /// Initializes a new instance of the NameAvailabilityInfo class. + /// + public NameAvailabilityInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NameAvailabilityInfo class. + /// + /// specifies if a name is available or + /// not + /// specifies the reason a name is unavailable. + /// Possible values include: 'Invalid', 'AlreadyExists' + /// message containing a detailed reason name is + /// unavailable + public NameAvailabilityInfo(bool? nameAvailable = default(bool?), string reason = default(string), string message = default(string)) + { + NameAvailable = nameAvailable; + Reason = reason; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets specifies if a name is available or not + /// + [JsonProperty(PropertyName = "nameAvailable")] + public bool? NameAvailable { get; set; } + + /// + /// Gets or sets specifies the reason a name is unavailable. Possible + /// values include: 'Invalid', 'AlreadyExists' + /// + [JsonProperty(PropertyName = "reason")] + public string Reason { get; set; } + + /// + /// Gets or sets message containing a detailed reason name is + /// unavailable + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/NameUnavailabilityReason.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/NameUnavailabilityReason.cs new file mode 100644 index 000000000000..e81ab9e6f9b7 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/NameUnavailabilityReason.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.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for NameUnavailabilityReason. + /// + public static class NameUnavailabilityReason + { + public const string Invalid = "Invalid"; + public const string AlreadyExists = "AlreadyExists"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Operation.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..55bee1d88311 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Operation.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Provisioning Service REST API operation. + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + /// Operation name: {provider}/{resource}/{read | + /// write | action | delete} + /// The object that represents the + /// operation. + public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay)) + { + Name = name; + Display = display; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets operation name: {provider}/{resource}/{read | write | action | + /// delete} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the object that represents the operation. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/OperationDisplay.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..7dc145ee72e5 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The object that represents 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. + /// + /// Service provider: Microsoft Devices. + /// Resource Type: ProvisioningServices. + /// Name of the operation. + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets service provider: Microsoft Devices. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; private set; } + + /// + /// Gets resource Type: ProvisioningServices. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; private set; } + + /// + /// Gets name of the operation. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; private set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/OperationInputs.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/OperationInputs.cs new file mode 100644 index 000000000000..42e998850135 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/OperationInputs.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Input values for operation results call. + /// + public partial class OperationInputs + { + /// + /// Initializes a new instance of the OperationInputs class. + /// + public OperationInputs() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationInputs class. + /// + /// The name of the Provisioning Service to + /// check. + public OperationInputs(string name) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the Provisioning Service to check. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Page.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..42a8f2c3653e --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/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.DeviceProvisioningServices.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/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpoint.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpoint.cs new file mode 100644 index 000000000000..9c58ab9ec9d4 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpoint.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The private endpoint property of a private endpoint connection + /// + public partial class PrivateEndpoint + { + /// + /// Initializes a new instance of the PrivateEndpoint class. + /// + public PrivateEndpoint() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpoint class. + /// + /// The resource identifier. + public PrivateEndpoint(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the resource identifier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpointConnection.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpointConnection.cs new file mode 100644 index 000000000000..c4613dc66ec1 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpointConnection.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.DeviceProvisioningServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The private endpoint connection of a provisioning service + /// + public partial class PrivateEndpointConnection : IResource + { + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + public PrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + /// The properties of a private endpoint + /// connection + /// The resource identifier. + /// The resource name. + /// The resource type. + public PrivateEndpointConnection(PrivateEndpointConnectionProperties properties, string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the resource identifier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the properties of a private endpoint connection + /// + [JsonProperty(PropertyName = "properties")] + public PrivateEndpointConnectionProperties Properties { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpointConnectionProperties.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpointConnectionProperties.cs new file mode 100644 index 000000000000..9a57871ec072 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateEndpointConnectionProperties.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties of a private endpoint connection + /// + public partial class PrivateEndpointConnectionProperties + { + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionProperties class. + /// + public PrivateEndpointConnectionProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PrivateEndpointConnectionProperties class. + /// + /// The current state + /// of a private endpoint connection + /// The private endpoint property of a + /// private endpoint connection + public PrivateEndpointConnectionProperties(PrivateLinkServiceConnectionState privateLinkServiceConnectionState, PrivateEndpoint privateEndpoint = default(PrivateEndpoint)) + { + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the private endpoint property of a private endpoint + /// connection + /// + [JsonProperty(PropertyName = "privateEndpoint")] + public PrivateEndpoint PrivateEndpoint { get; set; } + + /// + /// Gets or sets the current state of a private endpoint connection + /// + [JsonProperty(PropertyName = "privateLinkServiceConnectionState")] + public PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkResources.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkResources.cs new file mode 100644 index 000000000000..6a8fa45ae411 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkResources.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The available private link resources for a provisioning service + /// + public partial class PrivateLinkResources + { + /// + /// Initializes a new instance of the PrivateLinkResources class. + /// + public PrivateLinkResources() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkResources class. + /// + /// The list of available private link resources + /// for a provisioning service + public PrivateLinkResources(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of available private link resources for a + /// provisioning service + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkServiceConnectionState.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkServiceConnectionState.cs new file mode 100644 index 000000000000..7df8a83c4046 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkServiceConnectionState.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The current state of a private endpoint connection + /// + public partial class PrivateLinkServiceConnectionState + { + /// + /// Initializes a new instance of the PrivateLinkServiceConnectionState + /// class. + /// + public PrivateLinkServiceConnectionState() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkServiceConnectionState + /// class. + /// + /// The status of a private endpoint connection. + /// Possible values include: 'Pending', 'Approved', 'Rejected', + /// 'Disconnected' + /// The description for the current state of + /// a private endpoint connection + /// Actions required for a private + /// endpoint connection + public PrivateLinkServiceConnectionState(string status, string description, string actionsRequired = default(string)) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the status of a private endpoint connection. Possible + /// values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the description for the current state of a private + /// endpoint connection + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets actions required for a private endpoint connection + /// + [JsonProperty(PropertyName = "actionsRequired")] + public string ActionsRequired { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkServiceConnectionStatus.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkServiceConnectionStatus.cs new file mode 100644 index 000000000000..93b56e6a613e --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PrivateLinkServiceConnectionStatus.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.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for PrivateLinkServiceConnectionStatus. + /// + public static class PrivateLinkServiceConnectionStatus + { + public const string Pending = "Pending"; + public const string Approved = "Approved"; + public const string Rejected = "Rejected"; + public const string Disconnected = "Disconnected"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ProvisioningServiceDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ProvisioningServiceDescription.cs new file mode 100644 index 000000000000..720572fe0c23 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/ProvisioningServiceDescription.cs @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The description of the provisioning service. + /// + public partial class ProvisioningServiceDescription : Resource + { + /// + /// Initializes a new instance of the ProvisioningServiceDescription + /// class. + /// + public ProvisioningServiceDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProvisioningServiceDescription + /// class. + /// + /// The resource location. + /// Service specific properties for a + /// provisioning service + /// Sku info for a provisioning Service. + /// The resource identifier. + /// The resource name. + /// The resource type. + /// The resource tags. + /// The Etag field is *not* required. If it is + /// provided in the response body, it must also be provided as a header + /// per the normal ETag convention. + /// The managed identities for the IotDps + /// instance. + public ProvisioningServiceDescription(string location, IotDpsPropertiesDescription properties, IotDpsSkuInfo sku, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string etag = default(string), ArmIdentity identity = default(ArmIdentity)) + : base(location, id, name, type, tags) + { + Etag = etag; + Properties = properties; + Sku = sku; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Etag field is *not* required. If it is provided in + /// the response body, it must also be provided as a header per the + /// normal ETag convention. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; set; } + + /// + /// Gets or sets service specific properties for a provisioning service + /// + [JsonProperty(PropertyName = "properties")] + public IotDpsPropertiesDescription Properties { get; set; } + + /// + /// Gets or sets sku info for a provisioning Service. + /// + [JsonProperty(PropertyName = "sku")] + public IotDpsSkuInfo Sku { get; set; } + + /// + /// Gets or sets the managed identities for the IotDps instance. + /// + [JsonProperty(PropertyName = "identity")] + public ArmIdentity Identity { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PublicNetworkAccess.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PublicNetworkAccess.cs new file mode 100644 index 000000000000..d8bddf61b0b3 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/PublicNetworkAccess.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.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for PublicNetworkAccess. + /// + public static class PublicNetworkAccess + { + public const string Enabled = "Enabled"; + public const string Disabled = "Disabled"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Resource.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Resource.cs new file mode 100644 index 000000000000..f5781b1f5f02 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/Resource.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.DeviceProvisioningServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The common properties of an Azure resource. + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// The resource location. + /// The resource identifier. + /// The resource name. + /// The resource type. + /// The resource tags. + public Resource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the resource identifier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the resource name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the resource location. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the resource tags. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/SharedAccessSignatureAuthorizationRuleAccessRightsDescription.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/SharedAccessSignatureAuthorizationRuleAccessRightsDescription.cs new file mode 100644 index 000000000000..3d8c0261747f --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/SharedAccessSignatureAuthorizationRuleAccessRightsDescription.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Description of the shared access key. + /// + public partial class SharedAccessSignatureAuthorizationRuleAccessRightsDescription + { + /// + /// Initializes a new instance of the + /// SharedAccessSignatureAuthorizationRuleAccessRightsDescription + /// class. + /// + public SharedAccessSignatureAuthorizationRuleAccessRightsDescription() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SharedAccessSignatureAuthorizationRuleAccessRightsDescription + /// class. + /// + /// Name of the key. + /// Rights that this key has. Possible values + /// include: 'ServiceConfig', 'EnrollmentRead', 'EnrollmentWrite', + /// 'DeviceConnect', 'RegistrationStatusRead', + /// 'RegistrationStatusWrite' + /// Primary SAS key value. + /// Secondary SAS key value. + public SharedAccessSignatureAuthorizationRuleAccessRightsDescription(string keyName, string rights, string primaryKey = default(string), string secondaryKey = default(string)) + { + KeyName = keyName; + PrimaryKey = primaryKey; + SecondaryKey = secondaryKey; + Rights = rights; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the key. + /// + [JsonProperty(PropertyName = "keyName")] + public string KeyName { get; set; } + + /// + /// Gets or sets primary SAS key value. + /// + [JsonProperty(PropertyName = "primaryKey")] + public string PrimaryKey { get; set; } + + /// + /// Gets or sets secondary SAS key value. + /// + [JsonProperty(PropertyName = "secondaryKey")] + public string SecondaryKey { get; set; } + + /// + /// Gets or sets rights that this key has. Possible values include: + /// 'ServiceConfig', 'EnrollmentRead', 'EnrollmentWrite', + /// 'DeviceConnect', 'RegistrationStatusRead', + /// 'RegistrationStatusWrite' + /// + [JsonProperty(PropertyName = "rights")] + public string Rights { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/State.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/State.cs new file mode 100644 index 000000000000..4cb71e5ec2f0 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/State.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + + /// + /// Defines values for State. + /// + public static class State + { + public const string Activating = "Activating"; + public const string Active = "Active"; + public const string Deleting = "Deleting"; + public const string Deleted = "Deleted"; + public const string ActivationFailed = "ActivationFailed"; + public const string DeletionFailed = "DeletionFailed"; + public const string Transitioning = "Transitioning"; + public const string Suspending = "Suspending"; + public const string Suspended = "Suspended"; + public const string Resuming = "Resuming"; + public const string FailingOver = "FailingOver"; + public const string FailoverFailed = "FailoverFailed"; + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/TagsResource.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/TagsResource.cs new file mode 100644 index 000000000000..3e7e12667151 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/TagsResource.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A container holding only the Tags for a resource, allowing the user to + /// update the tags on a Provisioning Service instance. + /// + public partial class TagsResource + { + /// + /// Initializes a new instance of the TagsResource class. + /// + public TagsResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagsResource class. + /// + /// Resource tags + public TagsResource(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/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeRequest.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeRequest.cs new file mode 100644 index 000000000000..2a7f21b9dfdb --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeRequest.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.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The JSON-serialized leaf certificate + /// + public partial class VerificationCodeRequest + { + /// + /// Initializes a new instance of the VerificationCodeRequest class. + /// + public VerificationCodeRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VerificationCodeRequest class. + /// + /// base-64 representation of X509 + /// certificate .cer file or just .pem file content. + public VerificationCodeRequest(string certificate = default(string)) + { + Certificate = certificate; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets base-64 representation of X509 certificate .cer file + /// or just .pem file content. + /// + [JsonProperty(PropertyName = "certificate")] + public string Certificate { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeResponse.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeResponse.cs new file mode 100644 index 000000000000..dada77807da1 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeResponse.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Description of the response of the verification code. + /// + public partial class VerificationCodeResponse : IResource + { + /// + /// Initializes a new instance of the VerificationCodeResponse class. + /// + public VerificationCodeResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VerificationCodeResponse class. + /// + /// Name of certificate. + /// Request etag. + /// The resource identifier. + /// The resource type. + public VerificationCodeResponse(string name = default(string), string etag = default(string), string id = default(string), string type = default(string), VerificationCodeResponseProperties properties = default(VerificationCodeResponseProperties)) + { + Name = name; + Etag = etag; + Id = id; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets name of certificate. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets request etag. + /// + [JsonProperty(PropertyName = "etag")] + public string Etag { get; private set; } + + /// + /// Gets the resource identifier. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the resource type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// + [JsonProperty(PropertyName = "properties")] + public VerificationCodeResponseProperties Properties { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeResponseProperties.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeResponseProperties.cs new file mode 100644 index 000000000000..e92b0961607e --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Models/VerificationCodeResponseProperties.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + public partial class VerificationCodeResponseProperties + { + /// + /// Initializes a new instance of the + /// VerificationCodeResponseProperties class. + /// + public VerificationCodeResponseProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// VerificationCodeResponseProperties class. + /// + /// Verification code. + /// Certificate subject. + /// Code expiry. + /// Certificate thumbprint. + /// Indicate if the certificate is verified by + /// owner of private key. + /// Certificate created time. + /// Certificate updated time. + public VerificationCodeResponseProperties(string verificationCode = default(string), string subject = default(string), string expiry = default(string), string thumbprint = default(string), bool? isVerified = default(bool?), string created = default(string), string updated = default(string)) + { + VerificationCode = verificationCode; + Subject = subject; + Expiry = expiry; + Thumbprint = thumbprint; + IsVerified = isVerified; + Created = created; + Updated = updated; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets verification code. + /// + [JsonProperty(PropertyName = "verificationCode")] + public string VerificationCode { get; set; } + + /// + /// Gets or sets certificate subject. + /// + [JsonProperty(PropertyName = "subject")] + public string Subject { get; set; } + + /// + /// Gets or sets code expiry. + /// + [JsonProperty(PropertyName = "expiry")] + public string Expiry { get; set; } + + /// + /// Gets or sets certificate thumbprint. + /// + [JsonProperty(PropertyName = "thumbprint")] + public string Thumbprint { get; set; } + + /// + /// Gets or sets indicate if the certificate is verified by owner of + /// private key. + /// + [JsonProperty(PropertyName = "isVerified")] + public bool? IsVerified { get; set; } + + /// + /// Gets or sets certificate created time. + /// + [JsonProperty(PropertyName = "created")] + public string Created { get; set; } + + /// + /// Gets or sets certificate updated time. + /// + [JsonProperty(PropertyName = "updated")] + public string Updated { get; set; } + + } +} diff --git a/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Operations.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/Operations.cs new file mode 100644 index 000000000000..d667cdd721bc --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/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.DeviceProvisioningServices +{ + 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(IotDpsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the IotDpsClient + /// + public IotDpsClient Client { get; private set; } + + /// + /// Lists all of the available Microsoft.Devices REST API 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.Devices/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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the available Microsoft.Devices REST API 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 ErrorDetailsException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorDetails _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/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/OperationsExtensions.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..572ac046cfb3 --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/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.DeviceProvisioningServices +{ + 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 + { + /// + /// Lists all of the available Microsoft.Devices REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Microsoft.Devices REST API 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; + } + } + + /// + /// Lists all of the available Microsoft.Devices REST API 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(); + } + + /// + /// Lists all of the available Microsoft.Devices REST API 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/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/SdkInfo_iotDpsClient.cs b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/SdkInfo_iotDpsClient.cs new file mode 100644 index 000000000000..89d19d0a718b --- /dev/null +++ b/sdk/deviceprovisioningservcies/Management.Azure.Management.DeviceProvisioningServcies/src/Generated/SdkInfo_iotDpsClient.cs @@ -0,0 +1,29 @@ + +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.DeviceProvisioningServices +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_iotDpsClient + { + get + { + return new Tuple[] + { + new Tuple("Devices", "DpsCertificate", "2020-09-01-preview"), + new Tuple("Devices", "IotDpsResource", "2020-09-01-preview"), + new Tuple("Devices", "Operations", "2020-09-01-preview"), + }.AsEnumerable(); + } + } + } +}