@BetaApi @Generated(value="by gapic-generator-java") public class CloudQuotasClient extends Object implements com.google.api.gax.core.BackgroundResource
- List/Get the metadata and current status of the quotas for a service. - Create/Update quota preferencess that declare the preferred quota values. - Check the status of a quota preference request. - List/Get pending and historical quota preference.
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
QuotaInfoName name =
QuotaInfoName.ofProjectLocationServiceQuotaInfoName(
"[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]");
QuotaInfo response = cloudQuotasClient.getQuotaInfo(name);
}
Note: close() needs to be called on the CloudQuotasClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
ListQuotaInfos |
Lists QuotaInfos of all quotas for a given project, folder or organization. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetQuotaInfo |
Retrieve the QuotaInfo of a quota for a project, folder or organization. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListQuotaPreferences |
Lists QuotaPreferences in a given project, folder or organization. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetQuotaPreference |
Gets details of a single QuotaPreference. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateQuotaPreference |
Creates a new QuotaPreference that declares the desired value for a quota. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateQuotaPreference |
Updates the parameters of a single QuotaPreference. It can updates the config in any states, not just the ones pending approval. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return 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 CloudQuotasSettings 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
CloudQuotasSettings cloudQuotasSettings =
CloudQuotasSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create(cloudQuotasSettings);
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
CloudQuotasSettings cloudQuotasSettings =
CloudQuotasSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create(cloudQuotasSettings);
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
CloudQuotasSettings cloudQuotasSettings = CloudQuotasSettings.newHttpJsonBuilder().build();
CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create(cloudQuotasSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
CloudQuotasClient.ListQuotaInfosFixedSizeCollection |
static class |
CloudQuotasClient.ListQuotaInfosPage |
static class |
CloudQuotasClient.ListQuotaInfosPagedResponse |
static class |
CloudQuotasClient.ListQuotaPreferencesFixedSizeCollection |
static class |
CloudQuotasClient.ListQuotaPreferencesPage |
static class |
CloudQuotasClient.ListQuotaPreferencesPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
CloudQuotasClient(CloudQuotasSettings settings)
Constructs an instance of CloudQuotasClient, using the given settings.
|
protected |
CloudQuotasClient(CloudQuotasStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static CloudQuotasClient |
create()
Constructs an instance of CloudQuotasClient with default settings.
|
static CloudQuotasClient |
create(CloudQuotasSettings settings)
Constructs an instance of CloudQuotasClient, using the given settings.
|
static CloudQuotasClient |
create(CloudQuotasStub stub)
Constructs an instance of CloudQuotasClient, using the given stub for making calls.
|
QuotaPreference |
createQuotaPreference(CreateQuotaPreferenceRequest request)
Creates a new QuotaPreference that declares the desired value for a quota.
|
QuotaPreference |
createQuotaPreference(LocationName parent,
QuotaPreference quotaPreference)
Creates a new QuotaPreference that declares the desired value for a quota.
|
QuotaPreference |
createQuotaPreference(LocationName parent,
QuotaPreference quotaPreference,
String quotaPreferenceId)
Creates a new QuotaPreference that declares the desired value for a quota.
|
QuotaPreference |
createQuotaPreference(String parent,
QuotaPreference quotaPreference)
Creates a new QuotaPreference that declares the desired value for a quota.
|
QuotaPreference |
createQuotaPreference(String parent,
QuotaPreference quotaPreference,
String quotaPreferenceId)
Creates a new QuotaPreference that declares the desired value for a quota.
|
com.google.api.gax.rpc.UnaryCallable<CreateQuotaPreferenceRequest,QuotaPreference> |
createQuotaPreferenceCallable()
Creates a new QuotaPreference that declares the desired value for a quota.
|
QuotaInfo |
getQuotaInfo(GetQuotaInfoRequest request)
Retrieve the QuotaInfo of a quota for a project, folder or organization.
|
QuotaInfo |
getQuotaInfo(QuotaInfoName name)
Retrieve the QuotaInfo of a quota for a project, folder or organization.
|
QuotaInfo |
getQuotaInfo(String name)
Retrieve the QuotaInfo of a quota for a project, folder or organization.
|
com.google.api.gax.rpc.UnaryCallable<GetQuotaInfoRequest,QuotaInfo> |
getQuotaInfoCallable()
Retrieve the QuotaInfo of a quota for a project, folder or organization.
|
QuotaPreference |
getQuotaPreference(GetQuotaPreferenceRequest request)
Gets details of a single QuotaPreference.
|
QuotaPreference |
getQuotaPreference(QuotaPreferenceName name)
Gets details of a single QuotaPreference.
|
QuotaPreference |
getQuotaPreference(String name)
Gets details of a single QuotaPreference.
|
com.google.api.gax.rpc.UnaryCallable<GetQuotaPreferenceRequest,QuotaPreference> |
getQuotaPreferenceCallable()
Gets details of a single QuotaPreference.
|
CloudQuotasSettings |
getSettings() |
CloudQuotasStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
CloudQuotasClient.ListQuotaInfosPagedResponse |
listQuotaInfos(ListQuotaInfosRequest request)
Lists QuotaInfos of all quotas for a given project, folder or organization.
|
CloudQuotasClient.ListQuotaInfosPagedResponse |
listQuotaInfos(ServiceName parent)
Lists QuotaInfos of all quotas for a given project, folder or organization.
|
CloudQuotasClient.ListQuotaInfosPagedResponse |
listQuotaInfos(String parent)
Lists QuotaInfos of all quotas for a given project, folder or organization.
|
com.google.api.gax.rpc.UnaryCallable<ListQuotaInfosRequest,ListQuotaInfosResponse> |
listQuotaInfosCallable()
Lists QuotaInfos of all quotas for a given project, folder or organization.
|
com.google.api.gax.rpc.UnaryCallable<ListQuotaInfosRequest,CloudQuotasClient.ListQuotaInfosPagedResponse> |
listQuotaInfosPagedCallable()
Lists QuotaInfos of all quotas for a given project, folder or organization.
|
CloudQuotasClient.ListQuotaPreferencesPagedResponse |
listQuotaPreferences(ListQuotaPreferencesRequest request)
Lists QuotaPreferences in a given project, folder or organization.
|
CloudQuotasClient.ListQuotaPreferencesPagedResponse |
listQuotaPreferences(LocationName parent)
Lists QuotaPreferences in a given project, folder or organization.
|
CloudQuotasClient.ListQuotaPreferencesPagedResponse |
listQuotaPreferences(String parent)
Lists QuotaPreferences in a given project, folder or organization.
|
com.google.api.gax.rpc.UnaryCallable<ListQuotaPreferencesRequest,ListQuotaPreferencesResponse> |
listQuotaPreferencesCallable()
Lists QuotaPreferences in a given project, folder or organization.
|
com.google.api.gax.rpc.UnaryCallable<ListQuotaPreferencesRequest,CloudQuotasClient.ListQuotaPreferencesPagedResponse> |
listQuotaPreferencesPagedCallable()
Lists QuotaPreferences in a given project, folder or organization.
|
void |
shutdown() |
void |
shutdownNow() |
QuotaPreference |
updateQuotaPreference(QuotaPreference quotaPreference,
com.google.protobuf.FieldMask updateMask)
Updates the parameters of a single QuotaPreference.
|
QuotaPreference |
updateQuotaPreference(UpdateQuotaPreferenceRequest request)
Updates the parameters of a single QuotaPreference.
|
com.google.api.gax.rpc.UnaryCallable<UpdateQuotaPreferenceRequest,QuotaPreference> |
updateQuotaPreferenceCallable()
Updates the parameters of a single QuotaPreference.
|
protected CloudQuotasClient(CloudQuotasSettings settings) throws IOException
IOExceptionprotected CloudQuotasClient(CloudQuotasStub stub)
public static final CloudQuotasClient create() throws IOException
IOExceptionpublic static final CloudQuotasClient create(CloudQuotasSettings settings) throws IOException
IOExceptionpublic static final CloudQuotasClient create(CloudQuotasStub stub)
public final CloudQuotasSettings getSettings()
public CloudQuotasStub getStub()
public final CloudQuotasClient.ListQuotaInfosPagedResponse listQuotaInfos(ServiceName parent)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
ServiceName parent =
ServiceName.ofProjectLocationServiceName("[PROJECT]", "[LOCATION]", "[SERVICE]");
for (QuotaInfo element : cloudQuotasClient.listQuotaInfos(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Parent value of QuotaInfo resources. Listing across different resource
containers (such as 'projects/-') is not allowed.
Example names: `projects/123/locations/global/services/compute.googleapis.com` `folders/234/locations/global/services/compute.googleapis.com` `organizations/345/locations/global/services/compute.googleapis.com`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudQuotasClient.ListQuotaInfosPagedResponse listQuotaInfos(String parent)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
String parent =
ServiceName.ofProjectLocationServiceName("[PROJECT]", "[LOCATION]", "[SERVICE]")
.toString();
for (QuotaInfo element : cloudQuotasClient.listQuotaInfos(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Parent value of QuotaInfo resources. Listing across different resource
containers (such as 'projects/-') is not allowed.
Example names: `projects/123/locations/global/services/compute.googleapis.com` `folders/234/locations/global/services/compute.googleapis.com` `organizations/345/locations/global/services/compute.googleapis.com`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudQuotasClient.ListQuotaInfosPagedResponse listQuotaInfos(ListQuotaInfosRequest request)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
ListQuotaInfosRequest request =
ListQuotaInfosRequest.newBuilder()
.setParent(
ServiceName.ofProjectLocationServiceName("[PROJECT]", "[LOCATION]", "[SERVICE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (QuotaInfo element : cloudQuotasClient.listQuotaInfos(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListQuotaInfosRequest,CloudQuotasClient.ListQuotaInfosPagedResponse> listQuotaInfosPagedCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
ListQuotaInfosRequest request =
ListQuotaInfosRequest.newBuilder()
.setParent(
ServiceName.ofProjectLocationServiceName("[PROJECT]", "[LOCATION]", "[SERVICE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<QuotaInfo> future =
cloudQuotasClient.listQuotaInfosPagedCallable().futureCall(request);
// Do something.
for (QuotaInfo element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListQuotaInfosRequest,ListQuotaInfosResponse> listQuotaInfosCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
ListQuotaInfosRequest request =
ListQuotaInfosRequest.newBuilder()
.setParent(
ServiceName.ofProjectLocationServiceName("[PROJECT]", "[LOCATION]", "[SERVICE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListQuotaInfosResponse response = cloudQuotasClient.listQuotaInfosCallable().call(request);
for (QuotaInfo element : response.getQuotaInfosList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final QuotaInfo getQuotaInfo(QuotaInfoName name)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
QuotaInfoName name =
QuotaInfoName.ofProjectLocationServiceQuotaInfoName(
"[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]");
QuotaInfo response = cloudQuotasClient.getQuotaInfo(name);
}
name - Required. The resource name of the quota info.
An example name: `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaInfo getQuotaInfo(String name)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
String name =
QuotaInfoName.ofProjectLocationServiceQuotaInfoName(
"[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]")
.toString();
QuotaInfo response = cloudQuotasClient.getQuotaInfo(name);
}
name - Required. The resource name of the quota info.
An example name: `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaInfo getQuotaInfo(GetQuotaInfoRequest request)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
GetQuotaInfoRequest request =
GetQuotaInfoRequest.newBuilder()
.setName(
QuotaInfoName.ofProjectLocationServiceQuotaInfoName(
"[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]")
.toString())
.build();
QuotaInfo response = cloudQuotasClient.getQuotaInfo(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetQuotaInfoRequest,QuotaInfo> getQuotaInfoCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
GetQuotaInfoRequest request =
GetQuotaInfoRequest.newBuilder()
.setName(
QuotaInfoName.ofProjectLocationServiceQuotaInfoName(
"[PROJECT]", "[LOCATION]", "[SERVICE]", "[QUOTA_INFO]")
.toString())
.build();
ApiFuture<QuotaInfo> future = cloudQuotasClient.getQuotaInfoCallable().futureCall(request);
// Do something.
QuotaInfo response = future.get();
}
public final CloudQuotasClient.ListQuotaPreferencesPagedResponse listQuotaPreferences(LocationName parent)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
LocationName parent = LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]");
for (QuotaPreference element : cloudQuotasClient.listQuotaPreferences(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Parent value of QuotaPreference resources. Listing across different
resource containers (such as 'projects/-') is not allowed.
When the value starts with 'folders' or 'organizations', it lists the QuotaPreferences for org quotas in the container. It does not list the QuotaPreferences in the descendant projects of the container.
Example parents: `projects/123/locations/global`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudQuotasClient.ListQuotaPreferencesPagedResponse listQuotaPreferences(String parent)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
String parent = LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString();
for (QuotaPreference element : cloudQuotasClient.listQuotaPreferences(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. Parent value of QuotaPreference resources. Listing across different
resource containers (such as 'projects/-') is not allowed.
When the value starts with 'folders' or 'organizations', it lists the QuotaPreferences for org quotas in the container. It does not list the QuotaPreferences in the descendant projects of the container.
Example parents: `projects/123/locations/global`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudQuotasClient.ListQuotaPreferencesPagedResponse listQuotaPreferences(ListQuotaPreferencesRequest request)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
ListQuotaPreferencesRequest request =
ListQuotaPreferencesRequest.newBuilder()
.setParent(LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
for (QuotaPreference element : cloudQuotasClient.listQuotaPreferences(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListQuotaPreferencesRequest,CloudQuotasClient.ListQuotaPreferencesPagedResponse> listQuotaPreferencesPagedCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
ListQuotaPreferencesRequest request =
ListQuotaPreferencesRequest.newBuilder()
.setParent(LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
ApiFuture<QuotaPreference> future =
cloudQuotasClient.listQuotaPreferencesPagedCallable().futureCall(request);
// Do something.
for (QuotaPreference element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListQuotaPreferencesRequest,ListQuotaPreferencesResponse> listQuotaPreferencesCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
ListQuotaPreferencesRequest request =
ListQuotaPreferencesRequest.newBuilder()
.setParent(LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.build();
while (true) {
ListQuotaPreferencesResponse response =
cloudQuotasClient.listQuotaPreferencesCallable().call(request);
for (QuotaPreference element : response.getQuotaPreferencesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final QuotaPreference getQuotaPreference(QuotaPreferenceName name)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
QuotaPreferenceName name =
QuotaPreferenceName.ofProjectLocationQuotaPreferenceName(
"[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]");
QuotaPreference response = cloudQuotasClient.getQuotaPreference(name);
}
name - Required. Name of the resource
Example name: `projects/123/locations/global/quota_preferences/my-config-for-us-east1`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaPreference getQuotaPreference(String name)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
String name =
QuotaPreferenceName.ofProjectLocationQuotaPreferenceName(
"[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]")
.toString();
QuotaPreference response = cloudQuotasClient.getQuotaPreference(name);
}
name - Required. Name of the resource
Example name: `projects/123/locations/global/quota_preferences/my-config-for-us-east1`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaPreference getQuotaPreference(GetQuotaPreferenceRequest request)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
GetQuotaPreferenceRequest request =
GetQuotaPreferenceRequest.newBuilder()
.setName(
QuotaPreferenceName.ofProjectLocationQuotaPreferenceName(
"[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]")
.toString())
.build();
QuotaPreference response = cloudQuotasClient.getQuotaPreference(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetQuotaPreferenceRequest,QuotaPreference> getQuotaPreferenceCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
GetQuotaPreferenceRequest request =
GetQuotaPreferenceRequest.newBuilder()
.setName(
QuotaPreferenceName.ofProjectLocationQuotaPreferenceName(
"[PROJECT]", "[LOCATION]", "[QUOTA_PREFERENCE]")
.toString())
.build();
ApiFuture<QuotaPreference> future =
cloudQuotasClient.getQuotaPreferenceCallable().futureCall(request);
// Do something.
QuotaPreference response = future.get();
}
public final QuotaPreference createQuotaPreference(LocationName parent, QuotaPreference quotaPreference)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
LocationName parent = LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]");
QuotaPreference quotaPreference = QuotaPreference.newBuilder().build();
QuotaPreference response = cloudQuotasClient.createQuotaPreference(parent, quotaPreference);
}
parent - Required. Value for parent.
Example: `projects/123/locations/global`
quotaPreference - Required. The resource being createdcom.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaPreference createQuotaPreference(String parent, QuotaPreference quotaPreference)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
String parent = LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString();
QuotaPreference quotaPreference = QuotaPreference.newBuilder().build();
QuotaPreference response = cloudQuotasClient.createQuotaPreference(parent, quotaPreference);
}
parent - Required. Value for parent.
Example: `projects/123/locations/global`
quotaPreference - Required. The resource being createdcom.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaPreference createQuotaPreference(LocationName parent, QuotaPreference quotaPreference, String quotaPreferenceId)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
LocationName parent = LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]");
QuotaPreference quotaPreference = QuotaPreference.newBuilder().build();
String quotaPreferenceId = "quotaPreferenceId-948332050";
QuotaPreference response =
cloudQuotasClient.createQuotaPreference(parent, quotaPreference, quotaPreferenceId);
}
parent - Required. Value for parent.
Example: `projects/123/locations/global`
quotaPreference - Required. The resource being createdquotaPreferenceId - Optional. Id of the requesting object, must be unique under its
parent. If client does not set this field, the service will generate one.com.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaPreference createQuotaPreference(String parent, QuotaPreference quotaPreference, String quotaPreferenceId)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
String parent = LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString();
QuotaPreference quotaPreference = QuotaPreference.newBuilder().build();
String quotaPreferenceId = "quotaPreferenceId-948332050";
QuotaPreference response =
cloudQuotasClient.createQuotaPreference(parent, quotaPreference, quotaPreferenceId);
}
parent - Required. Value for parent.
Example: `projects/123/locations/global`
quotaPreference - Required. The resource being createdquotaPreferenceId - Optional. Id of the requesting object, must be unique under its
parent. If client does not set this field, the service will generate one.com.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaPreference createQuotaPreference(CreateQuotaPreferenceRequest request)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
CreateQuotaPreferenceRequest request =
CreateQuotaPreferenceRequest.newBuilder()
.setParent(LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString())
.setQuotaPreferenceId("quotaPreferenceId-948332050")
.setQuotaPreference(QuotaPreference.newBuilder().build())
.addAllIgnoreSafetyChecks(new ArrayList<QuotaSafetyCheck>())
.build();
QuotaPreference response = cloudQuotasClient.createQuotaPreference(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateQuotaPreferenceRequest,QuotaPreference> createQuotaPreferenceCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
CreateQuotaPreferenceRequest request =
CreateQuotaPreferenceRequest.newBuilder()
.setParent(LocationName.ofProjectLocationName("[PROJECT]", "[LOCATION]").toString())
.setQuotaPreferenceId("quotaPreferenceId-948332050")
.setQuotaPreference(QuotaPreference.newBuilder().build())
.addAllIgnoreSafetyChecks(new ArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<QuotaPreference> future =
cloudQuotasClient.createQuotaPreferenceCallable().futureCall(request);
// Do something.
QuotaPreference response = future.get();
}
public final QuotaPreference updateQuotaPreference(QuotaPreference quotaPreference, com.google.protobuf.FieldMask updateMask)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
QuotaPreference quotaPreference = QuotaPreference.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
QuotaPreference response =
cloudQuotasClient.updateQuotaPreference(quotaPreference, updateMask);
}
quotaPreference - Required. The resource being updatedupdateMask - Optional. Field mask is used to specify the fields to be overwritten in the
QuotaPreference resource by the update. The fields specified in the update_mask are
relative to the resource, not the full request. A field will be overwritten if it is in the
mask. If the user does not provide a mask then all fields will be overwritten.com.google.api.gax.rpc.ApiException - if the remote call failspublic final QuotaPreference updateQuotaPreference(UpdateQuotaPreferenceRequest request)
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
UpdateQuotaPreferenceRequest request =
UpdateQuotaPreferenceRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setQuotaPreference(QuotaPreference.newBuilder().build())
.setAllowMissing(true)
.setValidateOnly(true)
.addAllIgnoreSafetyChecks(new ArrayList<QuotaSafetyCheck>())
.build();
QuotaPreference response = cloudQuotasClient.updateQuotaPreference(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateQuotaPreferenceRequest,QuotaPreference> updateQuotaPreferenceCallable()
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 (CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create()) {
UpdateQuotaPreferenceRequest request =
UpdateQuotaPreferenceRequest.newBuilder()
.setUpdateMask(FieldMask.newBuilder().build())
.setQuotaPreference(QuotaPreference.newBuilder().build())
.setAllowMissing(true)
.setValidateOnly(true)
.addAllIgnoreSafetyChecks(new ArrayList<QuotaSafetyCheck>())
.build();
ApiFuture<QuotaPreference> future =
cloudQuotasClient.updateQuotaPreferenceCallable().futureCall(request);
// Do something.
QuotaPreference response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.