/// <summary> /// Initializes a new instance of the <see cref="DocumentTranslationOperation"/> class. /// </summary> /// <param name="serviceClient">The client for communicating with the Translator Cognitive Service through its REST API.</param> /// <param name="diagnostics">The client diagnostics for exception creation in case of failure.</param> /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param> internal DocumentTranslationOperation(DocumentTranslationRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation) { _serviceClient = serviceClient; _diagnostics = diagnostics; _operationInternal = new OperationInternal <AsyncPageable <DocumentStatusResult> >(_diagnostics, this, rawResponse: null); Id = operationLocation.Split('/').Last(); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentTranslationOperation"/> class. /// </summary> /// <param name="translationId">The translation ID of this operation.</param> /// <param name="client">The client used to check for completion.</param> public DocumentTranslationOperation(string translationId, DocumentTranslationClient client) { var parsedTranslationId = ClientCommon.ValidateModelId(translationId, nameof(translationId)); Id = parsedTranslationId.ToString(); _serviceClient = client._serviceRestClient; _diagnostics = client._clientDiagnostics; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentTranslationOperation"/> class. /// </summary> /// <param name="translationId">The translation ID of this operation.</param> /// <param name="client">The client used to check for completion.</param> public DocumentTranslationOperation(string translationId, DocumentTranslationClient client) { var parsedTranslationId = ClientCommon.ValidateModelId(translationId, nameof(translationId)); Id = parsedTranslationId.ToString(); _serviceClient = client._serviceRestClient; _diagnostics = client._clientDiagnostics; _operationInternal = new OperationInternal <AsyncPageable <DocumentStatusResult> >(_diagnostics, this, rawResponse: null); }
/// <summary> /// Initializes a new instance of <see cref="DocumentTranslationClient"/> class for the specified service instance. /// </summary> /// <param name="endpoint">A <see cref="Uri"/> to the service the client /// sends requests to.</param> /// <param name="credential">The API key used to access /// the service. This will allow you to update the API key /// without creating a new client.</param> /// <param name="options"><see cref="DocumentTranslationClientOptions"/> that allow /// callers to configure how requests are sent to the service.</param> public DocumentTranslationClient(Uri endpoint, AzureKeyCredential credential, DocumentTranslationClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(options, nameof(options)); _options = options; _clientDiagnostics = new ClientDiagnostics(options); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, Constants.AuthorizationHeader)); _serviceRestClient = new DocumentTranslationRestClient(_clientDiagnostics, pipeline, endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentTranslationClient"/> /// class for the specified service instance. /// </summary> /// <param name="endpoint">A <see cref="Uri"/> to the service the client /// sends requests to. Endpoint can be found in the Azure portal.</param> /// <param name="credential">A <see cref="TokenCredential"/> used to /// authenticate requests to the service, such as DefaultAzureCredential.</param> /// <param name="options"><see cref="DocumentTranslationClientOptions"/> that allow /// callers to configure how requests are sent to the service.</param> public DocumentTranslationClient(Uri endpoint, TokenCredential credential, DocumentTranslationClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(options, nameof(options)); _options = options; _clientDiagnostics = new ClientDiagnostics(options); HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, Constants.DefaultCognitiveScope)); _serviceRestClient = new DocumentTranslationRestClient(_clientDiagnostics, pipeline, endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentTranslationClient"/> /// class for the specified service instance. /// </summary> /// <param name="endpoint">A <see cref="Uri"/> to the service the client /// sends requests to. Endpoint can be found in the Azure portal.</param> /// <param name="credential">A <see cref="TokenCredential"/> used to /// authenticate requests to the service, such as DefaultAzureCredential.</param> /// <param name="options"><see cref="DocumentTranslationClientOptions"/> that allow /// callers to configure how requests are sent to the service.</param> public DocumentTranslationClient(Uri endpoint, TokenCredential credential, DocumentTranslationClientOptions options) { Argument.AssertNotNull(endpoint, nameof(endpoint)); Argument.AssertNotNull(credential, nameof(credential)); Argument.AssertNotNull(options, nameof(options)); _clientDiagnostics = new ClientDiagnostics(options); _options = options; string defaultScope = $"{(string.IsNullOrEmpty(options.Audience?.ToString()) ? DocumentTranslationAudience.AzurePublicCloud : options.Audience)}/.default"; HttpPipeline pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, defaultScope)); _serviceRestClient = new DocumentTranslationRestClient(_clientDiagnostics, pipeline, endpoint.AbsoluteUri); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentTranslationOperation"/> class. /// </summary> /// <param name="serviceClient">The client for communicating with the Translator Cognitive Service through its REST API.</param> /// <param name="diagnostics">The client diagnostics for exception creation in case of failure.</param> /// <param name="operationLocation">The address of the long-running operation. It can be obtained from the response headers upon starting the operation.</param> internal DocumentTranslationOperation(DocumentTranslationRestClient serviceClient, ClientDiagnostics diagnostics, string operationLocation) { _serviceClient = serviceClient; _diagnostics = diagnostics; Id = operationLocation.Split('/').Last(); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentTranslationOperation"/> class. /// </summary> /// <param name="translationId">The translation ID of this operation.</param> /// <param name="client">The client used to check for completion.</param> public DocumentTranslationOperation(string translationId, DocumentTranslationClient client) { Id = translationId; _serviceClient = client._serviceRestClient; _diagnostics = client._clientDiagnostics; }