Service Usage v1 API - Class ServiceUsageClient (2.3.0)

public abstract class ServiceUsageClient

Reference documentation and code samples for the Service Usage v1 API class ServiceUsageClient.

ServiceUsage client wrapper, for convenient use.

Inheritance

object > ServiceUsageClient

Derived Types

Namespace

Google.Cloud.ServiceUsage.V1

Assembly

Google.Cloud.ServiceUsage.V1.dll

Remarks

Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.

See Service Usage API

Properties

BatchEnableServicesOperationsClient

public virtual OperationsClient BatchEnableServicesOperationsClient { get; }

The long-running operations client for BatchEnableServices.

Property Value
TypeDescription
OperationsClient

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default ServiceUsage scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

DisableServiceOperationsClient

public virtual OperationsClient DisableServiceOperationsClient { get; }

The long-running operations client for DisableService.

Property Value
TypeDescription
OperationsClient

EnableServiceOperationsClient

public virtual OperationsClient EnableServiceOperationsClient { get; }

The long-running operations client for EnableService.

Property Value
TypeDescription
OperationsClient

GrpcClient

public virtual ServiceUsage.ServiceUsageClient GrpcClient { get; }

The underlying gRPC ServiceUsage client

Property Value
TypeDescription
ServiceUsageServiceUsageClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

BatchEnableServices(BatchEnableServicesRequest, CallSettings)

public virtual Operation<BatchEnableServicesResponse, OperationMetadata> BatchEnableServices(BatchEnableServicesRequest request, CallSettings callSettings = null)

Enable multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur. To enable a single service, use the EnableService method instead.

Parameters
NameDescription
requestBatchEnableServicesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchEnableServicesResponseOperationMetadata

The RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = ServiceUsageClient.Create();
// Initialize request argument(s)
BatchEnableServicesRequest request = new BatchEnableServicesRequest
{
    Parent = "",
    ServiceIds = { "", },
};
// Make the request
Operation<BatchEnableServicesResponse, OperationMetadata> response = serviceUsageClient.BatchEnableServices(request);

// Poll until the returned long-running operation is complete
Operation<BatchEnableServicesResponse, OperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
BatchEnableServicesResponse 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<BatchEnableServicesResponse, OperationMetadata> retrievedResponse = serviceUsageClient.PollOnceBatchEnableServices(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchEnableServicesResponse retrievedResult = retrievedResponse.Result;
}

BatchEnableServicesAsync(BatchEnableServicesRequest, CallSettings)

public virtual Task<Operation<BatchEnableServicesResponse, OperationMetadata>> BatchEnableServicesAsync(BatchEnableServicesRequest request, CallSettings callSettings = null)

Enable multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur. To enable a single service, use the EnableService method instead.

Parameters
NameDescription
requestBatchEnableServicesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchEnableServicesResponseOperationMetadata

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
BatchEnableServicesRequest request = new BatchEnableServicesRequest
{
    Parent = "",
    ServiceIds = { "", },
};
// Make the request
Operation<BatchEnableServicesResponse, OperationMetadata> response = await serviceUsageClient.BatchEnableServicesAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchEnableServicesResponse, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchEnableServicesResponse 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<BatchEnableServicesResponse, OperationMetadata> retrievedResponse = await serviceUsageClient.PollOnceBatchEnableServicesAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchEnableServicesResponse retrievedResult = retrievedResponse.Result;
}

BatchEnableServicesAsync(BatchEnableServicesRequest, CancellationToken)

public virtual Task<Operation<BatchEnableServicesResponse, OperationMetadata>> BatchEnableServicesAsync(BatchEnableServicesRequest request, CancellationToken cancellationToken)

Enable multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur. To enable a single service, use the EnableService method instead.

Parameters
NameDescription
requestBatchEnableServicesRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationBatchEnableServicesResponseOperationMetadata

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
BatchEnableServicesRequest request = new BatchEnableServicesRequest
{
    Parent = "",
    ServiceIds = { "", },
};
// Make the request
Operation<BatchEnableServicesResponse, OperationMetadata> response = await serviceUsageClient.BatchEnableServicesAsync(request);

// Poll until the returned long-running operation is complete
Operation<BatchEnableServicesResponse, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
BatchEnableServicesResponse 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<BatchEnableServicesResponse, OperationMetadata> retrievedResponse = await serviceUsageClient.PollOnceBatchEnableServicesAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    BatchEnableServicesResponse retrievedResult = retrievedResponse.Result;
}

BatchGetServices(BatchGetServicesRequest, CallSettings)

public virtual BatchGetServicesResponse BatchGetServices(BatchGetServicesRequest request, CallSettings callSettings = null)

