diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/CognitiveServicesManagementClient.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/CognitiveServicesManagementClient.cs index 7faff410cf95..5b86b76f5ae7 100644 --- a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/CognitiveServicesManagementClient.cs +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/CognitiveServicesManagementClient.cs @@ -95,6 +95,11 @@ public partial class CognitiveServicesManagementClient : ServiceClient public virtual ICheckSkuAvailabilityOperations CheckSkuAvailability { get; private set; } + /// + /// Gets the ILocationsOperations. + /// + public virtual ILocationsOperations Locations { get; private set; } + /// /// Initializes a new instance of the CognitiveServicesManagementClient class. /// @@ -340,6 +345,7 @@ private void Initialize() ResourceSkus = new ResourceSkusOperations(this); Operations = new Operations(this); CheckSkuAvailability = new CheckSkuAvailabilityOperations(this); + Locations = new LocationsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); ApiVersion = "2017-04-18"; AcceptLanguage = "en-US"; diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/ICognitiveServicesManagementClient.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/ICognitiveServicesManagementClient.cs index 6e897bac33a1..7ca9cd3b8720 100644 --- a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/ICognitiveServicesManagementClient.cs +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/ICognitiveServicesManagementClient.cs @@ -90,5 +90,10 @@ public partial interface ICognitiveServicesManagementClient : System.IDisposable /// ICheckSkuAvailabilityOperations CheckSkuAvailability { get; } + /// + /// Gets the ILocationsOperations. + /// + ILocationsOperations Locations { get; } + } } diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/ILocationsOperations.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/ILocationsOperations.cs new file mode 100644 index 000000000000..0bdb7caf7212 --- /dev/null +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/ILocationsOperations.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.CognitiveServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LocationsOperations operations. + /// + public partial interface ILocationsOperations + { + /// + /// Check available SKUs. + /// + /// + /// Resource location. + /// + /// + /// The subdomain name to use. + /// + /// + /// The Type of the 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> CheckDomainAvailabilityPostWithHttpMessagesAsync(string location, string subdomainName, string type, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/LocationsOperations.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/LocationsOperations.cs new file mode 100644 index 000000000000..7a64df9d7b13 --- /dev/null +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/LocationsOperations.cs @@ -0,0 +1,268 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CognitiveServices +{ + 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; + + /// + /// LocationsOperations operations. + /// + internal partial class LocationsOperations : IServiceOperations, ILocationsOperations + { + /// + /// Initializes a new instance of the LocationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LocationsOperations(CognitiveServicesManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the CognitiveServicesManagementClient + /// + public CognitiveServicesManagementClient Client { get; private set; } + + /// + /// Check available SKUs. + /// + /// + /// Resource location. + /// + /// + /// The subdomain name to use. + /// + /// + /// The Type of the 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> CheckDomainAvailabilityPostWithHttpMessagesAsync(string location, string subdomainName, string type, 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 (location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "location"); + } + if (subdomainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subdomainName"); + } + if (type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "type"); + } + CheckDomainAvailabilityParameter parameters = new CheckDomainAvailabilityParameter(); + if (subdomainName != null || type != null) + { + parameters.SubdomainName = subdomainName; + parameters.Type = type; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("location", location); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckDomainAvailabilityPost", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkDomainAvailability").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{location}", System.Uri.EscapeDataString(location)); + 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(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/LocationsOperationsExtensions.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/LocationsOperationsExtensions.cs new file mode 100644 index 000000000000..3bb9c757e056 --- /dev/null +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/LocationsOperationsExtensions.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CognitiveServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LocationsOperations. + /// + public static partial class LocationsOperationsExtensions + { + /// + /// Check available SKUs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource location. + /// + /// + /// The subdomain name to use. + /// + /// + /// The Type of the resource. + /// + public static CheckDomainAvailabilityResult CheckDomainAvailabilityPost(this ILocationsOperations operations, string location, string subdomainName, string type) + { + return operations.CheckDomainAvailabilityPostAsync(location, subdomainName, type).GetAwaiter().GetResult(); + } + + /// + /// Check available SKUs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Resource location. + /// + /// + /// The subdomain name to use. + /// + /// + /// The Type of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task CheckDomainAvailabilityPostAsync(this ILocationsOperations operations, string location, string subdomainName, string type, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckDomainAvailabilityPostWithHttpMessagesAsync(location, subdomainName, type, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CheckDomainAvailabilityParameter.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CheckDomainAvailabilityParameter.cs new file mode 100644 index 000000000000..2fc0681513a9 --- /dev/null +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CheckDomainAvailabilityParameter.cs @@ -0,0 +1,79 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.CognitiveServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Check Domain availability parameter. + /// + public partial class CheckDomainAvailabilityParameter + { + /// + /// Initializes a new instance of the CheckDomainAvailabilityParameter + /// class. + /// + public CheckDomainAvailabilityParameter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckDomainAvailabilityParameter + /// class. + /// + /// The subdomain name to use. + /// The Type of the resource. + public CheckDomainAvailabilityParameter(string subdomainName, string type) + { + SubdomainName = subdomainName; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the subdomain name to use. + /// + [JsonProperty(PropertyName = "subdomainName")] + public string SubdomainName { get; set; } + + /// + /// Gets or sets the Type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SubdomainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "SubdomainName"); + } + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + } + } +} diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CheckDomainAvailabilityResult.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CheckDomainAvailabilityResult.cs new file mode 100644 index 000000000000..7582f4616c84 --- /dev/null +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CheckDomainAvailabilityResult.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.CognitiveServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Check Domain availability result. + /// + public partial class CheckDomainAvailabilityResult + { + /// + /// Initializes a new instance of the CheckDomainAvailabilityResult + /// class. + /// + public CheckDomainAvailabilityResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckDomainAvailabilityResult + /// class. + /// + /// Indicates the given SKU is + /// available or not. + /// Reason why the SKU is not available. + /// The subdomain name to use. + /// The Type of the resource. + public CheckDomainAvailabilityResult(bool? isSubdomainAvailable = default(bool?), string reason = default(string), string subdomainName = default(string), string type = default(string)) + { + IsSubdomainAvailable = isSubdomainAvailable; + Reason = reason; + SubdomainName = subdomainName; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates the given SKU is available or not. + /// + [JsonProperty(PropertyName = "isSubdomainAvailable")] + public bool? IsSubdomainAvailable { get; set; } + + /// + /// Gets or sets reason why the SKU is not available. + /// + [JsonProperty(PropertyName = "reason")] + public string Reason { get; set; } + + /// + /// Gets or sets the subdomain name to use. + /// + [JsonProperty(PropertyName = "subdomainName")] + public string SubdomainName { get; set; } + + /// + /// Gets or sets the Type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CognitiveServicesAccount.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CognitiveServicesAccount.cs index 62feef2b340a..2a060e0925bc 100644 --- a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CognitiveServicesAccount.cs +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/Models/CognitiveServicesAccount.cs @@ -47,6 +47,8 @@ public CognitiveServicesAccount() /// 'Succeeded', 'Failed' /// Endpoint of the created account. /// The internal identifier. + /// Optional subdomain name used for + /// token-based authentication. /// The SKU of Cognitive Services account. /// Gets or sets a list of key value pairs that /// describe the resource. These tags can be used in viewing and @@ -55,7 +57,7 @@ public CognitiveServicesAccount() /// greater than 128 characters and value no greater than 256 /// characters. /// Resource type - public CognitiveServicesAccount(string etag = default(string), string id = default(string), string kind = default(string), string location = default(string), string name = default(string), string provisioningState = default(string), string endpoint = default(string), string internalId = default(string), Sku sku = default(Sku), IDictionary tags = default(IDictionary), string type = default(string)) + public CognitiveServicesAccount(string etag = default(string), string id = default(string), string kind = default(string), string location = default(string), string name = default(string), string provisioningState = default(string), string endpoint = default(string), string internalId = default(string), string customSubDomainName = default(string), Sku sku = default(Sku), IDictionary tags = default(IDictionary), string type = default(string)) { Etag = etag; Id = id; @@ -65,6 +67,7 @@ public CognitiveServicesAccount() ProvisioningState = provisioningState; Endpoint = endpoint; InternalId = internalId; + CustomSubDomainName = customSubDomainName; Sku = sku; Tags = tags; Type = type; @@ -126,6 +129,13 @@ public CognitiveServicesAccount() [JsonProperty(PropertyName = "properties.internalId")] public string InternalId { get; set; } + /// + /// Gets or sets optional subdomain name used for token-based + /// authentication. + /// + [JsonProperty(PropertyName = "properties.customSubDomainName")] + public string CustomSubDomainName { get; set; } + /// /// Gets or sets the SKU of Cognitive Services account. /// diff --git a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/SdkInfo_CognitiveServicesManagementClient.cs b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/SdkInfo_CognitiveServicesManagementClient.cs index 4f78150a3d41..9289f2b5a7dc 100644 --- a/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/SdkInfo_CognitiveServicesManagementClient.cs +++ b/src/SDKs/CognitiveServices/management/Management.CognitiveServices/Generated/SdkInfo_CognitiveServicesManagementClient.cs @@ -21,21 +21,11 @@ public static IEnumerable> ApiInfo_CognitiveServic { new Tuple("CognitiveServices", "Accounts", "2017-04-18"), new Tuple("CognitiveServices", "CheckSkuAvailability", "2017-04-18"), + new Tuple("CognitiveServices", "Locations", "2017-04-18"), new Tuple("CognitiveServices", "Operations", "2017-04-18"), new Tuple("CognitiveServices", "ResourceSkus", "2017-04-18"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "latest"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4283"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/cognitiveservices/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=D:\\Github\\azure-sdk-for-net\\src\\SDKs"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "a5fd13fd813e416fc4500310537491482ad401b3"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } -