Skip to content

Commit

Permalink
Update Text Analytics C# SDK auto-generated code.
Browse files Browse the repository at this point in the history
Update Text Analytics C# SDK auto-generated code.
  • Loading branch information
dsgouda authored Jul 27, 2018
2 parents 26d1c8c + 35bf218 commit 02cf21e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ namespace Language.Tests
public abstract class BaseTests
{
public static bool IsTestTenant = false;
// BaseEndpoint only contains protocol and hostname
private static string BaseEndpoint = "https://westus.api.cognitive.microsoft.com";
private static string SubscriptionKey = "000";

protected ITextAnalyticsClient GetClient(DelegatingHandler handler)
{
return new TextAnalyticsClient(new ApiKeyServiceClientCredentials(SubscriptionKey), handlers: handler);
return new TextAnalyticsClient(new ApiKeyServiceClientCredentials(SubscriptionKey), handlers: handler)
{
Endpoint = BaseEndpoint
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public partial interface ITextAnalyticsClient : System.IDisposable
/// <summary>
/// The base URI of the service.
/// </summary>
System.Uri BaseUri { get; set; }

/// <summary>
/// Gets or sets json serialization settings.
Expand All @@ -45,6 +44,12 @@ public partial interface ITextAnalyticsClient : System.IDisposable
/// </summary>
JsonSerializerSettings DeserializationSettings { get; }

/// <summary>
/// Supported Cognitive Services endpoints (protocol and hostname, for
/// example: https://westus.api.cognitive.microsoft.com).
/// </summary>
string Endpoint { get; set; }

/// <summary>
/// Subscription credentials which uniquely identify client
/// subscription.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public partial class TextAnalyticsClient : ServiceClient<TextAnalyticsClient>, I
/// <summary>
/// The base URI of the service.
/// </summary>
public System.Uri BaseUri { get; set; }
internal string BaseUri {get; set;}

/// <summary>
/// Gets or sets json serialization settings.
Expand All @@ -48,6 +48,12 @@ public partial class TextAnalyticsClient : ServiceClient<TextAnalyticsClient>, I
/// </summary>
public JsonSerializerSettings DeserializationSettings { get; private set; }

/// <summary>
/// Supported Cognitive Services endpoints (protocol and hostname, for example:
/// https://westus.api.cognitive.microsoft.com).
/// </summary>
public string Endpoint { get; set; }

/// <summary>
/// Subscription credentials which uniquely identify client subscription.
/// </summary>
Expand Down Expand Up @@ -78,51 +84,6 @@ protected TextAnalyticsClient(HttpClientHandler rootHandler, params DelegatingHa
Initialize();
}

/// <summary>
/// Initializes a new instance of the TextAnalyticsClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected TextAnalyticsClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}

/// <summary>
/// Initializes a new instance of the TextAnalyticsClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected TextAnalyticsClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
{
if (baseUri == null)
{
throw new System.ArgumentNullException("baseUri");
}
BaseUri = baseUri;
}

/// <summary>
/// Initializes a new instance of the TextAnalyticsClient class.
/// </summary>
Expand Down Expand Up @@ -176,75 +137,6 @@ public TextAnalyticsClient(ServiceClientCredentials credentials, HttpClientHandl
}
}

/// <summary>
/// Initializes a new instance of the TextAnalyticsClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public TextAnalyticsClient(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);
}
}

/// <summary>
/// Initializes a new instance of the TextAnalyticsClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
/// </param>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
/// </param>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public TextAnalyticsClient(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);
}
}

/// <summary>
/// An optional partial-method to perform custom initialization.
///</summary>
Expand All @@ -254,7 +146,7 @@ public TextAnalyticsClient(System.Uri baseUri, ServiceClientCredentials credenti
/// </summary>
private void Initialize()
{
BaseUri = new System.Uri("https://api.cognitive.microsoft.com/text/analytics/v2.0");
BaseUri = "{Endpoint}/text/analytics/v2.0";
SerializationSettings = new JsonSerializerSettings
{
Formatting = Newtonsoft.Json.Formatting.Indented,
Expand Down Expand Up @@ -319,6 +211,10 @@ private void Initialize()
/// </return>
public async Task<HttpOperationResponse<KeyPhraseBatchResult>> KeyPhrasesWithHttpMessagesAsync(MultiLanguageBatchInput input, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Endpoint == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
}
if (input == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "input");
Expand All @@ -335,8 +231,9 @@ private void Initialize()
ServiceClientTracing.Enter(_invocationId, this, "KeyPhrases", tracingParameters);
}
// Construct URL
var _baseUrl = BaseUri.AbsoluteUri;
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "keyPhrases").ToString();
var _baseUrl = BaseUri;
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "keyPhrases";
_url = _url.Replace("{Endpoint}", Endpoint);
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down Expand Up @@ -476,6 +373,10 @@ private void Initialize()
/// </return>
public async Task<HttpOperationResponse<LanguageBatchResult>> DetectLanguageWithHttpMessagesAsync(BatchInput input, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Endpoint == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
}
if (input == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "input");
Expand All @@ -492,8 +393,9 @@ private void Initialize()
ServiceClientTracing.Enter(_invocationId, this, "DetectLanguage", tracingParameters);
}
// Construct URL
var _baseUrl = BaseUri.AbsoluteUri;
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "languages").ToString();
var _baseUrl = BaseUri;
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "languages";
_url = _url.Replace("{Endpoint}", Endpoint);
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down Expand Up @@ -637,6 +539,10 @@ private void Initialize()
/// </return>
public async Task<HttpOperationResponse<SentimentBatchResult>> SentimentWithHttpMessagesAsync(MultiLanguageBatchInput input, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Endpoint == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
}
if (input == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "input");
Expand All @@ -653,8 +559,9 @@ private void Initialize()
ServiceClientTracing.Enter(_invocationId, this, "Sentiment", tracingParameters);
}
// Construct URL
var _baseUrl = BaseUri.AbsoluteUri;
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "sentiment").ToString();
var _baseUrl = BaseUri;
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "sentiment";
_url = _url.Replace("{Endpoint}", Endpoint);
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down Expand Up @@ -798,6 +705,10 @@ private void Initialize()
/// </return>
public async Task<HttpOperationResponse<EntitiesBatchResult>> EntitiesWithHttpMessagesAsync(MultiLanguageBatchInput input, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Endpoint == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Endpoint");
}
if (input == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "input");
Expand All @@ -814,8 +725,9 @@ private void Initialize()
ServiceClientTracing.Enter(_invocationId, this, "Entities", tracingParameters);
}
// Construct URL
var _baseUrl = BaseUri.AbsoluteUri;
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "entities").ToString();
var _baseUrl = BaseUri;
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "entities";
_url = _url.Replace("{Endpoint}", Endpoint);
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PropertyGroup>
<PackageId>Microsoft.Azure.CognitiveServices.Language.TextAnalytics</PackageId>
<Description>This client library provides access to the Microsoft Cognitive Services Language APIs.</Description>
<Version>2.0.0-preview</Version>
<Version>2.1.0-preview</Version>
<AssemblyName>Microsoft.Azure.CognitiveServices.Language.TextAnalytics</AssemblyName>
<PackageTags>Microsoft Cognitive Services;Cognitive Services;Cognitive Services SDK;Text Analytics API;Text Analytics;REST HTTP client;netcore451511</PackageTags>
<PackageReleaseNotes>
Expand All @@ -16,7 +16,7 @@
Note: This package is the successor to the Microsoft.Azure.CognitiveServices.Language NuGet package.
Changes in this release:
1. Support customizing service endpoints.
1. Support customizing service endpoints by assigning the endpoint string to TextAnalyticsClient.Endpoint. The endpoint string can be found on Azure Portal, it should contain only protocol and hostname, for example: https://westus.api.cognitive.microsoft.com
]]></PackageReleaseNotes>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyDescription("Provides API functions for consuming Microsoft Azure Cognitive Services Language APIs.")]

[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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/data-plane/TextAnalytics/readme.md --csharp --version=latest --reflect-api-versions --csharp.output-folder=E:\azure-sdk-for-net\src\SDKs\CognitiveServices\dataPlane\Language\TextAnalytics\TextAnalytics\Generated\TextAnalytics
2018-07-06 00:48:29 UTC
2018-07-26 19:20:31 UTC
1) azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 6a9b980b104d37e495f77e82a7aaf32e342e7a1c
Commit: c39645d5399639edb6a46d7f87715640e928cd30

2) AutoRest information
Requested version: latest
Bootstrapper version: [email protected].4280
Bootstrapper version: [email protected].4282


Latest installed version:
Expand Down

0 comments on commit 02cf21e

Please sign in to comment.