Udostępnij za pośrednictwem


EasmClient.GetTask Method

Definition

Overloads

GetTask(String, RequestContext)

[Protocol Method] Retrieve a task by taskId.

GetTask(String, CancellationToken)

Retrieve a task by taskId.

GetTask(String, RequestContext)

Source:
EasmClient.cs

[Protocol Method] Retrieve a task by taskId.

public virtual Azure.Response GetTask (string taskId, Azure.RequestContext context);
abstract member GetTask : string * Azure.RequestContext -> Azure.Response
override this.GetTask : string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetTask (taskId As String, context As RequestContext) As Response

Parameters

taskId
String

The unique identifier of the task.

context
RequestContext

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

Returns

The response returned from the service.

Exceptions

taskId is null.

taskId 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 GetTask and parse the result.

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

Response response = client.GetTask("<taskId>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());

This sample shows how to call GetTask with all parameters and parse the result.

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

Response response = client.GetTask("<taskId>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("startedAt").ToString());
Console.WriteLine(result.GetProperty("completedAt").ToString());
Console.WriteLine(result.GetProperty("lastPolledAt").ToString());
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("phase").ToString());
Console.WriteLine(result.GetProperty("reason").ToString());
Console.WriteLine(result.GetProperty("metadata").GetProperty("<key>").ToString());

Applies to

GetTask(String, CancellationToken)

Source:
EasmClient.cs

Retrieve a task by taskId.

public virtual Azure.Response<Azure.Analytics.Defender.Easm.TaskResource> GetTask (string taskId, System.Threading.CancellationToken cancellationToken = default);
abstract member GetTask : string * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.TaskResource>
override this.GetTask : string * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.TaskResource>
Public Overridable Function GetTask (taskId As String, Optional cancellationToken As CancellationToken = Nothing) As Response(Of TaskResource)

Parameters

taskId
String

The unique identifier of the task.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

taskId is null.

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

Examples

This sample shows how to call GetTask.

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

Response<TaskResource> response = client.GetTask("<taskId>");

This sample shows how to call GetTask with all parameters.

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

Response<TaskResource> response = client.GetTask("<taskId>");

Applies to