EasmClient.UpdateAssetsAsync Method

Definition

Overloads

UpdateAssetsAsync(String, AssetUpdatePayload, CancellationToken)

Update labels on assets matching the provided filter.

UpdateAssetsAsync(String, RequestContent, RequestContext)

[Protocol Method] Update labels on assets matching the provided filter.

UpdateAssetsAsync(String, AssetUpdatePayload, CancellationToken)

Source:
EasmClient.cs

Update labels on assets matching the provided filter.

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

Parameters

filter
String

An expression on the resource type that selects the resources to be returned.

assetUpdatePayload
AssetUpdatePayload

A request body used to update an asset.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

filter or assetUpdatePayload is null.

Examples

This sample shows how to call UpdateAssetsAsync.

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

AssetUpdatePayload assetUpdatePayload = new AssetUpdatePayload();
Response<TaskResource> response = await client.UpdateAssetsAsync("<filter>", assetUpdatePayload);

This sample shows how to call UpdateAssetsAsync with all parameters.

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

AssetUpdatePayload assetUpdatePayload = new AssetUpdatePayload
{
    State = AssetUpdateState.Candidate,
    ExternalId = "<externalId>",
    Labels =
    {
        ["key"] = true
    },
    Transfers = AssetUpdateTransfers.As,
};
Response<TaskResource> response = await client.UpdateAssetsAsync("<filter>", assetUpdatePayload);

Applies to

UpdateAssetsAsync(String, RequestContent, RequestContext)

Source:
EasmClient.cs

[Protocol Method] Update labels on assets matching the provided filter.

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

Parameters

filter
String

An expression on the resource type that selects the resources to be returned.

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 response returned from the service.

Exceptions

filter or content is null.

Service returned a non-success status code.

Examples

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

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

using RequestContent content = RequestContent.Create(new object());
Response response = await client.UpdateAssetsAsync("<filter>", content);

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

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

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

using RequestContent content = RequestContent.Create(new
{
    state = "candidate",
    externalId = "<externalId>",
    labels = new
    {
        key = true,
    },
    transfers = "as",
});
Response response = await client.UpdateAssetsAsync("<filter>", content);

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