KMS Inventory v1 API - Class KeyTrackingServiceClient (1.4.0)

public abstract class KeyTrackingServiceClient

Reference documentation and code samples for the KMS Inventory v1 API class KeyTrackingServiceClient.

KeyTrackingService client wrapper, for convenient use.

Inheritance

object > KeyTrackingServiceClient

Namespace

Google.Cloud.Kms.Inventory.V1

Assembly

Google.Cloud.Kms.Inventory.V1.dll

Remarks

Returns information about the resources in an org that are protected by a given Cloud KMS key via CMEK.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default KeyTrackingService scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

The default KeyTrackingService scopes are:

GrpcClient

public virtual KeyTrackingService.KeyTrackingServiceClient GrpcClient { get; }

The underlying gRPC KeyTrackingService client

Property Value
Type Description
KeyTrackingServiceKeyTrackingServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static KeyTrackingServiceClient Create()

Synchronously creates a KeyTrackingServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use KeyTrackingServiceClientBuilder .

Returns
Type Description
KeyTrackingServiceClient

The created KeyTrackingServiceClient.

CreateAsync(CancellationToken)

public static Task<KeyTrackingServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a KeyTrackingServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use KeyTrackingServiceClientBuilder .

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskKeyTrackingServiceClient

The task representing the created KeyTrackingServiceClient.

GetProtectedResourcesSummary(GetProtectedResourcesSummaryRequest, CallSettings)

public virtual ProtectedResourcesSummary GetProtectedResourcesSummary(GetProtectedResourcesSummaryRequest request, CallSettings callSettings = null)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
request GetProtectedResourcesSummaryRequest

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
ProtectedResourcesSummary

The RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = KeyTrackingServiceClient.Create();
// Initialize request argument(s)
GetProtectedResourcesSummaryRequest request = new GetProtectedResourcesSummaryRequest
{
    ProtectedResourcesSummaryName = ProtectedResourcesSummaryName.FromProjectLocationKeyRingCryptoKey("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]"),
};
// Make the request
ProtectedResourcesSummary response = keyTrackingServiceClient.GetProtectedResourcesSummary(request);

GetProtectedResourcesSummary(ProtectedResourcesSummaryName, CallSettings)

public virtual ProtectedResourcesSummary GetProtectedResourcesSummary(ProtectedResourcesSummaryName name, CallSettings callSettings = null)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
name ProtectedResourcesSummaryName

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
ProtectedResourcesSummary

The RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = KeyTrackingServiceClient.Create();
// Initialize request argument(s)
ProtectedResourcesSummaryName name = ProtectedResourcesSummaryName.FromProjectLocationKeyRingCryptoKey("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
// Make the request
ProtectedResourcesSummary response = keyTrackingServiceClient.GetProtectedResourcesSummary(name);

GetProtectedResourcesSummary(string, CallSettings)

public virtual ProtectedResourcesSummary GetProtectedResourcesSummary(string name, CallSettings callSettings = null)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
name string

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
ProtectedResourcesSummary

The RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = KeyTrackingServiceClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/keyRings/[KEY_RING]/cryptoKeys/[CRYPTO_KEY]/protectedResourcesSummary";
// Make the request
ProtectedResourcesSummary response = keyTrackingServiceClient.GetProtectedResourcesSummary(name);

GetProtectedResourcesSummaryAsync(GetProtectedResourcesSummaryRequest, CallSettings)

public virtual Task<ProtectedResourcesSummary> GetProtectedResourcesSummaryAsync(GetProtectedResourcesSummaryRequest request, CallSettings callSettings = null)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
request GetProtectedResourcesSummaryRequest

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
TaskProtectedResourcesSummary

A Task containing the RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
GetProtectedResourcesSummaryRequest request = new GetProtectedResourcesSummaryRequest
{
    ProtectedResourcesSummaryName = ProtectedResourcesSummaryName.FromProjectLocationKeyRingCryptoKey("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]"),
};
// Make the request
ProtectedResourcesSummary response = await keyTrackingServiceClient.GetProtectedResourcesSummaryAsync(request);

GetProtectedResourcesSummaryAsync(GetProtectedResourcesSummaryRequest, CancellationToken)

public virtual Task<ProtectedResourcesSummary> GetProtectedResourcesSummaryAsync(GetProtectedResourcesSummaryRequest request, CancellationToken cancellationToken)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
request GetProtectedResourcesSummaryRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskProtectedResourcesSummary

A Task containing the RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
GetProtectedResourcesSummaryRequest request = new GetProtectedResourcesSummaryRequest
{
    ProtectedResourcesSummaryName = ProtectedResourcesSummaryName.FromProjectLocationKeyRingCryptoKey("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]"),
};
// Make the request
ProtectedResourcesSummary response = await keyTrackingServiceClient.GetProtectedResourcesSummaryAsync(request);

GetProtectedResourcesSummaryAsync(ProtectedResourcesSummaryName, CallSettings)

public virtual Task<ProtectedResourcesSummary> GetProtectedResourcesSummaryAsync(ProtectedResourcesSummaryName name, CallSettings callSettings = null)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
name ProtectedResourcesSummaryName

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskProtectedResourcesSummary

A Task containing the RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
ProtectedResourcesSummaryName name = ProtectedResourcesSummaryName.FromProjectLocationKeyRingCryptoKey("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
// Make the request
ProtectedResourcesSummary response = await keyTrackingServiceClient.GetProtectedResourcesSummaryAsync(name);

GetProtectedResourcesSummaryAsync(ProtectedResourcesSummaryName, CancellationToken)

public virtual Task<ProtectedResourcesSummary> GetProtectedResourcesSummaryAsync(ProtectedResourcesSummaryName name, CancellationToken cancellationToken)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
name ProtectedResourcesSummaryName

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskProtectedResourcesSummary

A Task containing the RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
ProtectedResourcesSummaryName name = ProtectedResourcesSummaryName.FromProjectLocationKeyRingCryptoKey("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
// Make the request
ProtectedResourcesSummary response = await keyTrackingServiceClient.GetProtectedResourcesSummaryAsync(name);

GetProtectedResourcesSummaryAsync(string, CallSettings)

public virtual Task<ProtectedResourcesSummary> GetProtectedResourcesSummaryAsync(string name, CallSettings callSettings = null)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
name string

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskProtectedResourcesSummary

A Task containing the RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/keyRings/[KEY_RING]/cryptoKeys/[CRYPTO_KEY]/protectedResourcesSummary";
// Make the request
ProtectedResourcesSummary response = await keyTrackingServiceClient.GetProtectedResourcesSummaryAsync(name);

GetProtectedResourcesSummaryAsync(string, CancellationToken)

public virtual Task<ProtectedResourcesSummary> GetProtectedResourcesSummaryAsync(string name, CancellationToken cancellationToken)

Returns aggregate information about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey]. Only resources within the same Cloud organization as the key will be returned. The project that holds the key must be part of an organization in order for this call to succeed.

Parameters
Name Description
name string

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskProtectedResourcesSummary

A Task containing the RPC response.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/keyRings/[KEY_RING]/cryptoKeys/[CRYPTO_KEY]/protectedResourcesSummary";
// Make the request
ProtectedResourcesSummary response = await keyTrackingServiceClient.GetProtectedResourcesSummaryAsync(name);

SearchProtectedResources(OrganizationName, IResourceName, string, int?, CallSettings)

public virtual PagedEnumerable<SearchProtectedResourcesResponse, ProtectedResource> SearchProtectedResources(OrganizationName scope, IResourceName cryptoKey, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns metadata about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization.

Parameters
Name Description
scope OrganizationName

Required. Resource name of the organization. Example: organizations/123

cryptoKey IResourceName

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableSearchProtectedResourcesResponseProtectedResource

A pageable sequence of ProtectedResource resources.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = KeyTrackingServiceClient.Create();
// Initialize request argument(s)
OrganizationName scope = OrganizationName.FromOrganization("[ORGANIZATION]");
IResourceName cryptoKey = new UnparsedResourceName("a/wildcard/resource");
// Make the request
PagedEnumerable<SearchProtectedResourcesResponse, ProtectedResource> response = keyTrackingServiceClient.SearchProtectedResources(scope, cryptoKey);

// Iterate over all response items, lazily performing RPCs as required
foreach (ProtectedResource item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (SearchProtectedResourcesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (ProtectedResource item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<ProtectedResource> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (ProtectedResource item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

SearchProtectedResources(SearchProtectedResourcesRequest, CallSettings)

public virtual PagedEnumerable<SearchProtectedResourcesResponse, ProtectedResource> SearchProtectedResources(SearchProtectedResourcesRequest request, CallSettings callSettings = null)

Returns metadata about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization.

Parameters
Name Description
request SearchProtectedResourcesRequest

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
PagedEnumerableSearchProtectedResourcesResponseProtectedResource

A pageable sequence of ProtectedResource resources.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = KeyTrackingServiceClient.Create();
// Initialize request argument(s)
SearchProtectedResourcesRequest request = new SearchProtectedResourcesRequest
{
    CryptoKeyAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
    ScopeAsOrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
    ResourceTypes = { "", },
};
// Make the request
PagedEnumerable<SearchProtectedResourcesResponse, ProtectedResource> response = keyTrackingServiceClient.SearchProtectedResources(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (ProtectedResource item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (SearchProtectedResourcesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (ProtectedResource item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<ProtectedResource> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (ProtectedResource item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

SearchProtectedResources(string, string, string, int?, CallSettings)

public virtual PagedEnumerable<SearchProtectedResourcesResponse, ProtectedResource> SearchProtectedResources(string scope, string cryptoKey, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns metadata about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization.

Parameters
Name Description
scope string

Required. Resource name of the organization. Example: organizations/123

cryptoKey string

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableSearchProtectedResourcesResponseProtectedResource

A pageable sequence of ProtectedResource resources.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = KeyTrackingServiceClient.Create();
// Initialize request argument(s)
string scope = "organizations/[ORGANIZATION]";
string cryptoKey = "a/wildcard/resource";
// Make the request
PagedEnumerable<SearchProtectedResourcesResponse, ProtectedResource> response = keyTrackingServiceClient.SearchProtectedResources(scope, cryptoKey);

// Iterate over all response items, lazily performing RPCs as required
foreach (ProtectedResource item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (SearchProtectedResourcesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (ProtectedResource item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<ProtectedResource> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (ProtectedResource item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

SearchProtectedResourcesAsync(OrganizationName, IResourceName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<SearchProtectedResourcesResponse, ProtectedResource> SearchProtectedResourcesAsync(OrganizationName scope, IResourceName cryptoKey, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns metadata about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization.

Parameters
Name Description
scope OrganizationName

Required. Resource name of the organization. Example: organizations/123

cryptoKey IResourceName

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableSearchProtectedResourcesResponseProtectedResource

A pageable asynchronous sequence of ProtectedResource resources.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
OrganizationName scope = OrganizationName.FromOrganization("[ORGANIZATION]");
IResourceName cryptoKey = new UnparsedResourceName("a/wildcard/resource");
// Make the request
PagedAsyncEnumerable<SearchProtectedResourcesResponse, ProtectedResource> response = keyTrackingServiceClient.SearchProtectedResourcesAsync(scope, cryptoKey);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((ProtectedResource item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((SearchProtectedResourcesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (ProtectedResource item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<ProtectedResource> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (ProtectedResource item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

SearchProtectedResourcesAsync(SearchProtectedResourcesRequest, CallSettings)

public virtual PagedAsyncEnumerable<SearchProtectedResourcesResponse, ProtectedResource> SearchProtectedResourcesAsync(SearchProtectedResourcesRequest request, CallSettings callSettings = null)

Returns metadata about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization.

Parameters
Name Description
request SearchProtectedResourcesRequest

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
PagedAsyncEnumerableSearchProtectedResourcesResponseProtectedResource

A pageable asynchronous sequence of ProtectedResource resources.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
SearchProtectedResourcesRequest request = new SearchProtectedResourcesRequest
{
    CryptoKeyAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
    ScopeAsOrganizationName = OrganizationName.FromOrganization("[ORGANIZATION]"),
    ResourceTypes = { "", },
};
// Make the request
PagedAsyncEnumerable<SearchProtectedResourcesResponse, ProtectedResource> response = keyTrackingServiceClient.SearchProtectedResourcesAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((ProtectedResource item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((SearchProtectedResourcesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (ProtectedResource item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<ProtectedResource> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (ProtectedResource item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

SearchProtectedResourcesAsync(string, string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<SearchProtectedResourcesResponse, ProtectedResource> SearchProtectedResourcesAsync(string scope, string cryptoKey, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns metadata about the resources protected by the given Cloud KMS [CryptoKey][google.cloud.kms.v1.CryptoKey] in the given Cloud organization.

Parameters
Name Description
scope string

Required. Resource name of the organization. Example: organizations/123

cryptoKey string

Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey].

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableSearchProtectedResourcesResponseProtectedResource

A pageable asynchronous sequence of ProtectedResource resources.

Example
// Create client
KeyTrackingServiceClient keyTrackingServiceClient = await KeyTrackingServiceClient.CreateAsync();
// Initialize request argument(s)
string scope = "organizations/[ORGANIZATION]";
string cryptoKey = "a/wildcard/resource";
// Make the request
PagedAsyncEnumerable<SearchProtectedResourcesResponse, ProtectedResource> response = keyTrackingServiceClient.SearchProtectedResourcesAsync(scope, cryptoKey);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((ProtectedResource item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((SearchProtectedResourcesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (ProtectedResource item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<ProtectedResource> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (ProtectedResource item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

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

Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

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