Class ServiceUsageClient (2.5.0)

publicclass ServiceUsageClientimplementsBackgroundResource

Service Description: Service Usage API

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GetServiceRequestrequest=GetServiceRequest.newBuilder().setName("name3373707").build();
Serviceresponse=serviceUsageClient.getService(request);
}

Note: close() needs to be called on the ServiceUsageClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ServiceUsageSettings to create(). For example:

To customize credentials:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ServiceUsageSettingsserviceUsageSettings=
ServiceUsageSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ServiceUsageClientserviceUsageClient=ServiceUsageClient.create(serviceUsageSettings);

To customize the endpoint:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ServiceUsageSettingsserviceUsageSettings=
ServiceUsageSettings.newBuilder().setEndpoint(myEndpoint).build();
ServiceUsageClientserviceUsageClient=ServiceUsageClient.create(serviceUsageSettings);

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
ServiceUsageSettingsserviceUsageSettings=
ServiceUsageSettings.newBuilder()
.setTransportChannelProvider(
ServiceUsageSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
ServiceUsageClientserviceUsageClient=ServiceUsageClient.create(serviceUsageSettings);

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ServiceUsageClient

Implements

BackgroundResource

Static Methods

create()

publicstaticfinalServiceUsageClientcreate()

Constructs an instance of ServiceUsageClient with default settings.

Returns
Type Description
Exceptions
Type Description

create(ServiceUsageSettings settings)

publicstaticfinalServiceUsageClientcreate(ServiceUsageSettingssettings)

Constructs an instance of ServiceUsageClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
Returns
Type Description
Exceptions
Type Description

create(ServiceUsageStub stub)

publicstaticfinalServiceUsageClientcreate(ServiceUsageStubstub)

Constructs an instance of ServiceUsageClient, using the given stub for making calls. This is for advanced usage - prefer using create(ServiceUsageSettings).

Parameter
Name Description
Returns
Type Description

Constructors

ServiceUsageClient(ServiceUsageSettings settings)

protectedServiceUsageClient(ServiceUsageSettingssettings)

Constructs an instance of ServiceUsageClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description

ServiceUsageClient(ServiceUsageStub stub)

protectedServiceUsageClient(ServiceUsageStubstub)
Parameter
Name Description

Methods

awaitTermination(long duration, TimeUnit unit)

publicbooleanawaitTermination(longduration,TimeUnitunit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
Exceptions
Type Description

batchEnableServicesAsync(BatchEnableServicesRequest request) (deprecated)

publicfinalOperationFuture<Empty,OperationMetadata>batchEnableServicesAsync(BatchEnableServicesRequestrequest)

Deprecated. This method is deprecated and will be removed in the next major version update.

Enables multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur.

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
BatchEnableServicesRequestrequest=
BatchEnableServicesRequest.newBuilder()
.setParent("parent-995424086")
.addAllServiceIds(newArrayList<String>())
.build();
serviceUsageClient.batchEnableServicesAsync(request).get();
}
Parameter
Name Description
request BatchEnableServicesRequest

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

Returns
Type Description

batchEnableServicesCallable() (deprecated)

publicfinalUnaryCallable<BatchEnableServicesRequest,Operation>batchEnableServicesCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Enables multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur.

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
BatchEnableServicesRequestrequest=
BatchEnableServicesRequest.newBuilder()
.setParent("parent-995424086")
.addAllServiceIds(newArrayList<String>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.batchEnableServicesCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

batchEnableServicesOperationCallable() (deprecated)

publicfinalOperationCallable<BatchEnableServicesRequest,Empty,OperationMetadata>batchEnableServicesOperationCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Enables multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur.

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
BatchEnableServicesRequestrequest=
BatchEnableServicesRequest.newBuilder()
.setParent("parent-995424086")
.addAllServiceIds(newArrayList<String>())
.build();
OperationFuture<Empty,OperationMetadata>future=
serviceUsageClient.batchEnableServicesOperationCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

close()

publicfinalvoidclose()

createAdminOverrideAsync(CreateAdminOverrideRequest request)

publicfinalOperationFuture<QuotaOverride,OperationMetadata>createAdminOverrideAsync(CreateAdminOverrideRequestrequest)

Creates an admin override. An admin override is applied by an administrator of a parent folder or parent organization of the consumer receiving the override. An admin override is intended to limit the amount of quota the consumer can use out of the total quota pool allocated to all children of the folder or organization.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
CreateAdminOverrideRequestrequest=
CreateAdminOverrideRequest.newBuilder()
.setParent("parent-995424086")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
QuotaOverrideresponse=serviceUsageClient.createAdminOverrideAsync(request).get();
}
Parameter
Name Description
request CreateAdminOverrideRequest

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

Returns
Type Description

createAdminOverrideCallable()

publicfinalUnaryCallable<CreateAdminOverrideRequest,Operation>createAdminOverrideCallable()

Creates an admin override. An admin override is applied by an administrator of a parent folder or parent organization of the consumer receiving the override. An admin override is intended to limit the amount of quota the consumer can use out of the total quota pool allocated to all children of the folder or organization.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
CreateAdminOverrideRequestrequest=
CreateAdminOverrideRequest.newBuilder()
.setParent("parent-995424086")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.createAdminOverrideCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

createAdminOverrideOperationCallable()

publicfinalOperationCallable<CreateAdminOverrideRequest,QuotaOverride,OperationMetadata>createAdminOverrideOperationCallable()

Creates an admin override. An admin override is applied by an administrator of a parent folder or parent organization of the consumer receiving the override. An admin override is intended to limit the amount of quota the consumer can use out of the total quota pool allocated to all children of the folder or organization.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
CreateAdminOverrideRequestrequest=
CreateAdminOverrideRequest.newBuilder()
.setParent("parent-995424086")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<QuotaOverride,OperationMetadata>future=
serviceUsageClient.createAdminOverrideOperationCallable().futureCall(request);
// Do something.
QuotaOverrideresponse=future.get();
}
Returns
Type Description

