Share via


EasmClient.GetSnapshotAsync Method

Definition

Overloads

GetSnapshotAsync(ReportAssetSnapshotPayload, CancellationToken)

Get the most recent snapshot of asset summary values for the snapshot request.

GetSnapshotAsync(RequestContent, RequestContext)

[Protocol Method] Get the most recent snapshot of asset summary values for the snapshot request.

GetSnapshotAsync(ReportAssetSnapshotPayload, CancellationToken)

Source:
EasmClient.cs

Get the most recent snapshot of asset summary values for the snapshot request.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.ReportAssetSnapshotResult>> GetSnapshotAsync (Azure.Analytics.Defender.Easm.ReportAssetSnapshotPayload reportAssetSnapshotPayload, System.Threading.CancellationToken cancellationToken = default);
abstract member GetSnapshotAsync : Azure.Analytics.Defender.Easm.ReportAssetSnapshotPayload * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.ReportAssetSnapshotResult>>
override this.GetSnapshotAsync : Azure.Analytics.Defender.Easm.ReportAssetSnapshotPayload * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.ReportAssetSnapshotResult>>
Public Overridable Function GetSnapshotAsync (reportAssetSnapshotPayload As ReportAssetSnapshotPayload, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of ReportAssetSnapshotResult))

Parameters

reportAssetSnapshotPayload
ReportAssetSnapshotPayload

A request body used to retrieve an asset report snapshot.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

reportAssetSnapshotPayload is null.

Examples

This sample shows how to call GetSnapshotAsync.

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

ReportAssetSnapshotPayload reportAssetSnapshotPayload = new ReportAssetSnapshotPayload();
Response<ReportAssetSnapshotResult> response = await client.GetSnapshotAsync(reportAssetSnapshotPayload);

This sample shows how to call GetSnapshotAsync with all parameters.

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

ReportAssetSnapshotPayload reportAssetSnapshotPayload = new ReportAssetSnapshotPayload
{
    Metric = "<metric>",
    LabelName = "<labelName>",
    Size = 1234,
    Page = 1234,
};
Response<ReportAssetSnapshotResult> response = await client.GetSnapshotAsync(reportAssetSnapshotPayload);

Applies to

GetSnapshotAsync(RequestContent, RequestContext)

Source:
EasmClient.cs

[Protocol Method] Get the most recent snapshot of asset summary values for the snapshot request.

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

Parameters

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

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call GetSnapshotAsync 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.GetSnapshotAsync(content);

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

This sample shows how to call GetSnapshotAsync with all 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
{
    metric = "<metric>",
    labelName = "<labelName>",
    size = 1234,
    page = 1234,
});
Response response = await client.GetSnapshotAsync(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("metric").ToString());
Console.WriteLine(result.GetProperty("labelName").ToString());
Console.WriteLine(result.GetProperty("updatedAt").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("totalElements").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("mark").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("nextLink").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("uuid").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("createdDate").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("updatedDate").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("externalId").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("labels")[0].ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("wildcard").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("discoGroupName").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("auditTrail")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("auditTrail")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("auditTrail")[0].GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("auditTrail")[0].GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("auditTrail")[0].GetProperty("reason").ToString());
Console.WriteLine(result.GetProperty("assets").GetProperty("value")[0].GetProperty("reason").ToString());

Applies to