- 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: + * + *
{@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); + * } + * }+ * + *
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(). + * + *
The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *
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: + * + *
{@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 + * CloudQuotasSettings cloudQuotasSettings = + * CloudQuotasSettings.newBuilder() + * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + * .build(); + * CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create(cloudQuotasSettings); + * }+ * + *
To customize the endpoint: + * + *
{@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 + * 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: + * + *
{@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 + * CloudQuotasSettings cloudQuotasSettings = CloudQuotasSettings.newHttpJsonBuilder().build(); + * CloudQuotasClient cloudQuotasClient = CloudQuotasClient.create(cloudQuotasSettings); + * }+ * + *
Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class CloudQuotasClient implements BackgroundResource { + private final CloudQuotasSettings settings; + private final CloudQuotasStub stub; + + /** Constructs an instance of CloudQuotasClient with default settings. */ + public static final CloudQuotasClient create() throws IOException { + return create(CloudQuotasSettings.newBuilder().build()); + } + + /** + * Constructs an instance of CloudQuotasClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final CloudQuotasClient create(CloudQuotasSettings settings) throws IOException { + return new CloudQuotasClient(settings); + } + + /** + * Constructs an instance of CloudQuotasClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(CloudQuotasSettings). + */ + public static final CloudQuotasClient create(CloudQuotasStub stub) { + return new CloudQuotasClient(stub); + } + + /** + * Constructs an instance of CloudQuotasClient, 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. + */ + protected CloudQuotasClient(CloudQuotasSettings settings) throws IOException { + this.settings = settings; + this.stub = ((CloudQuotasStubSettings) settings.getStubSettings()).createStub(); + } + + protected CloudQuotasClient(CloudQuotasStub stub) { + this.settings = null; + this.stub = stub; + } + + public final CloudQuotasSettings getSettings() { + return settings; + } + + public CloudQuotasStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists QuotaInfos of all quotas for a given project, folder or organization. + * + *
Sample code: + * + *
{@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); + * } + * } + * }+ * + * @param 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` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListQuotaInfosPagedResponse listQuotaInfos(ServiceName parent) { + ListQuotaInfosRequest request = + ListQuotaInfosRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listQuotaInfos(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists QuotaInfos of all quotas for a given project, folder or organization. + * + *
Sample code: + * + *
{@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); + * } + * } + * }+ * + * @param 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` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListQuotaInfosPagedResponse listQuotaInfos(String parent) { + ListQuotaInfosRequest request = ListQuotaInfosRequest.newBuilder().setParent(parent).build(); + return listQuotaInfos(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists QuotaInfos of all quotas for a given project, folder or organization. + * + *
Sample code: + * + *
{@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); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListQuotaInfosPagedResponse listQuotaInfos(ListQuotaInfosRequest request) { + return listQuotaInfosPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists QuotaInfos of all quotas for a given project, folder or organization. + * + *
Sample code: + * + *
{@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+ */ + public final UnaryCallablefuture = + * cloudQuotasClient.listQuotaInfosPagedCallable().futureCall(request); + * // Do something. + * for (QuotaInfo element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@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 UnaryCallable
Sample code: + * + *
{@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); + * } + * }+ * + * @param name Required. The resource name of the quota info. + *
An example name: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaInfo getQuotaInfo(QuotaInfoName name) { + GetQuotaInfoRequest request = + GetQuotaInfoRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getQuotaInfo(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieve the QuotaInfo of a quota for a project, folder or organization. + * + *
Sample code: + * + *
{@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); + * } + * }+ * + * @param name Required. The resource name of the quota info. + *
An example name: + * `projects/123/locations/global/services/compute.googleapis.com/quotaInfos/CpusPerProjectPerRegion` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaInfo getQuotaInfo(String name) { + GetQuotaInfoRequest request = GetQuotaInfoRequest.newBuilder().setName(name).build(); + return getQuotaInfo(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieve the QuotaInfo of a quota for a project, folder or organization. + * + *
Sample code: + * + *
{@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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaInfo getQuotaInfo(GetQuotaInfoRequest request) { + return getQuotaInfoCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieve the QuotaInfo of a quota for a project, folder or organization. + * + *
Sample code: + * + *
{@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+ */ + public final UnaryCallablefuture = cloudQuotasClient.getQuotaInfoCallable().futureCall(request); + * // Do something. + * QuotaInfo response = future.get(); + * } + * }
Sample code: + * + *
{@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); + * } + * } + * }+ * + * @param 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` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListQuotaPreferencesPagedResponse listQuotaPreferences(LocationName parent) { + ListQuotaPreferencesRequest request = + ListQuotaPreferencesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listQuotaPreferences(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists QuotaPreferences in a given project, folder or organization. + * + *
Sample code: + * + *
{@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); + * } + * } + * }+ * + * @param 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` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListQuotaPreferencesPagedResponse listQuotaPreferences(String parent) { + ListQuotaPreferencesRequest request = + ListQuotaPreferencesRequest.newBuilder().setParent(parent).build(); + return listQuotaPreferences(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists QuotaPreferences in a given project, folder or organization. + * + *
Sample code: + * + *
{@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); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListQuotaPreferencesPagedResponse listQuotaPreferences( + ListQuotaPreferencesRequest request) { + return listQuotaPreferencesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists QuotaPreferences in a given project, folder or organization. + * + *
Sample code: + * + *
{@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+ */ + public final UnaryCallablefuture = + * cloudQuotasClient.listQuotaPreferencesPagedCallable().futureCall(request); + * // Do something. + * for (QuotaPreference element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@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 UnaryCallable
Sample code: + * + *
{@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); + * } + * }+ * + * @param name Required. Name of the resource + *
Example name: `projects/123/locations/global/quota_preferences/my-config-for-us-east1` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference getQuotaPreference(QuotaPreferenceName name) { + GetQuotaPreferenceRequest request = + GetQuotaPreferenceRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getQuotaPreference(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets details of a single QuotaPreference. + * + *
Sample code: + * + *
{@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); + * } + * }+ * + * @param name Required. Name of the resource + *
Example name: `projects/123/locations/global/quota_preferences/my-config-for-us-east1` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference getQuotaPreference(String name) { + GetQuotaPreferenceRequest request = + GetQuotaPreferenceRequest.newBuilder().setName(name).build(); + return getQuotaPreference(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets details of a single QuotaPreference. + * + *
Sample code: + * + *
{@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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference getQuotaPreference(GetQuotaPreferenceRequest request) { + return getQuotaPreferenceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets details of a single QuotaPreference. + * + *
Sample code: + * + *
{@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+ */ + public final UnaryCallablefuture = + * cloudQuotasClient.getQuotaPreferenceCallable().futureCall(request); + * // Do something. + * QuotaPreference response = future.get(); + * } + * }
Sample code: + * + *
{@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); + * } + * }+ * + * @param parent Required. Value for parent. + *
Example: `projects/123/locations/global` + * @param quotaPreference Required. The resource being created + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference createQuotaPreference( + LocationName parent, QuotaPreference quotaPreference) { + CreateQuotaPreferenceRequest request = + CreateQuotaPreferenceRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setQuotaPreference(quotaPreference) + .build(); + return createQuotaPreference(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new QuotaPreference that declares the desired value for a quota. + * + *
Sample code: + * + *
{@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); + * } + * }+ * + * @param parent Required. Value for parent. + *
Example: `projects/123/locations/global` + * @param quotaPreference Required. The resource being created + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference createQuotaPreference( + String parent, QuotaPreference quotaPreference) { + CreateQuotaPreferenceRequest request = + CreateQuotaPreferenceRequest.newBuilder() + .setParent(parent) + .setQuotaPreference(quotaPreference) + .build(); + return createQuotaPreference(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new QuotaPreference that declares the desired value for a quota. + * + *
Sample code: + * + *
{@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); + * } + * }+ * + * @param parent Required. Value for parent. + *
Example: `projects/123/locations/global` + * @param quotaPreference Required. The resource being created + * @param quotaPreferenceId Optional. Id of the requesting object, must be unique under its + * parent. If client does not set this field, the service will generate one. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference createQuotaPreference( + LocationName parent, QuotaPreference quotaPreference, String quotaPreferenceId) { + CreateQuotaPreferenceRequest request = + CreateQuotaPreferenceRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setQuotaPreference(quotaPreference) + .setQuotaPreferenceId(quotaPreferenceId) + .build(); + return createQuotaPreference(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new QuotaPreference that declares the desired value for a quota. + * + *
Sample code: + * + *
{@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); + * } + * }+ * + * @param parent Required. Value for parent. + *
Example: `projects/123/locations/global` + * @param quotaPreference Required. The resource being created + * @param quotaPreferenceId Optional. Id of the requesting object, must be unique under its + * parent. If client does not set this field, the service will generate one. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference createQuotaPreference( + String parent, QuotaPreference quotaPreference, String quotaPreferenceId) { + CreateQuotaPreferenceRequest request = + CreateQuotaPreferenceRequest.newBuilder() + .setParent(parent) + .setQuotaPreference(quotaPreference) + .setQuotaPreferenceId(quotaPreferenceId) + .build(); + return createQuotaPreference(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new QuotaPreference that declares the desired value for a quota. + * + *
Sample code: + * + *
{@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+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference createQuotaPreference(CreateQuotaPreferenceRequest request) { + return createQuotaPreferenceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new QuotaPreference that declares the desired value for a quota. + * + *()) + * .build(); + * QuotaPreference response = cloudQuotasClient.createQuotaPreference(request); + * } + * }
Sample code: + * + *
{@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+ */ + public final UnaryCallable()) + * .build(); + * ApiFuture future = + * cloudQuotasClient.createQuotaPreferenceCallable().futureCall(request); + * // Do something. + * QuotaPreference response = future.get(); + * } + * }
Sample code: + * + *
{@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); + * } + * }+ * + * @param quotaPreference Required. The resource being updated + * @param updateMask 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. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference updateQuotaPreference( + QuotaPreference quotaPreference, FieldMask updateMask) { + UpdateQuotaPreferenceRequest request = + UpdateQuotaPreferenceRequest.newBuilder() + .setQuotaPreference(quotaPreference) + .setUpdateMask(updateMask) + .build(); + return updateQuotaPreference(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the parameters of a single QuotaPreference. It can updates the config in any states, + * not just the ones pending approval. + * + *
Sample code: + * + *
{@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+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final QuotaPreference updateQuotaPreference(UpdateQuotaPreferenceRequest request) { + return updateQuotaPreferenceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the parameters of a single QuotaPreference. It can updates the config in any states, + * not just the ones pending approval. + * + *()) + * .build(); + * QuotaPreference response = cloudQuotasClient.updateQuotaPreference(request); + * } + * }
Sample code: + * + *
{@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+ */ + public final UnaryCallable()) + * .build(); + * ApiFuture future = + * cloudQuotasClient.updateQuotaPreferenceCallable().futureCall(request); + * // Do something. + * QuotaPreference response = future.get(); + * } + * }
The default instance has everything set to sensible defaults: + * + *
The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *
For example, to set the total timeout of getQuotaInfo to 30 seconds: + * + *
{@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 + * CloudQuotasSettings.Builder cloudQuotasSettingsBuilder = CloudQuotasSettings.newBuilder(); + * cloudQuotasSettingsBuilder + * .getQuotaInfoSettings() + * .setRetrySettings( + * cloudQuotasSettingsBuilder + * .getQuotaInfoSettings() + * .getRetrySettings() + * .toBuilder() + * .setTotalTimeout(Duration.ofSeconds(30)) + * .build()); + * CloudQuotasSettings cloudQuotasSettings = cloudQuotasSettingsBuilder.build(); + * }+ */ +@Generated("by gapic-generator-java") +public class CloudQuotasSettings extends ClientSettings
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction The interfaces provided are listed below, along with usage samples.
+ *
+ * ======================= CloudQuotasClient =======================
+ *
+ * Service Description: The Cloud Quotas API is an infrastructure service for Google Cloud that
+ * lets service consumers list and manage their resource usage limits.
+ *
+ * - 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.
+ *
+ * Sample for CloudQuotasClient:
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class CloudQuotasStub implements BackgroundResource {
+
+ public UnaryCallable The default instance has everything set to sensible defaults:
+ *
+ * The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ * For example, to set the total timeout of getQuotaInfo to 30 seconds:
+ *
+ * Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcCloudQuotasCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcCloudQuotasStub extends CloudQuotasStub {
+ private static final MethodDescriptor This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonCloudQuotasCallableFactory
+ implements HttpJsonStubCallableFactory This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonCloudQuotasStub extends CloudQuotasStub {
+ private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
+
+ private static final ApiMethodDescriptor{@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);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.api.cloudquotas.v1;
+
+import javax.annotation.Generated;
diff --git a/java-cloudquotas/google-cloud-cloudquotas/src/main/java/com/google/api/cloudquotas/v1/stub/CloudQuotasStub.java b/java-cloudquotas/google-cloud-cloudquotas/src/main/java/com/google/api/cloudquotas/v1/stub/CloudQuotasStub.java
new file mode 100644
index 000000000000..a699f000b7e3
--- /dev/null
+++ b/java-cloudquotas/google-cloud-cloudquotas/src/main/java/com/google/api/cloudquotas/v1/stub/CloudQuotasStub.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.api.cloudquotas.v1.stub;
+
+import static com.google.api.cloudquotas.v1.CloudQuotasClient.ListQuotaInfosPagedResponse;
+import static com.google.api.cloudquotas.v1.CloudQuotasClient.ListQuotaPreferencesPagedResponse;
+
+import com.google.api.cloudquotas.v1.CreateQuotaPreferenceRequest;
+import com.google.api.cloudquotas.v1.GetQuotaInfoRequest;
+import com.google.api.cloudquotas.v1.GetQuotaPreferenceRequest;
+import com.google.api.cloudquotas.v1.ListQuotaInfosRequest;
+import com.google.api.cloudquotas.v1.ListQuotaInfosResponse;
+import com.google.api.cloudquotas.v1.ListQuotaPreferencesRequest;
+import com.google.api.cloudquotas.v1.ListQuotaPreferencesResponse;
+import com.google.api.cloudquotas.v1.QuotaInfo;
+import com.google.api.cloudquotas.v1.QuotaPreference;
+import com.google.api.cloudquotas.v1.UpdateQuotaPreferenceRequest;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.UnaryCallable;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the CloudQuotas service API.
+ *
+ *
+ *
+ *
+ * {@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
+ * CloudQuotasStubSettings.Builder cloudQuotasSettingsBuilder =
+ * CloudQuotasStubSettings.newBuilder();
+ * cloudQuotasSettingsBuilder
+ * .getQuotaInfoSettings()
+ * .setRetrySettings(
+ * cloudQuotasSettingsBuilder
+ * .getQuotaInfoSettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * CloudQuotasStubSettings cloudQuotasSettings = cloudQuotasSettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class CloudQuotasStubSettings extends StubSettings