createConsumerOverrideAsync(CreateConsumerOverrideRequest request)

publicfinalOperationFuture<QuotaOverride,OperationMetadata>createConsumerOverrideAsync(CreateConsumerOverrideRequestrequest)

Creates a consumer override. A consumer override is applied to the consumer on its own authority to limit its own quota usage. Consumer overrides cannot be used to grant more quota than would be allowed by admin overrides, producer overrides, or the default limit of the service.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
CreateConsumerOverrideRequestrequest=
CreateConsumerOverrideRequest.newBuilder()
.setParent("parent-995424086")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
QuotaOverrideresponse=serviceUsageClient.createConsumerOverrideAsync(request).get();
}
Parameter
Name Description
request CreateConsumerOverrideRequest

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

Returns
Type Description

createConsumerOverrideCallable()

publicfinalUnaryCallable<CreateConsumerOverrideRequest,Operation>createConsumerOverrideCallable()

Creates a consumer override. A consumer override is applied to the consumer on its own authority to limit its own quota usage. Consumer overrides cannot be used to grant more quota than would be allowed by admin overrides, producer overrides, or the default limit of the service.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
CreateConsumerOverrideRequestrequest=
CreateConsumerOverrideRequest.newBuilder()
.setParent("parent-995424086")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.createConsumerOverrideCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

createConsumerOverrideOperationCallable()

publicfinalOperationCallable<CreateConsumerOverrideRequest,QuotaOverride,OperationMetadata>createConsumerOverrideOperationCallable()

Creates a consumer override. A consumer override is applied to the consumer on its own authority to limit its own quota usage. Consumer overrides cannot be used to grant more quota than would be allowed by admin overrides, producer overrides, or the default limit of the service.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
CreateConsumerOverrideRequestrequest=
CreateConsumerOverrideRequest.newBuilder()
.setParent("parent-995424086")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<QuotaOverride,OperationMetadata>future=
serviceUsageClient.createConsumerOverrideOperationCallable().futureCall(request);
// Do something.
QuotaOverrideresponse=future.get();
}
Returns
Type Description

