Share via


EasmClient.GetAssetResource Method

Definition

Overloads

GetAssetResource(String, CancellationToken)

Retrieve an asset by assetId.

GetAssetResource(String, RequestContext)

[Protocol Method] Retrieve an asset by assetId.

GetAssetResource(String, CancellationToken)

Source:
EasmClient.cs

Retrieve an asset by assetId.

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

Parameters

assetId
String

The system generated unique id for the resource.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

assetId is null.

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

Examples

This sample shows how to call GetAssetResource.

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

Response<AssetResource> response = client.GetAssetResource("<assetId>");

This sample shows how to call GetAssetResource with all parameters.

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

Response<AssetResource> response = client.GetAssetResource("<assetId>");

Applies to

GetAssetResource(String, RequestContext)

Source:
EasmClient.cs

[Protocol Method] Retrieve an asset by assetId.

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

Parameters

assetId
String

The system generated unique id for the resource.

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

assetId is null.

assetId 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 GetAssetResource 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.GetAssetResource("<assetId>", null);

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

This sample shows how to call GetAssetResource 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.GetAssetResource("<assetId>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("uuid").ToString());
Console.WriteLine(result.GetProperty("createdDate").ToString());
Console.WriteLine(result.GetProperty("updatedDate").ToString());
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("externalId").ToString());
Console.WriteLine(result.GetProperty("labels")[0].ToString());
Console.WriteLine(result.GetProperty("wildcard").ToString());
Console.WriteLine(result.GetProperty("discoGroupName").ToString());
Console.WriteLine(result.GetProperty("auditTrail")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("auditTrail")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("auditTrail")[0].GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("auditTrail")[0].GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("auditTrail")[0].GetProperty("reason").ToString());
Console.WriteLine(result.GetProperty("reason").ToString());

Applies to