Show / Hide Table of Contents

Class AssetServiceClient

AssetService client wrapper, for convenient use.

Inheritance
System.Object
AssetServiceClient
AssetServiceClientImpl
Inherited Members
System.Object.ToString()
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Cloud.Asset.V1Beta1
Assembly: Google.Cloud.Asset.V1Beta1.dll
Syntax
public abstract class AssetServiceClient

Properties

DefaultEndpoint

The default endpoint for the AssetService service, which is a host of "cloudasset.googleapis.com" and a port of 443.

Declaration
public static ServiceEndpoint DefaultEndpoint { get; }
Property Value
Type Description
ServiceEndpoint

DefaultScopes

The default AssetService scopes.

Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type Description
System.Collections.Generic.IReadOnlyList<System.String>
Remarks

The default AssetService scopes are:

  • "https://www.googleapis.com/auth/cloud-platform";

ExportAssetsOperationsClient

The long-running operations client for ExportAssets.

Declaration
public virtual OperationsClient ExportAssetsOperationsClient { get; }
Property Value
Type Description
OperationsClient

GrpcClient

The underlying gRPC AssetService client.

Declaration
public virtual AssetService.AssetServiceClient GrpcClient { get; }
Property Value
Type Description
AssetService.AssetServiceClient

Methods

BatchGetAssetsHistory(BatchGetAssetsHistoryRequest, CallSettings)

Batch gets the update history of assets that overlap a time window. For RESOURCE content, this API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create gaps in the output history.

Declaration
public virtual BatchGetAssetsHistoryResponse BatchGetAssetsHistory(BatchGetAssetsHistoryRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchGetAssetsHistoryRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
BatchGetAssetsHistoryResponse

The RPC response.

Sample code
// Create client
AssetServiceClient assetServiceClient = AssetServiceClient.Create();
// Initialize request argument(s)
BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
{
    ParentAsProjectName = new ProjectName("[PROJECT]"),
    ContentType = ContentType.Unspecified,
    ReadTimeWindow = new TimeWindow(),
};
// Make the request
BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(request);

BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest, CallSettings)

Batch gets the update history of assets that overlap a time window. For RESOURCE content, this API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create gaps in the output history.

Declaration
public virtual Task<BatchGetAssetsHistoryResponse> BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
BatchGetAssetsHistoryRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<BatchGetAssetsHistoryResponse>

A Task containing the RPC response.

Sample code
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
{
    ParentAsProjectName = new ProjectName("[PROJECT]"),
    ContentType = ContentType.Unspecified,
    ReadTimeWindow = new TimeWindow(),
};
// Make the request
BatchGetAssetsHistoryResponse response = await assetServiceClient.BatchGetAssetsHistoryAsync(request);

BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest, CancellationToken)

Batch gets the update history of assets that overlap a time window. For RESOURCE content, this API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create gaps in the output history.

Declaration
public virtual Task<BatchGetAssetsHistoryResponse> BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest request, CancellationToken cancellationToken)
Parameters
Type Name Description
BatchGetAssetsHistoryRequest request

The request object containing all of the parameters for the API call.

System.Threading.CancellationToken cancellationToken

A System.Threading.CancellationToken to use for this RPC.

Returns
Type Description
System.Threading.Tasks.Task<BatchGetAssetsHistoryResponse>

A Task containing the RPC response.

Sample code
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
{
    ParentAsProjectName = new ProjectName("[PROJECT]"),
    ContentType = ContentType.Unspecified,
    ReadTimeWindow = new TimeWindow(),
};
// Make the request
BatchGetAssetsHistoryResponse response = await assetServiceClient.BatchGetAssetsHistoryAsync(request);

Create(ServiceEndpoint, AssetServiceSettings)

Synchronously creates a AssetServiceClient, applying defaults for all unspecified settings, and creating a channel connecting to the given endpoint with application default credentials where necessary. See the example for how to use custom credentials.