Returns the service configurations and enabled states for a given list of services.

Parameters
NameDescription
requestBatchGetServicesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
BatchGetServicesResponse

The RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = ServiceUsageClient.Create();
// Initialize request argument(s)
BatchGetServicesRequest request = new BatchGetServicesRequest
{
    Parent = "",
    Names = { "", },
};
// Make the request
BatchGetServicesResponse response = serviceUsageClient.BatchGetServices(request);

BatchGetServicesAsync(BatchGetServicesRequest, CallSettings)

public virtual Task<BatchGetServicesResponse> BatchGetServicesAsync(BatchGetServicesRequest request, CallSettings callSettings = null)

Returns the service configurations and enabled states for a given list of services.

Parameters
NameDescription
requestBatchGetServicesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskBatchGetServicesResponse

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
BatchGetServicesRequest request = new BatchGetServicesRequest
{
    Parent = "",
    Names = { "", },
};
// Make the request
BatchGetServicesResponse response = await serviceUsageClient.BatchGetServicesAsync(request);

BatchGetServicesAsync(BatchGetServicesRequest, CancellationToken)

public virtual Task<BatchGetServicesResponse> BatchGetServicesAsync(BatchGetServicesRequest request, CancellationToken cancellationToken)

Returns the service configurations and enabled states for a given list of services.

Parameters
NameDescription
requestBatchGetServicesRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskBatchGetServicesResponse

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
BatchGetServicesRequest request = new BatchGetServicesRequest
{
    Parent = "",
    Names = { "", },
};
// Make the request
BatchGetServicesResponse response = await serviceUsageClient.BatchGetServicesAsync(request);

Create()

public static ServiceUsageClient Create()

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

Returns
TypeDescription
ServiceUsageClient

The created ServiceUsageClient.

CreateAsync(CancellationToken)

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

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

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskServiceUsageClient

The task representing the created ServiceUsageClient.

DisableService(DisableServiceRequest, CallSettings)

public virtual Operation<DisableServiceResponse, OperationMetadata> DisableService(DisableServiceRequest request, CallSettings callSettings = null)

Disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause unexpected billing charges or security leaks.

It is not valid to call the disable method on a service that is not currently enabled. Callers will receive a FAILED_PRECONDITION status if the target service is not currently enabled.

Parameters
NameDescription
requestDisableServiceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationDisableServiceResponseOperationMetadata

The RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = ServiceUsageClient.Create();
// Initialize request argument(s)
DisableServiceRequest request = new DisableServiceRequest
{
    Name = "",
    DisableDependentServices = false,
    CheckIfServiceHasUsage = DisableServiceRequest.Types.CheckIfServiceHasUsage.Unspecified,
};
// Make the request
Operation<DisableServiceResponse, OperationMetadata> response = serviceUsageClient.DisableService(request);

// Poll until the returned long-running operation is complete
Operation<DisableServiceResponse, OperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
DisableServiceResponse 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<DisableServiceResponse, OperationMetadata> retrievedResponse = serviceUsageClient.PollOnceDisableService(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DisableServiceResponse retrievedResult = retrievedResponse.Result;
}

DisableServiceAsync(DisableServiceRequest, CallSettings)

public virtual Task<Operation<DisableServiceResponse, OperationMetadata>> DisableServiceAsync(DisableServiceRequest request, CallSettings callSettings = null)

Disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause unexpected billing charges or security leaks.

It is not valid to call the disable method on a service that is not currently enabled. Callers will receive a FAILED_PRECONDITION status if the target service is not currently enabled.

Parameters
NameDescription
requestDisableServiceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationDisableServiceResponseOperationMetadata

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
DisableServiceRequest request = new DisableServiceRequest
{
    Name = "",
    DisableDependentServices = false,
    CheckIfServiceHasUsage = DisableServiceRequest.Types.CheckIfServiceHasUsage.Unspecified,
};
// Make the request
Operation<DisableServiceResponse, OperationMetadata> response = await serviceUsageClient.DisableServiceAsync(request);

// Poll until the returned long-running operation is complete
Operation<DisableServiceResponse, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DisableServiceResponse 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<DisableServiceResponse, OperationMetadata> retrievedResponse = await serviceUsageClient.PollOnceDisableServiceAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DisableServiceResponse retrievedResult = retrievedResponse.Result;
}

DisableServiceAsync(DisableServiceRequest, CancellationToken)

public virtual Task<Operation<DisableServiceResponse, OperationMetadata>> DisableServiceAsync(DisableServiceRequest request, CancellationToken cancellationToken)

Disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause unexpected billing charges or security leaks.

