Share via


DocumentIntelligenceAdministrationClient.CopyClassifierToAsync Method

Definition

Overloads

CopyClassifierToAsync(WaitUntil, String, ClassifierCopyAuthorization, CancellationToken)

Copies document classifier to the target resource, region, and classifierId.

CopyClassifierToAsync(WaitUntil, String, RequestContent, RequestContext)

[Protocol Method] Copies document classifier to the target resource, region, and classifierId.

CopyClassifierToAsync(WaitUntil, String, ClassifierCopyAuthorization, CancellationToken)

Copies document classifier to the target resource, region, and classifierId.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>> CopyClassifierToAsync (Azure.WaitUntil waitUntil, string classifierId, Azure.AI.DocumentIntelligence.ClassifierCopyAuthorization copyToRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member CopyClassifierToAsync : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.ClassifierCopyAuthorization * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>>
override this.CopyClassifierToAsync : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.ClassifierCopyAuthorization * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>>
Public Overridable Function CopyClassifierToAsync (waitUntil As WaitUntil, classifierId As String, copyToRequest As ClassifierCopyAuthorization, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DocumentClassifierDetails))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

classifierId
String

Unique document classifier name.

copyToRequest
ClassifierCopyAuthorization

Copy to request parameters.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

classifierId or copyToRequest is null.

classifierId is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call CopyClassifierToAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

ClassifierCopyAuthorization copyToRequest = new ClassifierCopyAuthorization(
"<targetResourceId>",
"<targetResourceRegion>",
"<targetClassifierId>",
new Uri("http://localhost:3000"),
"<accessToken>",
DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"));
Operation<DocumentClassifierDetails> operation = await client.CopyClassifierToAsync(WaitUntil.Completed, "<classifierId>", copyToRequest);
DocumentClassifierDetails responseData = operation.Value;

This sample shows how to call CopyClassifierToAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

ClassifierCopyAuthorization copyToRequest = new ClassifierCopyAuthorization(
"<targetResourceId>",
"<targetResourceRegion>",
"<targetClassifierId>",
new Uri("http://localhost:3000"),
"<accessToken>",
DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"));
Operation<DocumentClassifierDetails> operation = await client.CopyClassifierToAsync(WaitUntil.Completed, "<classifierId>", copyToRequest);
DocumentClassifierDetails responseData = operation.Value;

Applies to

CopyClassifierToAsync(WaitUntil, String, RequestContent, RequestContext)

[Protocol Method] Copies document classifier to the target resource, region, and classifierId.

public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> CopyClassifierToAsync (Azure.WaitUntil waitUntil, string classifierId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CopyClassifierToAsync : Azure.WaitUntil * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.CopyClassifierToAsync : Azure.WaitUntil * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function CopyClassifierToAsync (waitUntil As WaitUntil, classifierId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Operation(Of BinaryData))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

classifierId
String

Unique document classifier name.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The Operation representing an asynchronous operation on the service.

Exceptions

classifierId or content is null.

classifierId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call CopyClassifierToAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    targetResourceId = "<targetResourceId>",
    targetResourceRegion = "<targetResourceRegion>",
    targetClassifierId = "<targetClassifierId>",
    targetClassifierLocation = "http://localhost:3000",
    accessToken = "<accessToken>",
    expirationDateTime = "2022-05-10T18:57:31.2311892Z",
});
Operation<BinaryData> operation = await client.CopyClassifierToAsync(WaitUntil.Completed, "<classifierId>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("classifierId").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("apiVersion").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").ToString());

This sample shows how to call CopyClassifierToAsync with all parameters and request content and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    targetResourceId = "<targetResourceId>",
    targetResourceRegion = "<targetResourceRegion>",
    targetClassifierId = "<targetClassifierId>",
    targetClassifierLocation = "http://localhost:3000",
    accessToken = "<accessToken>",
    expirationDateTime = "2022-05-10T18:57:31.2311892Z",
});
Operation<BinaryData> operation = await client.CopyClassifierToAsync(WaitUntil.Completed, "<classifierId>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("classifierId").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("expirationDateTime").ToString());
Console.WriteLine(result.GetProperty("apiVersion").ToString());
Console.WriteLine(result.GetProperty("baseClassifierId").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("sourceKind").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobSource").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobFileListSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("azureBlobFileListSource").GetProperty("fileList").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("target").ToString());

Applies to