Declaration
public static AssetServiceClient Create(ServiceEndpoint endpoint = null, AssetServiceSettings settings = null)
Parameters
Type Name Description
ServiceEndpoint endpoint

Optional ServiceEndpoint.

AssetServiceSettings settings

Optional AssetServiceSettings.

Returns
Type Description
AssetServiceClient

The created AssetServiceClient.

Examples

This sample shows how to create a client using default credentials:

using Google.Cloud.Asset.V1Beta1;
...
// When running on Google Cloud Platform this will use the project Compute Credential.
// Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a JSON
// credential file to use that credential.
AssetServiceClient client = AssetServiceClient.Create();

This sample shows how to create a client using credentials loaded from a JSON file:

using Google.Cloud.Asset.V1Beta1;
using Google.Apis.Auth.OAuth2;
using Grpc.Auth;
using Grpc.Core;
...
GoogleCredential cred = GoogleCredential.FromFile("/path/to/credentials.json");
Channel channel = new Channel(
    AssetServiceClient.DefaultEndpoint.Host, AssetServiceClient.DefaultEndpoint.Port, cred.ToChannelCredentials());
AssetServiceClient client = AssetServiceClient.Create(channel);
...
// Shutdown the channel when it is no longer required.
channel.ShutdownAsync().Wait();

Create(CallInvoker, AssetServiceSettings)

Creates a AssetServiceClient which uses the specified call invoker for remote operations.

Declaration
public static AssetServiceClient Create(CallInvoker callInvoker, AssetServiceSettings settings = null)
Parameters
Type Name Description
CallInvoker callInvoker

The CallInvoker for remote operations. Must not be null.

AssetServiceSettings settings

Optional AssetServiceSettings.

Returns
Type Description
AssetServiceClient

The created AssetServiceClient.

Create(Channel, AssetServiceSettings)

Creates a AssetServiceClient which uses the specified channel for remote operations.

Declaration
public static AssetServiceClient Create(Channel channel, AssetServiceSettings settings = null)
Parameters
Type Name Description
Channel channel

The Channel for remote operations. Must not be null.

AssetServiceSettings settings

Optional AssetServiceSettings.

Returns
Type Description
AssetServiceClient

The created AssetServiceClient.

CreateAsync(ServiceEndpoint, AssetServiceSettings)

Asynchronously creates a AssetServiceClient, applying defaults for all unspecified settings, and creating a channel connecting to the given endpoint with application default credentials where necessary. See the example for how to use custom credentials.

Declaration
public static Task<AssetServiceClient> CreateAsync(ServiceEndpoint endpoint = null, AssetServiceSettings settings = null)
Parameters
Type Name Description
ServiceEndpoint endpoint

Optional ServiceEndpoint.

AssetServiceSettings settings

Optional AssetServiceSettings.

Returns
Type Description
System.Threading.Tasks.Task<AssetServiceClient>

The task representing the created AssetServiceClient.

Examples

This sample shows how to create a client using default credentials:

using Google.Cloud.Asset.V1Beta1;
...
// When running on Google Cloud Platform this will use the project Compute Credential.
// Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a JSON
// credential file to use that credential.
AssetServiceClient client = await AssetServiceClient.CreateAsync();

This sample shows how to create a client using credentials loaded from a JSON file:

using Google.Cloud.Asset.V1Beta1;
using Google.Apis.Auth.OAuth2;
using Grpc.Auth;
using Grpc.Core;
...
GoogleCredential cred = GoogleCredential.FromFile("/path/to/credentials.json");
Channel channel = new Channel(
    AssetServiceClient.DefaultEndpoint.Host, AssetServiceClient.DefaultEndpoint.Port, cred.ToChannelCredentials());
AssetServiceClient client = AssetServiceClient.Create(channel);
...
// Shutdown the channel when it is no longer required.
await channel.ShutdownAsync();

ExportAssets(ExportAssetsRequest, CallSettings)