deleteAdminOverrideAsync(DeleteAdminOverrideRequest request)

publicfinalOperationFuture<Empty,OperationMetadata>deleteAdminOverrideAsync(DeleteAdminOverrideRequestrequest)

Deletes an admin override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DeleteAdminOverrideRequestrequest=
DeleteAdminOverrideRequest.newBuilder()
.setName("name3373707")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
serviceUsageClient.deleteAdminOverrideAsync(request).get();
}
Parameter
Name Description
request DeleteAdminOverrideRequest

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

Returns
Type Description

deleteAdminOverrideCallable()

publicfinalUnaryCallable<DeleteAdminOverrideRequest,Operation>deleteAdminOverrideCallable()

Deletes an admin override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DeleteAdminOverrideRequestrequest=
DeleteAdminOverrideRequest.newBuilder()
.setName("name3373707")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.deleteAdminOverrideCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

deleteAdminOverrideOperationCallable()

publicfinalOperationCallable<DeleteAdminOverrideRequest,Empty,OperationMetadata>deleteAdminOverrideOperationCallable()

Deletes an admin override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DeleteAdminOverrideRequestrequest=
DeleteAdminOverrideRequest.newBuilder()
.setName("name3373707")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<Empty,OperationMetadata>future=
serviceUsageClient.deleteAdminOverrideOperationCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

deleteConsumerOverrideAsync(DeleteConsumerOverrideRequest request)

publicfinalOperationFuture<Empty,OperationMetadata>deleteConsumerOverrideAsync(DeleteConsumerOverrideRequestrequest)

Deletes a consumer override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DeleteConsumerOverrideRequestrequest=
DeleteConsumerOverrideRequest.newBuilder()
.setName("name3373707")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
serviceUsageClient.deleteConsumerOverrideAsync(request).get();
}
Parameter
Name Description
request DeleteConsumerOverrideRequest

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

Returns
Type Description

deleteConsumerOverrideCallable()

publicfinalUnaryCallable<DeleteConsumerOverrideRequest,Operation>deleteConsumerOverrideCallable()

Deletes a consumer override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DeleteConsumerOverrideRequestrequest=
DeleteConsumerOverrideRequest.newBuilder()
.setName("name3373707")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.deleteConsumerOverrideCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

deleteConsumerOverrideOperationCallable()

publicfinalOperationCallable<DeleteConsumerOverrideRequest,Empty,OperationMetadata>deleteConsumerOverrideOperationCallable()

Deletes a consumer override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DeleteConsumerOverrideRequestrequest=
DeleteConsumerOverrideRequest.newBuilder()
.setName("name3373707")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<Empty,OperationMetadata>future=
serviceUsageClient.deleteConsumerOverrideOperationCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

disableServiceAsync(DisableServiceRequest request) (deprecated)

publicfinalOperationFuture<Empty,OperationMetadata>disableServiceAsync(DisableServiceRequestrequest)

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DisableServiceRequestrequest=
DisableServiceRequest.newBuilder().setName("name3373707").build();
serviceUsageClient.disableServiceAsync(request).get();
}
Parameter
Name Description
request DisableServiceRequest

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

Returns
Type Description

disableServiceCallable() (deprecated)

publicfinalUnaryCallable<DisableServiceRequest,Operation>disableServiceCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DisableServiceRequestrequest=
DisableServiceRequest.newBuilder().setName("name3373707").build();
ApiFuture<Operation>future=serviceUsageClient.disableServiceCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

disableServiceOperationCallable() (deprecated)

publicfinalOperationCallable<DisableServiceRequest,Empty,OperationMetadata>disableServiceOperationCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
DisableServiceRequestrequest=
DisableServiceRequest.newBuilder().setName("name3373707").build();
OperationFuture<Empty,OperationMetadata>future=
serviceUsageClient.disableServiceOperationCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

enableServiceAsync(EnableServiceRequest request) (deprecated)

