Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Cognitive Services SDK to 7.0 #9177

Merged
merged 2 commits into from Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions eng/mgmt/mgmtmetadata/cognitiveservices_resource-manager.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Installing AutoRest version: latest
AutoRest installed successfully.
Commencing code generation
Generating CSharp code
Executing AutoRest command
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\sdk
2019-12-17 21:52:50 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 1016fa552ce1db3c857344179dbca2518de290d0
AutoRest information
Requested version: latest
Bootstrapper version: autorest@2.0.4407
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
/// <param name='accountName'>
/// The name of Cognitive Services account.
/// </param>
/// <param name='parameters'>
/// <param name='account'>
/// The parameters to provide for the created account.
/// </param>
/// <param name='customHeaders'>
Expand All @@ -85,7 +85,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<CognitiveServicesAccount>> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, CognitiveServicesAccountCreateParameters parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<CognitiveServicesAccount>> CreateWithHttpMessagesAsync(string resourceGroupName, string accountName, CognitiveServicesAccount account, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (resourceGroupName == null)
{
Expand All @@ -110,13 +110,13 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-zA-Z0-9][a-zA-Z0-9_.-]*$");
}
}
if (parameters == null)
if (account == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
throw new ValidationException(ValidationRules.CannotBeNull, "account");
}
if (parameters != null)
if (account != null)
{
parameters.Validate();
account.Validate();
}
if (Client.ApiVersion == null)
{
Expand All @@ -135,7 +135,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("resourceGroupName", resourceGroupName);
tracingParameters.Add("accountName", accountName);
tracingParameters.Add("parameters", parameters);
tracingParameters.Add("account", account);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
}
Expand Down Expand Up @@ -188,9 +188,9 @@ internal AccountsOperations(CognitiveServicesManagementClient client)

// Serialize Request
string _requestContent = null;
if(parameters != null)
if(account != null)
{
_requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings);
_requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(account, 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");
}
Expand All @@ -214,7 +214,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 200 && (int)_statusCode != 201)
if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202)
{
var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
try
Expand Down Expand Up @@ -287,6 +287,24 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
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<CognitiveServicesAccount>(_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);
Expand All @@ -303,18 +321,8 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
/// <param name='accountName'>
/// The name of Cognitive Services account.
/// </param>
/// <param name='sku'>
/// Gets or sets the SKU of the resource.
/// </param>
/// <param name='tags'>
/// Gets or sets a list of key value pairs that describe the resource. These
/// tags can be used in viewing and grouping this resource (across resource
/// groups). A maximum of 15 tags can be provided for a resource. Each tag must
/// have a key no greater than 128 characters and value no greater than 256
/// characters.
/// </param>
/// <param name='properties'>
/// Additional properties for Account. Only provided fields will be updated.
/// <param name='account'>
/// The parameters to provide for the created account.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
Expand All @@ -337,7 +345,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<CognitiveServicesAccount>> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, Sku sku = default(Sku), IDictionary<string, string> tags = default(IDictionary<string, string>), object properties = default(object), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<CognitiveServicesAccount>> UpdateWithHttpMessagesAsync(string resourceGroupName, string accountName, CognitiveServicesAccount account, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (resourceGroupName == null)
{
Expand All @@ -362,6 +370,10 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
throw new ValidationException(ValidationRules.Pattern, "accountName", "^[a-zA-Z0-9][a-zA-Z0-9_.-]*$");
}
}
if (account == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "account");
}
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
Expand All @@ -370,17 +382,6 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
}
if (sku != null)
{
sku.Validate();
}
CognitiveServicesAccountUpdateParameters parameters = new CognitiveServicesAccountUpdateParameters();
if (sku != null || tags != null || properties != null)
{
parameters.Sku = sku;
parameters.Tags = tags;
parameters.Properties = properties;
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
Expand All @@ -390,7 +391,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("resourceGroupName", resourceGroupName);
tracingParameters.Add("accountName", accountName);
tracingParameters.Add("parameters", parameters);
tracingParameters.Add("account", account);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
}
Expand Down Expand Up @@ -443,9 +444,9 @@ internal AccountsOperations(CognitiveServicesManagementClient client)

