Share via


EasmClient.UpdateAssets Method

Definition

Overloads

UpdateAssets(String, AssetUpdatePayload, CancellationToken)

Update labels on assets matching the provided filter.

UpdateAssets(String, RequestContent, RequestContext)

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

UpdateAssets(String, AssetUpdatePayload, CancellationToken)

Source:
EasmClient.cs

Update labels on assets matching the provided filter.

public virtual Azure.Response<Azure.Analytics.Defender.Easm.TaskResource> UpdateAssets (string filter, Azure.Analytics.Defender.Easm.AssetUpdatePayload assetUpdatePayload, System.Threading.CancellationToken cancellationToken = default);
abstract member UpdateAssets : string * Azure.Analytics.Defender.Easm.AssetUpdatePayload * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.TaskResource>
override this.UpdateAssets : string * Azure.Analytics.Defender.Easm.AssetUpdatePayload * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.TaskResource>
Public Overridable Function UpdateAssets (filter As String, assetUpdatePayload As AssetUpdatePayload, Optional cancellationToken As CancellationToken = Nothing) As 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 UpdateAssets.

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 = client.UpdateAssets("<filter>", assetUpdatePayload);

This sample shows how to call UpdateAssets 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 = client.UpdateAssets("<filter>", assetUpdatePayload);

Applies to

UpdateAssets(String, RequestContent, RequestContext)

Source:
EasmClient.cs

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

public virtual Azure.Response UpdateAssets (string filter, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member UpdateAssets : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.UpdateAssets : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function UpdateAssets (filter As String, content As RequestContent, Optional context As RequestContext = Nothing) As 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 UpdateAssets 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 = client.UpdateAssets("<filter>", content);

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

This sample shows how to call UpdateAssets 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 = client.UpdateAssets("<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