It is not valid to call the disable method on a service that is not currently enabled. Callers will receive a FAILED_PRECONDITION status if the target service is not currently enabled.

Parameters
NameDescription
requestDisableServiceRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationDisableServiceResponseOperationMetadata

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
DisableServiceRequest request = new DisableServiceRequest
{
    Name = "",
    DisableDependentServices = false,
    CheckIfServiceHasUsage = DisableServiceRequest.Types.CheckIfServiceHasUsage.Unspecified,
};
// Make the request
Operation<DisableServiceResponse, OperationMetadata> response = await serviceUsageClient.DisableServiceAsync(request);

// Poll until the returned long-running operation is complete
Operation<DisableServiceResponse, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DisableServiceResponse 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<DisableServiceResponse, OperationMetadata> retrievedResponse = await serviceUsageClient.PollOnceDisableServiceAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    DisableServiceResponse retrievedResult = retrievedResponse.Result;
}

EnableService(EnableServiceRequest, CallSettings)

public virtual Operation<EnableServiceResponse, OperationMetadata> EnableService(EnableServiceRequest request, CallSettings callSettings = null)

Enable a service so that it can be used with a project.

Parameters
NameDescription
requestEnableServiceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationEnableServiceResponseOperationMetadata

The RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = ServiceUsageClient.Create();
// Initialize request argument(s)
EnableServiceRequest request = new EnableServiceRequest { Name = "", };
// Make the request
Operation<EnableServiceResponse, OperationMetadata> response = serviceUsageClient.EnableService(request);

// Poll until the returned long-running operation is complete
Operation<EnableServiceResponse, OperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
EnableServiceResponse 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<EnableServiceResponse, OperationMetadata> retrievedResponse = serviceUsageClient.PollOnceEnableService(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    EnableServiceResponse retrievedResult = retrievedResponse.Result;
}

EnableServiceAsync(EnableServiceRequest, CallSettings)

public virtual Task<Operation<EnableServiceResponse, OperationMetadata>> EnableServiceAsync(EnableServiceRequest request, CallSettings callSettings = null)

Enable a service so that it can be used with a project.

Parameters
NameDescription
requestEnableServiceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationEnableServiceResponseOperationMetadata

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
EnableServiceRequest request = new EnableServiceRequest { Name = "", };
// Make the request
Operation<EnableServiceResponse, OperationMetadata> response = await serviceUsageClient.EnableServiceAsync(request);

// Poll until the returned long-running operation is complete
Operation<EnableServiceResponse, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
EnableServiceResponse 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<EnableServiceResponse, OperationMetadata> retrievedResponse = await serviceUsageClient.PollOnceEnableServiceAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    EnableServiceResponse retrievedResult = retrievedResponse.Result;
}

EnableServiceAsync(EnableServiceRequest, CancellationToken)

public virtual Task<Operation<EnableServiceResponse, OperationMetadata>> EnableServiceAsync(EnableServiceRequest request, CancellationToken cancellationToken)

Enable a service so that it can be used with a project.

Parameters
NameDescription
requestEnableServiceRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskOperationEnableServiceResponseOperationMetadata

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
EnableServiceRequest request = new EnableServiceRequest { Name = "", };
// Make the request
Operation<EnableServiceResponse, OperationMetadata> response = await serviceUsageClient.EnableServiceAsync(request);

// Poll until the returned long-running operation is complete
Operation<EnableServiceResponse, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
EnableServiceResponse 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<EnableServiceResponse, OperationMetadata> retrievedResponse = await serviceUsageClient.PollOnceEnableServiceAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    EnableServiceResponse retrievedResult = retrievedResponse.Result;
}

GetService(GetServiceRequest, CallSettings)

public virtual Service GetService(GetServiceRequest request, CallSettings callSettings = null)

Returns the service configuration and enabled state for a given service.

Parameters
NameDescription
requestGetServiceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Service

The RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = ServiceUsageClient.Create();
// Initialize request argument(s)
GetServiceRequest request = new GetServiceRequest { Name = "", };
// Make the request
Service response = serviceUsageClient.GetService(request);

GetServiceAsync(GetServiceRequest, CallSettings)

public virtual Task<Service> GetServiceAsync(GetServiceRequest request, CallSettings callSettings = null)

Returns the service configuration and enabled state for a given service.

Parameters
NameDescription
requestGetServiceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskService

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
GetServiceRequest request = new GetServiceRequest { Name = "", };
// Make the request
Service response = await serviceUsageClient.GetServiceAsync(request);

GetServiceAsync(GetServiceRequest, CancellationToken)