publicfinalOperationFuture<Empty,OperationMetadata>enableServiceAsync(EnableServiceRequestrequest)

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
EnableServiceRequestrequest=
EnableServiceRequest.newBuilder().setName("name3373707").build();
serviceUsageClient.enableServiceAsync(request).get();
}
Parameter
Name Description
request EnableServiceRequest

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

Returns
Type Description

enableServiceCallable() (deprecated)

publicfinalUnaryCallable<EnableServiceRequest,Operation>enableServiceCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
EnableServiceRequestrequest=
EnableServiceRequest.newBuilder().setName("name3373707").build();
ApiFuture<Operation>future=serviceUsageClient.enableServiceCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

enableServiceOperationCallable() (deprecated)

publicfinalOperationCallable<EnableServiceRequest,Empty,OperationMetadata>enableServiceOperationCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Operation response type: google.protobuf.Empty

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
EnableServiceRequestrequest=
EnableServiceRequest.newBuilder().setName("name3373707").build();
OperationFuture<Empty,OperationMetadata>future=
serviceUsageClient.enableServiceOperationCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

generateServiceIdentityAsync(GenerateServiceIdentityRequest request)

publicfinalOperationFuture<ServiceIdentity,Empty>generateServiceIdentityAsync(GenerateServiceIdentityRequestrequest)

Generates service identity for service.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GenerateServiceIdentityRequestrequest=
GenerateServiceIdentityRequest.newBuilder().setParent("parent-995424086").build();
ServiceIdentityresponse=serviceUsageClient.generateServiceIdentityAsync(request).get();
}
Parameter
Name Description
request GenerateServiceIdentityRequest

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

Returns
Type Description

generateServiceIdentityCallable()

publicfinalUnaryCallable<GenerateServiceIdentityRequest,Operation>generateServiceIdentityCallable()

Generates service identity for service.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GenerateServiceIdentityRequestrequest=
GenerateServiceIdentityRequest.newBuilder().setParent("parent-995424086").build();
ApiFuture<Operation>future=
serviceUsageClient.generateServiceIdentityCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

generateServiceIdentityOperationCallable()

publicfinalOperationCallable<GenerateServiceIdentityRequest,ServiceIdentity,Empty>generateServiceIdentityOperationCallable()

Generates service identity for service.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GenerateServiceIdentityRequestrequest=
GenerateServiceIdentityRequest.newBuilder().setParent("parent-995424086").build();
OperationFuture<ServiceIdentity,Empty>future=
serviceUsageClient.generateServiceIdentityOperationCallable().futureCall(request);
// Do something.
ServiceIdentityresponse=future.get();
}
Returns
Type Description

getConsumerQuotaLimit(GetConsumerQuotaLimitRequest request)

publicfinalConsumerQuotaLimitgetConsumerQuotaLimit(GetConsumerQuotaLimitRequestrequest)

Retrieves a summary of quota information for a specific quota limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GetConsumerQuotaLimitRequestrequest=
GetConsumerQuotaLimitRequest.newBuilder()
.setName("name3373707")
.setView(QuotaView.forNumber(0))
.build();
ConsumerQuotaLimitresponse=serviceUsageClient.getConsumerQuotaLimit(request);
}
Parameter
Name Description
request GetConsumerQuotaLimitRequest

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

Returns
Type Description

getConsumerQuotaLimitCallable()

publicfinalUnaryCallable<GetConsumerQuotaLimitRequest,ConsumerQuotaLimit>getConsumerQuotaLimitCallable()

Retrieves a summary of quota information for a specific quota limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GetConsumerQuotaLimitRequestrequest=
GetConsumerQuotaLimitRequest.newBuilder()
.setName("name3373707")
.setView(QuotaView.forNumber(0))
.build();
ApiFuture<ConsumerQuotaLimit>future=
serviceUsageClient.getConsumerQuotaLimitCallable().futureCall(request);
// Do something.
ConsumerQuotaLimitresponse=future.get();
}
Returns
Type Description

getConsumerQuotaMetric(GetConsumerQuotaMetricRequest request)

publicfinalConsumerQuotaMetricgetConsumerQuotaMetric(GetConsumerQuotaMetricRequestrequest)