// Serialize Request
string _requestContent = null;
if(parameters != null)
if(account != null)
{
_requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings);
_requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(account, 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");
}
Expand All @@ -469,7 +470,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 200)
if ((int)_statusCode != 200 && (int)_statusCode != 202)
{
var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
try
Expand Down Expand Up @@ -524,6 +525,24 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
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<CognitiveServicesAccount>(_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);
Expand Down Expand Up @@ -672,7 +691,7 @@ internal AccountsOperations(CognitiveServicesManagementClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 200 && (int)_statusCode != 204)
if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204)
{
var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ 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;

Expand All @@ -37,12 +35,12 @@ public static partial class AccountsOperationsExtensions
/// <param name='accountName'>
/// The name of Cognitive Services account.
/// </param>
/// <param name='parameters'>
/// <param name='account'>
/// The parameters to provide for the created account.
/// </param>
public static CognitiveServicesAccount Create(this IAccountsOperations operations, string resourceGroupName, string accountName, CognitiveServicesAccountCreateParameters parameters)
public static CognitiveServicesAccount Create(this IAccountsOperations operations, string resourceGroupName, string accountName, CognitiveServicesAccount account)
{
return operations.CreateAsync(resourceGroupName, accountName, parameters).GetAwaiter().GetResult();
return operations.CreateAsync(resourceGroupName, accountName, account).GetAwaiter().GetResult();
}

/// <summary>
Expand All @@ -59,15 +57,15 @@ public static CognitiveServicesAccount Create(this IAccountsOperations operation
/// <param name='accountName'>
/// The name of Cognitive Services account.
/// </param>
/// <param name='parameters'>
/// <param name='account'>
/// The parameters to provide for the created account.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<CognitiveServicesAccount> CreateAsync(this IAccountsOperations operations, string resourceGroupName, string accountName, CognitiveServicesAccountCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<CognitiveServicesAccount> CreateAsync(this IAccountsOperations operations, string resourceGroupName, string accountName, CognitiveServicesAccount account, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, accountName, account, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand All @@ -85,22 +83,12 @@ public static CognitiveServicesAccount Create(this IAccountsOperations operation
/// <param name='accountName'>
/// The name of Cognitive Services account.
/// </param>
/// <param name='sku'>
/// Gets or sets the SKU of the resource.
/// </param>
/// <param name='tags'>
/// Gets or sets a list of key value pairs that describe the resource. These
/// tags can be used in viewing and grouping this resource (across resource
/// groups). A maximum of 15 tags can be provided for a resource. Each tag must
/// have a key no greater than 128 characters and value no greater than 256
/// characters.
/// </param>
/// <param name='properties'>
/// Additional properties for Account. Only provided fields will be updated.
/// <param name='account'>
/// The parameters to provide for the created account.
/// </param>
public static CognitiveServicesAccount Update(this IAccountsOperations operations, string resourceGroupName, string accountName, Sku sku = default(Sku), IDictionary<string, string> tags = default(IDictionary<string, string>), object properties = default(object))
public static CognitiveServicesAccount Update(this IAccountsOperations operations, string resourceGroupName, string accountName, CognitiveServicesAccount account)
{
return operations.UpdateAsync(resourceGroupName, accountName, sku, tags, properties).GetAwaiter().GetResult();
return operations.UpdateAsync(resourceGroupName, accountName, account).GetAwaiter().GetResult();
}

/// <summary>
Expand All @@ -115,25 +103,15 @@ public static CognitiveServicesAccount Create(this IAccountsOperations operation
/// <param name='accountName'>
/// The name of Cognitive Services account.
/// </param>
/// <param name='sku'>
/// Gets or sets the SKU of the resource.
/// </param>
/// <param name='tags'>
/// Gets or sets a list of key value pairs that describe the resource. These
/// tags can be used in viewing and grouping this resource (across resource
/// groups). A maximum of 15 tags can be provided for a resource. Each tag must
/// have a key no greater than 128 characters and value no greater than 256
/// characters.
/// </param>
/// <param name='properties'>
/// Additional properties for Account. Only provided fields will be updated.
/// <param name='account'>
/// The parameters to provide for the created account.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<CognitiveServicesAccount> UpdateAsync(this IAccountsOperations operations, string resourceGroupName, string accountName, Sku sku = default(Sku), IDictionary<string, string> tags = default(IDictionary<string, string>), object properties = default(object), CancellationToken cancellationToken = default(CancellationToken))
public static async Task<CognitiveServicesAccount> UpdateAsync(this IAccountsOperations operations, string resourceGroupName, string accountName, CognitiveServicesAccount account, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, sku, tags, properties, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, account, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand Down
Loading