public virtual Task<Service> GetServiceAsync(GetServiceRequest request, CancellationToken cancellationToken)

Returns the service configuration and enabled state for a given service.

Parameters
NameDescription
requestGetServiceRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskService

A Task containing the RPC response.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
GetServiceRequest request = new GetServiceRequest { Name = "", };
// Make the request
Service response = await serviceUsageClient.GetServiceAsync(request);

ListServices(ListServicesRequest, CallSettings)

public virtual PagedEnumerable<ListServicesResponse, Service> ListServices(ListServicesRequest request, CallSettings callSettings = null)

List all services available to the specified project, and the current state of those services with respect to the project. The list includes all public services, all services for which the calling user has the servicemanagement.services.bind permission, and all services that have already been enabled on the project. The list can be filtered to only include services in a specific state, for example to only include services enabled on the project.

WARNING: If you need to query enabled services frequently or across an organization, you should use Cloud Asset Inventory API, which provides higher throughput and richer filtering capability.

Parameters
NameDescription
requestListServicesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListServicesResponseService

A pageable sequence of Service resources.

Example
// Create client
ServiceUsageClient serviceUsageClient = ServiceUsageClient.Create();
// Initialize request argument(s)
ListServicesRequest request = new ListServicesRequest
{
    Parent = "",
    Filter = "",
};
// Make the request
PagedEnumerable<ListServicesResponse, Service> response = serviceUsageClient.ListServices(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Service 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 (ListServicesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Service 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<Service> 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 (Service 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;

ListServicesAsync(ListServicesRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListServicesResponse, Service> ListServicesAsync(ListServicesRequest request, CallSettings callSettings = null)

List all services available to the specified project, and the current state of those services with respect to the project. The list includes all public services, all services for which the calling user has the servicemanagement.services.bind permission, and all services that have already been enabled on the project. The list can be filtered to only include services in a specific state, for example to only include services enabled on the project.

WARNING: If you need to query enabled services frequently or across an organization, you should use Cloud Asset Inventory API, which provides higher throughput and richer filtering capability.

Parameters
NameDescription
requestListServicesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListServicesResponseService

A pageable asynchronous sequence of Service resources.

Example
// Create client
ServiceUsageClient serviceUsageClient = await ServiceUsageClient.CreateAsync();
// Initialize request argument(s)
ListServicesRequest request = new ListServicesRequest
{
    Parent = "",
    Filter = "",
};
// Make the request
PagedAsyncEnumerable<ListServicesResponse, Service> response = serviceUsageClient.ListServicesAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Service 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((ListServicesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Service 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<Service> 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 (Service 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;

PollOnceBatchEnableServices(string, CallSettings)

public virtual Operation<BatchEnableServicesResponse, OperationMetadata> PollOnceBatchEnableServices(string operationName, CallSettings callSettings = null)

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

Parameters
NameDescription
operationNamestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationBatchEnableServicesResponseOperationMetadata

The result of polling the operation.

PollOnceBatchEnableServicesAsync(string, CallSettings)

public virtual Task<Operation<BatchEnableServicesResponse, OperationMetadata>> PollOnceBatchEnableServicesAsync(string operationName, CallSettings callSettings = null)

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

Parameters
NameDescription
operationNamestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationBatchEnableServicesResponseOperationMetadata

A task representing the result of polling the operation.

PollOnceDisableService(string, CallSettings)

public virtual Operation<DisableServiceResponse, OperationMetadata> PollOnceDisableService(string operationName, CallSettings callSettings = null)

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

Parameters
NameDescription
operationNamestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationDisableServiceResponseOperationMetadata

The result of polling the operation.

PollOnceDisableServiceAsync(string, CallSettings)

public virtual Task<Operation<DisableServiceResponse, OperationMetadata>> PollOnceDisableServiceAsync(string operationName, CallSettings callSettings = null)

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

Parameters
NameDescription
operationNamestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationDisableServiceResponseOperationMetadata

A task representing the result of polling the operation.

PollOnceEnableService(string, CallSettings)

public virtual Operation<EnableServiceResponse, OperationMetadata> PollOnceEnableService(string operationName, CallSettings callSettings = null)

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

Parameters
NameDescription
operationNamestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
OperationEnableServiceResponseOperationMetadata

The result of polling the operation.

PollOnceEnableServiceAsync(string, CallSettings)

public virtual Task<Operation<EnableServiceResponse, OperationMetadata>> PollOnceEnableServiceAsync(string operationName, CallSettings callSettings = null)

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

Parameters
NameDescription
operationNamestring

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskOperationEnableServiceResponseOperationMetadata

A task representing the result of polling the operation.

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
TypeDescription
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.