Retrieves a summary of quota information for a specific quota metric

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GetConsumerQuotaMetricRequestrequest=
GetConsumerQuotaMetricRequest.newBuilder()
.setName("name3373707")
.setView(QuotaView.forNumber(0))
.build();
ConsumerQuotaMetricresponse=serviceUsageClient.getConsumerQuotaMetric(request);
}
Parameter
Name Description
request GetConsumerQuotaMetricRequest

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

Returns
Type Description

getConsumerQuotaMetricCallable()

publicfinalUnaryCallable<GetConsumerQuotaMetricRequest,ConsumerQuotaMetric>getConsumerQuotaMetricCallable()

Retrieves a summary of quota information for a specific quota metric

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GetConsumerQuotaMetricRequestrequest=
GetConsumerQuotaMetricRequest.newBuilder()
.setName("name3373707")
.setView(QuotaView.forNumber(0))
.build();
ApiFuture<ConsumerQuotaMetric>future=
serviceUsageClient.getConsumerQuotaMetricCallable().futureCall(request);
// Do something.
ConsumerQuotaMetricresponse=future.get();
}
Returns
Type Description

getHttpJsonOperationsClient()

publicfinalOperationsClientgetHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description

getOperationsClient()

publicfinalOperationsClientgetOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description

getService(GetServiceRequest request) (deprecated)

publicfinalServicegetService(GetServiceRequestrequest)

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GetServiceRequestrequest=GetServiceRequest.newBuilder().setName("name3373707").build();
Serviceresponse=serviceUsageClient.getService(request);
}
Parameter
Name Description
request GetServiceRequest

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

Returns
Type Description

getServiceCallable() (deprecated)

publicfinalUnaryCallable<GetServiceRequest,Service>getServiceCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
GetServiceRequestrequest=GetServiceRequest.newBuilder().setName("name3373707").build();
ApiFuture<Service>future=serviceUsageClient.getServiceCallable().futureCall(request);
// Do something.
Serviceresponse=future.get();
}
Returns
Type Description

getSettings()

publicfinalServiceUsageSettingsgetSettings()
Returns
Type Description

getStub()

publicServiceUsageStubgetStub()
Returns
Type Description

importAdminOverridesAsync(ImportAdminOverridesRequest request)

publicfinalOperationFuture<ImportAdminOverridesResponse,ImportAdminOverridesMetadata>importAdminOverridesAsync(ImportAdminOverridesRequestrequest)

Creates or updates multiple admin overrides atomically, all on the same consumer, but on many different metrics or limits. The name field in the quota override message should not be set.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ImportAdminOverridesRequestrequest=
ImportAdminOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ImportAdminOverridesResponseresponse=
serviceUsageClient.importAdminOverridesAsync(request).get();
}
Parameter
Name Description
request ImportAdminOverridesRequest

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

Returns
Type Description

importAdminOverridesCallable()

publicfinalUnaryCallable<ImportAdminOverridesRequest,Operation>importAdminOverridesCallable()

Creates or updates multiple admin overrides atomically, all on the same consumer, but on many different metrics or limits. The name field in the quota override message should not be set.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ImportAdminOverridesRequestrequest=
ImportAdminOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.importAdminOverridesCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

importAdminOverridesOperationCallable()

publicfinalOperationCallable<ImportAdminOverridesRequest,ImportAdminOverridesResponse,ImportAdminOverridesMetadata>importAdminOverridesOperationCallable()

Creates or updates multiple admin overrides atomically, all on the same consumer, but on many different metrics or limits. The name field in the quota override message should not be set.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ImportAdminOverridesRequestrequest=
ImportAdminOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<ImportAdminOverridesResponse,ImportAdminOverridesMetadata>future=
serviceUsageClient.importAdminOverridesOperationCallable().futureCall(request);
// Do something.
ImportAdminOverridesResponseresponse=future.get();
}
Returns
Type Description

importConsumerOverridesAsync(ImportConsumerOverridesRequest request)

