Share via


DeidentificationClient.CreateJobAsync Method

Definition

Overloads

CreateJobAsync(WaitUntil, String, RequestContent, RequestContext)

[Protocol Method] Create a de-identification job.

CreateJobAsync(WaitUntil, String, DeidentificationJob, CancellationToken)

Create a de-identification job.

CreateJobAsync(WaitUntil, String, RequestContent, RequestContext)

Source:
DeidentificationClient.cs

[Protocol Method] Create a de-identification job.

public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> CreateJobAsync (Azure.WaitUntil waitUntil, string name, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateJobAsync : Azure.WaitUntil * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.CreateJobAsync : Azure.WaitUntil * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function CreateJobAsync (waitUntil As WaitUntil, name 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.

name
String

The name of a job.

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

name or content is null.

name 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 CreateJobAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    sourceLocation = new
    {
        location = "http://localhost:3000",
        prefix = "<prefix>",
    },
    targetLocation = new
    {
        location = "http://localhost:3000",
        prefix = "<prefix>",
    },
});
Operation<BinaryData> operation = await client.CreateJobAsync(WaitUntil.Completed, "<name>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString());
Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString());
Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("lastUpdatedAt").ToString());
Console.WriteLine(result.GetProperty("createdAt").ToString());

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

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    sourceLocation = new
    {
        location = "http://localhost:3000",
        prefix = "<prefix>",
        extensions = new object[]
        {
            "<extensions>"
        },
    },
    targetLocation = new
    {
        location = "http://localhost:3000",
        prefix = "<prefix>",
    },
    operation = "Redact",
    dataType = "Plaintext",
    redactionFormat = "<redactionFormat>",
});
Operation<BinaryData> operation = await client.CreateJobAsync(WaitUntil.Completed, "<name>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("location").ToString());
Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("sourceLocation").GetProperty("extensions")[0].ToString());
Console.WriteLine(result.GetProperty("targetLocation").GetProperty("location").ToString());
Console.WriteLine(result.GetProperty("targetLocation").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("operation").ToString());
Console.WriteLine(result.GetProperty("dataType").ToString());
Console.WriteLine(result.GetProperty("redactionFormat").ToString());
Console.WriteLine(result.GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("lastUpdatedAt").ToString());
Console.WriteLine(result.GetProperty("createdAt").ToString());
Console.WriteLine(result.GetProperty("startedAt").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("successful").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("failed").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("canceled").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("total").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("bytesProcessed").ToString());

Applies to

CreateJobAsync(WaitUntil, String, DeidentificationJob, CancellationToken)

Source:
DeidentificationClient.cs

Create a de-identification job.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.Health.Deidentification.DeidentificationJob>> CreateJobAsync (Azure.WaitUntil waitUntil, string name, Azure.Health.Deidentification.DeidentificationJob resource, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateJobAsync : Azure.WaitUntil * string * Azure.Health.Deidentification.DeidentificationJob * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.Health.Deidentification.DeidentificationJob>>
override this.CreateJobAsync : Azure.WaitUntil * string * Azure.Health.Deidentification.DeidentificationJob * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.Health.Deidentification.DeidentificationJob>>
Public Overridable Function CreateJobAsync (waitUntil As WaitUntil, name As String, resource As DeidentificationJob, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DeidentificationJob))

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.

name
String

The name of a job.

resource
DeidentificationJob

The resource instance.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

name or resource is null.

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

Examples

This sample shows how to call CreateJobAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);

DeidentificationJob resource = new DeidentificationJob(new SourceStorageLocation(new Uri("http://localhost:3000"), "<prefix>"), new TargetStorageLocation(new Uri("http://localhost:3000"), "<prefix>"));
Operation<DeidentificationJob> operation = await client.CreateJobAsync(WaitUntil.Completed, "<name>", resource);
DeidentificationJob responseData = operation.Value;

This sample shows how to call CreateJobAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);

DeidentificationJob resource = new DeidentificationJob(new SourceStorageLocation(new Uri("http://localhost:3000"), "<prefix>")
{
    Extensions = { "<extensions>" },
}, new TargetStorageLocation(new Uri("http://localhost:3000"), "<prefix>"))
{
    Operation = OperationType.Redact,
    DataType = DocumentDataType.Plaintext,
    RedactionFormat = "<redactionFormat>",
};
Operation<DeidentificationJob> operation = await client.CreateJobAsync(WaitUntil.Completed, "<name>", resource);
DeidentificationJob responseData = operation.Value;

Remarks

Long-running resource create or replace operation template.

Applies to