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](https://cloud.google.com/service-usage/docs/overview) v1
Package
@google-cloud/service-usageConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of ServiceUsageClient.
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof gax.fallback
: loaded instance of |
Properties
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
operationsClient
operationsClient: gax.OperationsClient;
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
serviceUsageStub
serviceUsageStub?: Promise<{
[name: string]: Function;
}>;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
batchEnableServices(request, options)
batchEnableServices(request?: protos.google.api.serviceusage.v1.IBatchEnableServicesRequest, options?: CallOptions): Promise<[
LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
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.
Name | Description |
request |
protos.google.api.serviceusage.v1.IBatchEnableServicesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Parent to enable services on.
* An example name would be:
* `projects/123` where `123` is the project number.
* The `BatchEnableServices` method currently only supports projects.
*/
// const parent = 'abc123'
/**
* The identifiers of the services to enable on the project.
* A valid identifier would be:
* serviceusage.googleapis.com
* Enabling services requires that each service is public or is shared with
* the user enabling the service.
* A single request can enable a maximum of 20 services at a time. If more
* than 20 services are specified, the request will fail, and no state changes
* will occur.
*/
// const serviceIds = 'abc123'
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callBatchEnableServices() {
// Construct request
const request = {
};
// Run request
const [operation] = await serviceusageClient.batchEnableServices(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchEnableServices();
batchEnableServices(request, options, callback)
batchEnableServices(request: protos.google.api.serviceusage.v1.IBatchEnableServicesRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IBatchEnableServicesRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
batchEnableServices(request, callback)
batchEnableServices(request: protos.google.api.serviceusage.v1.IBatchEnableServicesRequest, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IBatchEnableServicesRequest
|
callback |
Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
batchGetServices(request, options)
batchGetServices(request?: protos.google.api.serviceusage.v1.IBatchGetServicesRequest, options?: CallOptions): Promise<[
protos.google.api.serviceusage.v1.IBatchGetServicesResponse,
protos.google.api.serviceusage.v1.IBatchGetServicesRequest | undefined,
{} | undefined
]>;
Returns the service configurations and enabled states for a given list of services.
Name | Description |
request |
protos.google.api.serviceusage.v1.IBatchGetServicesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [BatchGetServicesResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Parent to retrieve services from.
* If this is set, the parent of all of the services specified in `names` must
* match this field. An example name would be: `projects/123` where `123` is
* the project number. The `BatchGetServices` method currently only supports
* projects.
*/
// const parent = 'abc123'
/**
* Names of the services to retrieve.
* An example name would be:
* `projects/123/services/serviceusage.googleapis.com` where `123` is the
* project number.
* A single request can get a maximum of 30 services at a time.
*/
// const names = 'abc123'
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callBatchGetServices() {
// Construct request
const request = {
};
// Run request
const response = await serviceusageClient.batchGetServices(request);
console.log(response);
}
callBatchGetServices();
batchGetServices(request, options, callback)
batchGetServices(request: protos.google.api.serviceusage.v1.IBatchGetServicesRequest, options: CallOptions, callback: Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IBatchGetServicesRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
batchGetServices(request, callback)
batchGetServices(request: protos.google.api.serviceusage.v1.IBatchGetServicesRequest, callback: Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IBatchGetServicesRequest
|
callback |
Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
checkBatchEnableServicesProgress(name)
checkBatchEnableServicesProgress(name: string): Promise<LROperation<protos.google.api.serviceusage.v1.BatchEnableServicesResponse, protos.google.api.serviceusage.v1.OperationMetadata>>;
Check the status of the long running operation returned by batchEnableServices()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.api.serviceusage.v1.BatchEnableServicesResponse, protos.google.api.serviceusage.v1.OperationMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Parent to enable services on.
* An example name would be:
* `projects/123` where `123` is the project number.
* The `BatchEnableServices` method currently only supports projects.
*/
// const parent = 'abc123'
/**
* The identifiers of the services to enable on the project.
* A valid identifier would be:
* serviceusage.googleapis.com
* Enabling services requires that each service is public or is shared with
* the user enabling the service.
* A single request can enable a maximum of 20 services at a time. If more
* than 20 services are specified, the request will fail, and no state changes
* will occur.
*/
// const serviceIds = 'abc123'
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callBatchEnableServices() {
// Construct request
const request = {
};
// Run request
const [operation] = await serviceusageClient.batchEnableServices(request);
const [response] = await operation.promise();
console.log(response);
}
callBatchEnableServices();
checkDisableServiceProgress(name)
checkDisableServiceProgress(name: string): Promise<LROperation<protos.google.api.serviceusage.v1.DisableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>>;
Check the status of the long running operation returned by disableService()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.api.serviceusage.v1.DisableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Name of the consumer and service to disable the service on.
* The enable and disable methods currently only support projects.
* An example name would be:
* `projects/123/services/serviceusage.googleapis.com` where `123` is the
* project number.
*/
// const name = 'abc123'
/**
* Indicates if services that are enabled and which depend on this service
* should also be disabled. If not set, an error will be generated if any
* enabled services depend on the service to be disabled. When set, the
* service, and any enabled services that depend on it, will be disabled
* together.
*/
// const disableDependentServices = true
/**
* Defines the behavior for checking service usage when disabling a service.
*/
// const checkIfServiceHasUsage = {}
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callDisableService() {
// Construct request
const request = {
};
// Run request
const [operation] = await serviceusageClient.disableService(request);
const [response] = await operation.promise();
console.log(response);
}
callDisableService();
checkEnableServiceProgress(name)
checkEnableServiceProgress(name: string): Promise<LROperation<protos.google.api.serviceusage.v1.EnableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>>;
Check the status of the long running operation returned by enableService()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.api.serviceusage.v1.EnableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Name of the consumer and service to enable the service on.
* The `EnableService` and `DisableService` methods currently only support
* projects.
* Enabling a service requires that the service is public or is shared with
* the user enabling the service.
* An example name would be:
* `projects/123/services/serviceusage.googleapis.com` where `123` is the
* project number.
*/
// const name = 'abc123'
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callEnableService() {
// Construct request
const request = {
};
// Run request
const [operation] = await serviceusageClient.enableService(request);
const [response] = await operation.promise();
console.log(response);
}
callEnableService();
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
disableService(request, options)
disableService(request?: protos.google.api.serviceusage.v1.IDisableServiceRequest, options?: CallOptions): Promise<[
LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
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.
Name | Description |
request |
protos.google.api.serviceusage.v1.IDisableServiceRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Name of the consumer and service to disable the service on.
* The enable and disable methods currently only support projects.
* An example name would be:
* `projects/123/services/serviceusage.googleapis.com` where `123` is the
* project number.
*/
// const name = 'abc123'
/**
* Indicates if services that are enabled and which depend on this service
* should also be disabled. If not set, an error will be generated if any
* enabled services depend on the service to be disabled. When set, the
* service, and any enabled services that depend on it, will be disabled
* together.
*/
// const disableDependentServices = true
/**
* Defines the behavior for checking service usage when disabling a service.
*/
// const checkIfServiceHasUsage = {}
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callDisableService() {
// Construct request
const request = {
};
// Run request
const [operation] = await serviceusageClient.disableService(request);
const [response] = await operation.promise();
console.log(response);
}
callDisableService();
disableService(request, options, callback)
disableService(request: protos.google.api.serviceusage.v1.IDisableServiceRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IDisableServiceRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
disableService(request, callback)
disableService(request: protos.google.api.serviceusage.v1.IDisableServiceRequest, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IDisableServiceRequest
|
callback |
Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
enableService(request, options)
enableService(request?: protos.google.api.serviceusage.v1.IEnableServiceRequest, options?: CallOptions): Promise<[
LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Enable a service so that it can be used with a project.
Name | Description |
request |
protos.google.api.serviceusage.v1.IEnableServiceRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Name of the consumer and service to enable the service on.
* The `EnableService` and `DisableService` methods currently only support
* projects.
* Enabling a service requires that the service is public or is shared with
* the user enabling the service.
* An example name would be:
* `projects/123/services/serviceusage.googleapis.com` where `123` is the
* project number.
*/
// const name = 'abc123'
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callEnableService() {
// Construct request
const request = {
};
// Run request
const [operation] = await serviceusageClient.enableService(request);
const [response] = await operation.promise();
console.log(response);
}
callEnableService();
enableService(request, options, callback)
enableService(request: protos.google.api.serviceusage.v1.IEnableServiceRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IEnableServiceRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
enableService(request, callback)
enableService(request: protos.google.api.serviceusage.v1.IEnableServiceRequest, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IEnableServiceRequest
|
callback |
Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getProjectId()
getProjectId(): Promise<string>;
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Type | Description |
void |
getService(request, options)
getService(request?: protos.google.api.serviceusage.v1.IGetServiceRequest, options?: CallOptions): Promise<[
protos.google.api.serviceusage.v1.IService,
protos.google.api.serviceusage.v1.IGetServiceRequest | undefined,
{} | undefined
]>;
Returns the service configuration and enabled state for a given service.
Name | Description |
request |
protos.google.api.serviceusage.v1.IGetServiceRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [Service]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Name of the consumer and service to get the `ConsumerState` for.
* An example name would be:
* `projects/123/services/serviceusage.googleapis.com` where `123` is the
* project number.
*/
// const name = 'abc123'
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callGetService() {
// Construct request
const request = {
};
// Run request
const response = await serviceusageClient.getService(request);
console.log(response);
}
callGetService();
getService(request, options, callback)
getService(request: protos.google.api.serviceusage.v1.IGetServiceRequest, options: CallOptions, callback: Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IGetServiceRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getService(request, callback)
getService(request: protos.google.api.serviceusage.v1.IGetServiceRequest, callback: Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IGetServiceRequest
|
callback |
Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Type | Description |
Promise<{ [name: string]: Function; }> | {Promise} A promise that resolves to an authenticated service stub. |
listServices(request, options)
listServices(request?: protos.google.api.serviceusage.v1.IListServicesRequest, options?: CallOptions): Promise<[
protos.google.api.serviceusage.v1.IService[],
protos.google.api.serviceusage.v1.IListServicesRequest | null,
protos.google.api.serviceusage.v1.IListServicesResponse
]>;
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](https://cloud.google.com/asset-inventory/docs/apis), which provides higher throughput and richer filtering capability.
Name | Description |
request |
protos.google.api.serviceusage.v1.IListServicesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.api.serviceusage.v1.IService[], protos.google.api.serviceusage.v1.IListServicesRequest | null, protos.google.api.serviceusage.v1.IListServicesResponse ]> | {Promise} - The promise which resolves to an array. The first element of the array is Array of [Service]. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using |
listServices(request, options, callback)
listServices(request: protos.google.api.serviceusage.v1.IListServicesRequest, options: CallOptions, callback: PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IListServicesRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>
|
Type | Description |
void |
listServices(request, callback)
listServices(request: protos.google.api.serviceusage.v1.IListServicesRequest, callback: PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>): void;
Name | Description |
request |
protos.google.api.serviceusage.v1.IListServicesRequest
|
callback |
PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>
|
Type | Description |
void |
listServicesAsync(request, options)
listServicesAsync(request?: protos.google.api.serviceusage.v1.IListServicesRequest, options?: CallOptions): AsyncIterable<protos.google.api.serviceusage.v1.IService>;
Equivalent to listServices
, but returns an iterable object.
for
-await
-of
syntax is used with the iterable to get response elements on-demand.
Name | Description |
request |
protos.google.api.serviceusage.v1.IListServicesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
AsyncIterable<protos.google.api.serviceusage.v1.IService> | {Object} An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). When you iterate the returned iterable, each element will be an object representing [Service]. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Parent to search for services on.
* An example name would be:
* `projects/123` where `123` is the project number.
*/
// const parent = 'abc123'
/**
* Requested size of the next page of data.
* Requested page size cannot exceed 200.
* If not set, the default page size is 50.
*/
// const pageSize = 1234
/**
* Token identifying which result to start with, which is returned by a
* previous list call.
*/
// const pageToken = 'abc123'
/**
* Only list services that conform to the given filter.
* The allowed filter strings are `state:ENABLED` and `state:DISABLED`.
*/
// const filter = 'abc123'
// Imports the Serviceusage library
const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;
// Instantiates a client
const serviceusageClient = new ServiceUsageClient();
async function callListServices() {
// Construct request
const request = {
};
// Run request
const iterable = await serviceusageClient.listServicesAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListServices();
listServicesStream(request, options)
listServicesStream(request?: protos.google.api.serviceusage.v1.IListServicesRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Name | Description |
request |
protos.google.api.serviceusage.v1.IListServicesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Transform | {Stream} An object stream which emits an object representing [Service] on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using |