publicfinalOperationFuture<ImportConsumerOverridesResponse,ImportConsumerOverridesMetadata>importConsumerOverridesAsync(ImportConsumerOverridesRequestrequest)

Creates or updates multiple consumer overrides atomically, all on the same consumer, but on many different metrics or limits. The name field in the quota override message should not be set.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ImportConsumerOverridesRequestrequest=
ImportConsumerOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ImportConsumerOverridesResponseresponse=
serviceUsageClient.importConsumerOverridesAsync(request).get();
}
Parameter
Name Description
request ImportConsumerOverridesRequest

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

Returns
Type Description

importConsumerOverridesCallable()

publicfinalUnaryCallable<ImportConsumerOverridesRequest,Operation>importConsumerOverridesCallable()

Creates or updates multiple consumer overrides atomically, all on the same consumer, but on many different metrics or limits. The name field in the quota override message should not be set.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ImportConsumerOverridesRequestrequest=
ImportConsumerOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.importConsumerOverridesCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

importConsumerOverridesOperationCallable()

publicfinalOperationCallable<ImportConsumerOverridesRequest,ImportConsumerOverridesResponse,ImportConsumerOverridesMetadata>importConsumerOverridesOperationCallable()

Creates or updates multiple consumer overrides atomically, all on the same consumer, but on many different metrics or limits. The name field in the quota override message should not be set.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ImportConsumerOverridesRequestrequest=
ImportConsumerOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setForce(true)
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<ImportConsumerOverridesResponse,ImportConsumerOverridesMetadata>future=
serviceUsageClient.importConsumerOverridesOperationCallable().futureCall(request);
// Do something.
ImportConsumerOverridesResponseresponse=future.get();
}
Returns
Type Description

isShutdown()

publicbooleanisShutdown()
Returns
Type Description

isTerminated()

publicbooleanisTerminated()
Returns
Type Description

listAdminOverrides(ListAdminOverridesRequest request)

publicfinalServiceUsageClient.ListAdminOverridesPagedResponselistAdminOverrides(ListAdminOverridesRequestrequest)