Exports assets with time and resource types to a given Cloud Storage location. The output format is newline-delimited JSON. This API implements the [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of the export.

Declaration
public virtual Operation<ExportAssetsResponse, ExportAssetsRequest> ExportAssets(ExportAssetsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
ExportAssetsRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Operation<ExportAssetsResponse, ExportAssetsRequest>

The RPC response.

Sample code
// Create client
AssetServiceClient assetServiceClient = AssetServiceClient.Create();
// Initialize request argument(s)
ExportAssetsRequest request = new ExportAssetsRequest
{
    ParentAsProjectName = new ProjectName("[PROJECT]"),
    OutputConfig = new OutputConfig(),
};
// Make the request
Operation<ExportAssetsResponse, ExportAssetsRequest> response =
    assetServiceClient.ExportAssets(request);

// Poll until the returned long-running operation is complete
Operation<ExportAssetsResponse, ExportAssetsRequest> completedResponse =
    response.PollUntilCompleted();
// Retrieve the operation result
ExportAssetsResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<ExportAssetsResponse, ExportAssetsRequest> retrievedResponse =
    assetServiceClient.PollOnceExportAssets(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    ExportAssetsResponse retrievedResult = retrievedResponse.Result;
}

ExportAssetsAsync(ExportAssetsRequest, CallSettings)

Exports assets with time and resource types to a given Cloud Storage location. The output format is newline-delimited JSON. This API implements the [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of the export.

Declaration
public virtual Task<Operation<ExportAssetsResponse, ExportAssetsRequest>> ExportAssetsAsync(ExportAssetsRequest request, CallSettings callSettings = null)
Parameters
Type Name Description
ExportAssetsRequest request

The request object containing all of the parameters for the API call.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<Operation<ExportAssetsResponse, ExportAssetsRequest>>

A Task containing the RPC response.

Sample code
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
ExportAssetsRequest request = new ExportAssetsRequest
{
    ParentAsProjectName = new ProjectName("[PROJECT]"),
    OutputConfig = new OutputConfig(),
};
// Make the request
Operation<ExportAssetsResponse, ExportAssetsRequest> response =
    await assetServiceClient.ExportAssetsAsync(request);

// Poll until the returned long-running operation is complete
Operation<ExportAssetsResponse, ExportAssetsRequest> completedResponse =
    await response.PollUntilCompletedAsync();
// Retrieve the operation result
ExportAssetsResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<ExportAssetsResponse, ExportAssetsRequest> retrievedResponse =
    await assetServiceClient.PollOnceExportAssetsAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    ExportAssetsResponse retrievedResult = retrievedResponse.Result;
}

PollOnceExportAssets(String, CallSettings)

Poll an operation once, using an operationName from a previous invocation of ExportAssets.

Declaration
public virtual Operation<ExportAssetsResponse, ExportAssetsRequest> PollOnceExportAssets(string operationName, CallSettings callSettings = null)
Parameters
Type Name Description
System.String operationName

The name of a previously invoked operation. Must not be null or empty.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Operation<ExportAssetsResponse, ExportAssetsRequest>

The result of polling the operation.

PollOnceExportAssetsAsync(String, CallSettings)

Asynchronously poll an operation once, using an operationName from a previous invocation of ExportAssetsAsync.

Declaration
public virtual Task<Operation<ExportAssetsResponse, ExportAssetsRequest>> PollOnceExportAssetsAsync(string operationName, CallSettings callSettings = null)
Parameters
Type Name Description
System.String operationName

The name of a previously invoked operation. Must not be null or empty.

CallSettings callSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
System.Threading.Tasks.Task<Operation<ExportAssetsResponse, ExportAssetsRequest>>

A task representing the result of polling the operation.

ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create(ServiceEndpoint, AssetServiceSettings) and CreateAsync(ServiceEndpoint, AssetServiceSettings). Channels which weren't automatically created are not affected.

Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
Type Description
System.Threading.Tasks.Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create(ServiceEndpoint, AssetServiceSettings) and CreateAsync(ServiceEndpoint, AssetServiceSettings) will create new channels, which could in turn be shut down by another call to this method.

Back to top