Lists all admin overrides on this limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListAdminOverridesRequestrequest=
ListAdminOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(QuotaOverrideelement:serviceUsageClient.listAdminOverrides(request).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
request ListAdminOverridesRequest

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

Returns
Type Description

listAdminOverridesCallable()

publicfinalUnaryCallable<ListAdminOverridesRequest,ListAdminOverridesResponse>listAdminOverridesCallable()

Lists all admin overrides on this limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListAdminOverridesRequestrequest=
ListAdminOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListAdminOverridesResponseresponse=
serviceUsageClient.listAdminOverridesCallable().call(request);
for(QuotaOverrideelement:response.getOverridesList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
Returns
Type Description

listAdminOverridesPagedCallable()

publicfinalUnaryCallable<ListAdminOverridesRequest,ServiceUsageClient.ListAdminOverridesPagedResponse>listAdminOverridesPagedCallable()

Lists all admin overrides on this limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListAdminOverridesRequestrequest=
ListAdminOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<QuotaOverride>future=
serviceUsageClient.listAdminOverridesPagedCallable().futureCall(request);
// Do something.
for(QuotaOverrideelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
Returns
Type Description

listConsumerOverrides(ListConsumerOverridesRequest request)

publicfinalServiceUsageClient.ListConsumerOverridesPagedResponselistConsumerOverrides(ListConsumerOverridesRequestrequest)

Lists all consumer overrides on this limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListConsumerOverridesRequestrequest=
ListConsumerOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(QuotaOverrideelement:serviceUsageClient.listConsumerOverrides(request).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
request ListConsumerOverridesRequest

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

Returns
Type Description

listConsumerOverridesCallable()

publicfinalUnaryCallable<ListConsumerOverridesRequest,ListConsumerOverridesResponse>listConsumerOverridesCallable()

Lists all consumer overrides on this limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListConsumerOverridesRequestrequest=
ListConsumerOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListConsumerOverridesResponseresponse=
serviceUsageClient.listConsumerOverridesCallable().call(request);
for(QuotaOverrideelement:response.getOverridesList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
Returns
Type Description

listConsumerOverridesPagedCallable()

publicfinalUnaryCallable<ListConsumerOverridesRequest,ServiceUsageClient.ListConsumerOverridesPagedResponse>listConsumerOverridesPagedCallable()

Lists all consumer overrides on this limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListConsumerOverridesRequestrequest=
ListConsumerOverridesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<QuotaOverride>future=
serviceUsageClient.listConsumerOverridesPagedCallable().futureCall(request);
// Do something.
for(QuotaOverrideelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
Returns
Type Description

listConsumerQuotaMetrics(ListConsumerQuotaMetricsRequest request)

publicfinalServiceUsageClient.ListConsumerQuotaMetricsPagedResponselistConsumerQuotaMetrics(ListConsumerQuotaMetricsRequestrequest)

Retrieves a summary of all quota information visible to the service consumer, organized by service metric. Each metric includes information about all of its defined limits. Each limit includes the limit configuration (quota unit, preciseness, default value), the current effective limit value, and all of the overrides applied to the limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListConsumerQuotaMetricsRequestrequest=
ListConsumerQuotaMetricsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setView(QuotaView.forNumber(0))
.build();
for(ConsumerQuotaMetricelement:
serviceUsageClient.listConsumerQuotaMetrics(request).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
request ListConsumerQuotaMetricsRequest

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

Returns
Type Description

listConsumerQuotaMetricsCallable()

publicfinalUnaryCallable<ListConsumerQuotaMetricsRequest,ListConsumerQuotaMetricsResponse>listConsumerQuotaMetricsCallable()

Retrieves a summary of all quota information visible to the service consumer, organized by service metric. Each metric includes information about all of its defined limits. Each limit includes the limit configuration (quota unit, preciseness, default value), the current effective limit value, and all of the overrides applied to the limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListConsumerQuotaMetricsRequestrequest=
ListConsumerQuotaMetricsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setView(QuotaView.forNumber(0))
.build();
while(true){
ListConsumerQuotaMetricsResponseresponse=
serviceUsageClient.listConsumerQuotaMetricsCallable().call(request);
for(ConsumerQuotaMetricelement:response.getMetricsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
Returns
Type Description

listConsumerQuotaMetricsPagedCallable()

publicfinalUnaryCallable<ListConsumerQuotaMetricsRequest,ServiceUsageClient.ListConsumerQuotaMetricsPagedResponse>listConsumerQuotaMetricsPagedCallable()

Retrieves a summary of all quota information visible to the service consumer, organized by service metric. Each metric includes information about all of its defined limits. Each limit includes the limit configuration (quota unit, preciseness, default value), the current effective limit value, and all of the overrides applied to the limit.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListConsumerQuotaMetricsRequestrequest=
ListConsumerQuotaMetricsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setView(QuotaView.forNumber(0))
.build();
ApiFuture<ConsumerQuotaMetric>future=
serviceUsageClient.listConsumerQuotaMetricsPagedCallable().futureCall(request);
// Do something.
for(ConsumerQuotaMetricelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
Returns
Type Description

listServices(ListServicesRequest request) (deprecated)

publicfinalServiceUsageClient.ListServicesPagedResponselistServices(ListServicesRequestrequest)

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListServicesRequestrequest=
ListServicesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
for(Serviceelement:serviceUsageClient.listServices(request).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
request ListServicesRequest

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

Returns
Type Description

listServicesCallable() (deprecated)

publicfinalUnaryCallable<ListServicesRequest,ListServicesResponse>listServicesCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListServicesRequestrequest=
ListServicesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
while(true){
ListServicesResponseresponse=serviceUsageClient.listServicesCallable().call(request);
for(Serviceelement:response.getServicesList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
Returns
Type Description

listServicesPagedCallable() (deprecated)

publicfinalUnaryCallable<ListServicesRequest,ServiceUsageClient.ListServicesPagedResponse>listServicesPagedCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

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

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
ListServicesRequestrequest=
ListServicesRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
ApiFuture<Service>future=
serviceUsageClient.listServicesPagedCallable().futureCall(request);
// Do something.
for(Serviceelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
Returns
Type Description

shutdown()

publicvoidshutdown()

shutdownNow()

publicvoidshutdownNow()

updateAdminOverrideAsync(UpdateAdminOverrideRequest request)

publicfinalOperationFuture<QuotaOverride,OperationMetadata>updateAdminOverrideAsync(UpdateAdminOverrideRequestrequest)

Updates an admin override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
UpdateAdminOverrideRequestrequest=
UpdateAdminOverrideRequest.newBuilder()
.setName("name3373707")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.setUpdateMask(FieldMask.newBuilder().build())
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
QuotaOverrideresponse=serviceUsageClient.updateAdminOverrideAsync(request).get();
}
Parameter
Name Description
request UpdateAdminOverrideRequest

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

Returns
Type Description

updateAdminOverrideCallable()

publicfinalUnaryCallable<UpdateAdminOverrideRequest,Operation>updateAdminOverrideCallable()

Updates an admin override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
UpdateAdminOverrideRequestrequest=
UpdateAdminOverrideRequest.newBuilder()
.setName("name3373707")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.setUpdateMask(FieldMask.newBuilder().build())
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.updateAdminOverrideCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

updateAdminOverrideOperationCallable()

publicfinalOperationCallable<UpdateAdminOverrideRequest,QuotaOverride,OperationMetadata>updateAdminOverrideOperationCallable()

Updates an admin override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
UpdateAdminOverrideRequestrequest=
UpdateAdminOverrideRequest.newBuilder()
.setName("name3373707")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.setUpdateMask(FieldMask.newBuilder().build())
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<QuotaOverride,OperationMetadata>future=
serviceUsageClient.updateAdminOverrideOperationCallable().futureCall(request);
// Do something.
QuotaOverrideresponse=future.get();
}
Returns
Type Description

updateConsumerOverrideAsync(UpdateConsumerOverrideRequest request)

publicfinalOperationFuture<QuotaOverride,OperationMetadata>updateConsumerOverrideAsync(UpdateConsumerOverrideRequestrequest)

Updates a consumer override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
UpdateConsumerOverrideRequestrequest=
UpdateConsumerOverrideRequest.newBuilder()
.setName("name3373707")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.setUpdateMask(FieldMask.newBuilder().build())
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
QuotaOverrideresponse=serviceUsageClient.updateConsumerOverrideAsync(request).get();
}
Parameter
Name Description
request UpdateConsumerOverrideRequest

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

Returns
Type Description

updateConsumerOverrideCallable()

publicfinalUnaryCallable<UpdateConsumerOverrideRequest,Operation>updateConsumerOverrideCallable()

Updates a consumer override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
UpdateConsumerOverrideRequestrequest=
UpdateConsumerOverrideRequest.newBuilder()
.setName("name3373707")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.setUpdateMask(FieldMask.newBuilder().build())
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<Operation>future=
serviceUsageClient.updateConsumerOverrideCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

updateConsumerOverrideOperationCallable()

publicfinalOperationCallable<UpdateConsumerOverrideRequest,QuotaOverride,OperationMetadata>updateConsumerOverrideOperationCallable()

Updates a consumer override.

Sample code:


// 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.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(ServiceUsageClientserviceUsageClient=ServiceUsageClient.create()){
UpdateConsumerOverrideRequestrequest=
UpdateConsumerOverrideRequest.newBuilder()
.setName("name3373707")
.setOverride(QuotaOverride.newBuilder().build())
.setForce(true)
.setUpdateMask(FieldMask.newBuilder().build())
.addAllForceOnly(newArrayList<QuotaSafetyCheck>())
.build();
OperationFuture<QuotaOverride,OperationMetadata>future=
serviceUsageClient.updateConsumerOverrideOperationCallable().futureCall(request);
// Do something.
QuotaOverrideresponse=future.get();
}
Returns
Type Description

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月19日 UTC.