All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.cloud.retail.v2beta.ControlServiceClient Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2024 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.cloud.retail.v2beta;

import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.retail.v2beta.stub.ControlServiceStub;
import com.google.cloud.retail.v2beta.stub.ControlServiceStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
 * Service Description: Service for modifying Control.
 *
 * 

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
 *   CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]");
 *   Control control = Control.newBuilder().build();
 *   String controlId = "controlId-395080872";
 *   Control response = controlServiceClient.createControl(parent, control, controlId);
 * }
 * }
* *

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

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Methods
MethodDescriptionMethod Variants

CreateControl

Creates a Control. *

If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an ALREADY_EXISTS error is returned.

*

Request object method variants only take one parameter, a request object, which must be constructed before the call.

*
    *
  • createControl(CreateControlRequest request) *

*

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

*
    *
  • createControl(CatalogName parent, Control control, String controlId) *

  • createControl(String parent, Control control, String controlId) *

*

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

*
    *
  • createControlCallable() *

*

DeleteControl

Deletes a Control. *

If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.

*

Request object method variants only take one parameter, a request object, which must be constructed before the call.

*
    *
  • deleteControl(DeleteControlRequest request) *

*

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

*
    *
  • deleteControl(ControlName name) *

  • deleteControl(String name) *

*

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

*
    *
  • deleteControlCallable() *

*

UpdateControl

Updates a Control. *

[Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to update does not exist, a NOT_FOUND error is returned.

*

Request object method variants only take one parameter, a request object, which must be constructed before the call.

*
    *
  • updateControl(UpdateControlRequest request) *

*

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

*
    *
  • updateControl(Control control, FieldMask updateMask) *

*

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

*
    *
  • updateControlCallable() *

*

GetControl

Gets a Control.

*

Request object method variants only take one parameter, a request object, which must be constructed before the call.

*
    *
  • getControl(GetControlRequest request) *

*

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

*
    *
  • getControl(ControlName name) *

  • getControl(String name) *

*

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

*
    *
  • getControlCallable() *

*

ListControls

Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog].

*

Request object method variants only take one parameter, a request object, which must be constructed before the call.

*
    *
  • listControls(ListControlsRequest request) *

*

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

*
    *
  • listControls(CatalogName parent) *

  • listControls(String parent) *

*

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

*
    *
  • listControlsPagedCallable() *

  • listControlsCallable() *

*
* *

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 ControlServiceSettings 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
 * ControlServiceSettings controlServiceSettings =
 *     ControlServiceSettings.newBuilder()
 *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
 *         .build();
 * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings);
 * }
* *

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
 * ControlServiceSettings controlServiceSettings =
 *     ControlServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings);
 * }
* *

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
 * ControlServiceSettings controlServiceSettings =
 *     ControlServiceSettings.newHttpJsonBuilder().build();
 * ControlServiceClient controlServiceClient = ControlServiceClient.create(controlServiceSettings);
 * }
* *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @Generated("by gapic-generator-java") public class ControlServiceClient implements BackgroundResource { private final ControlServiceSettings settings; private final ControlServiceStub stub; /** Constructs an instance of ControlServiceClient with default settings. */ public static final ControlServiceClient create() throws IOException { return create(ControlServiceSettings.newBuilder().build()); } /** * Constructs an instance of ControlServiceClient, 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 ControlServiceClient create(ControlServiceSettings settings) throws IOException { return new ControlServiceClient(settings); } /** * Constructs an instance of ControlServiceClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ControlServiceSettings). */ public static final ControlServiceClient create(ControlServiceStub stub) { return new ControlServiceClient(stub); } /** * Constructs an instance of ControlServiceClient, 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 ControlServiceClient(ControlServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ControlServiceStubSettings) settings.getStubSettings()).createStub(); } protected ControlServiceClient(ControlServiceStub stub) { this.settings = null; this.stub = stub; } public final ControlServiceSettings getSettings() { return settings; } public ControlServiceStub getStub() { return stub; } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an * ALREADY_EXISTS error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]");
   *   Control control = Control.newBuilder().build();
   *   String controlId = "controlId-395080872";
   *   Control response = controlServiceClient.createControl(parent, control, controlId);
   * }
   * }
* * @param parent Required. Full resource name of parent catalog. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` * @param control Required. The Control to create. * @param controlId Required. The ID to use for the Control, which will become the final component * of the Control's resource name. *

This value should be 4-63 characters, and valid characters are /[a-z][0-9]-_/. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Control createControl(CatalogName parent, Control control, String controlId) { CreateControlRequest request = CreateControlRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setControl(control) .setControlId(controlId) .build(); return createControl(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an * ALREADY_EXISTS error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString();
   *   Control control = Control.newBuilder().build();
   *   String controlId = "controlId-395080872";
   *   Control response = controlServiceClient.createControl(parent, control, controlId);
   * }
   * }
* * @param parent Required. Full resource name of parent catalog. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` * @param control Required. The Control to create. * @param controlId Required. The ID to use for the Control, which will become the final component * of the Control's resource name. *

This value should be 4-63 characters, and valid characters are /[a-z][0-9]-_/. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Control createControl(String parent, Control control, String controlId) { CreateControlRequest request = CreateControlRequest.newBuilder() .setParent(parent) .setControl(control) .setControlId(controlId) .build(); return createControl(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an * ALREADY_EXISTS error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   CreateControlRequest request =
   *       CreateControlRequest.newBuilder()
   *           .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
   *           .setControl(Control.newBuilder().build())
   *           .setControlId("controlId-395080872")
   *           .build();
   *   Control response = controlServiceClient.createControl(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 Control createControl(CreateControlRequest request) { return createControlCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an * ALREADY_EXISTS error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   CreateControlRequest request =
   *       CreateControlRequest.newBuilder()
   *           .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
   *           .setControl(Control.newBuilder().build())
   *           .setControlId("controlId-395080872")
   *           .build();
   *   ApiFuture future = controlServiceClient.createControlCallable().futureCall(request);
   *   // Do something.
   *   Control response = future.get();
   * }
   * }
*/ public final UnaryCallable createControlCallable() { return stub.createControlCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND * error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]");
   *   controlServiceClient.deleteControl(name);
   * }
   * }
* * @param name Required. The resource name of the Control to delete. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteControl(ControlName name) { DeleteControlRequest request = DeleteControlRequest.newBuilder().setName(name == null ? null : name.toString()).build(); deleteControl(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND * error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString();
   *   controlServiceClient.deleteControl(name);
   * }
   * }
* * @param name Required. The resource name of the Control to delete. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteControl(String name) { DeleteControlRequest request = DeleteControlRequest.newBuilder().setName(name).build(); deleteControl(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND * error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   DeleteControlRequest request =
   *       DeleteControlRequest.newBuilder()
   *           .setName(
   *               ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString())
   *           .build();
   *   controlServiceClient.deleteControl(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 void deleteControl(DeleteControlRequest request) { deleteControlCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a Control. * *

If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND * error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   DeleteControlRequest request =
   *       DeleteControlRequest.newBuilder()
   *           .setName(
   *               ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString())
   *           .build();
   *   ApiFuture future = controlServiceClient.deleteControlCallable().futureCall(request);
   *   // Do something.
   *   future.get();
   * }
   * }
*/ public final UnaryCallable deleteControlCallable() { return stub.deleteControlCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates a Control. * *

[Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if * so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to * update does not exist, a NOT_FOUND error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   Control control = Control.newBuilder().build();
   *   FieldMask updateMask = FieldMask.newBuilder().build();
   *   Control response = controlServiceClient.updateControl(control, updateMask);
   * }
   * }
* * @param control Required. The Control to update. * @param updateMask Indicates which fields in the provided * [Control][google.cloud.retail.v2beta.Control] to update. The following are NOT supported: *
    *
  • [Control.name][google.cloud.retail.v2beta.Control.name] *
*

If not set or empty, all supported fields are updated. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Control updateControl(Control control, FieldMask updateMask) { UpdateControlRequest request = UpdateControlRequest.newBuilder().setControl(control).setUpdateMask(updateMask).build(); return updateControl(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates a Control. * *

[Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if * so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to * update does not exist, a NOT_FOUND error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   UpdateControlRequest request =
   *       UpdateControlRequest.newBuilder()
   *           .setControl(Control.newBuilder().build())
   *           .setUpdateMask(FieldMask.newBuilder().build())
   *           .build();
   *   Control response = controlServiceClient.updateControl(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 Control updateControl(UpdateControlRequest request) { return updateControlCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates a Control. * *

[Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if * so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to * update does not exist, a NOT_FOUND error is returned. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   UpdateControlRequest request =
   *       UpdateControlRequest.newBuilder()
   *           .setControl(Control.newBuilder().build())
   *           .setUpdateMask(FieldMask.newBuilder().build())
   *           .build();
   *   ApiFuture future = controlServiceClient.updateControlCallable().futureCall(request);
   *   // Do something.
   *   Control response = future.get();
   * }
   * }
*/ public final UnaryCallable updateControlCallable() { return stub.updateControlCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a Control. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   ControlName name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]");
   *   Control response = controlServiceClient.getControl(name);
   * }
   * }
* * @param name Required. The resource name of the Control to get. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Control getControl(ControlName name) { GetControlRequest request = GetControlRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getControl(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a Control. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   String name = ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString();
   *   Control response = controlServiceClient.getControl(name);
   * }
   * }
* * @param name Required. The resource name of the Control to get. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Control getControl(String name) { GetControlRequest request = GetControlRequest.newBuilder().setName(name).build(); return getControl(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a Control. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   GetControlRequest request =
   *       GetControlRequest.newBuilder()
   *           .setName(
   *               ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString())
   *           .build();
   *   Control response = controlServiceClient.getControl(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 Control getControl(GetControlRequest request) { return getControlCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a Control. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   GetControlRequest request =
   *       GetControlRequest.newBuilder()
   *           .setName(
   *               ControlName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CONTROL]").toString())
   *           .build();
   *   ApiFuture future = controlServiceClient.getControlCallable().futureCall(request);
   *   // Do something.
   *   Control response = future.get();
   * }
   * }
*/ public final UnaryCallable getControlCallable() { return stub.getControlCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog]. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]");
   *   for (Control element : controlServiceClient.listControls(parent).iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }
* * @param parent Required. The catalog resource name. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListControlsPagedResponse listControls(CatalogName parent) { ListControlsRequest request = ListControlsRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .build(); return listControls(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog]. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   String parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString();
   *   for (Control element : controlServiceClient.listControls(parent).iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }
* * @param parent Required. The catalog resource name. Format: * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final ListControlsPagedResponse listControls(String parent) { ListControlsRequest request = ListControlsRequest.newBuilder().setParent(parent).build(); return listControls(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog]. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   ListControlsRequest request =
   *       ListControlsRequest.newBuilder()
   *           .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
   *           .setPageSize(883849137)
   *           .setPageToken("pageToken873572522")
   *           .setFilter("filter-1274492040")
   *           .build();
   *   for (Control element : controlServiceClient.listControls(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 ListControlsPagedResponse listControls(ListControlsRequest request) { return listControlsPagedCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog]. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   ListControlsRequest request =
   *       ListControlsRequest.newBuilder()
   *           .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
   *           .setPageSize(883849137)
   *           .setPageToken("pageToken873572522")
   *           .setFilter("filter-1274492040")
   *           .build();
   *   ApiFuture future =
   *       controlServiceClient.listControlsPagedCallable().futureCall(request);
   *   // Do something.
   *   for (Control element : future.get().iterateAll()) {
   *     // doThingsWith(element);
   *   }
   * }
   * }
*/ public final UnaryCallable listControlsPagedCallable() { return stub.listControlsPagedCallable(); } // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog]. * *

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 (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
   *   ListControlsRequest request =
   *       ListControlsRequest.newBuilder()
   *           .setParent(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
   *           .setPageSize(883849137)
   *           .setPageToken("pageToken873572522")
   *           .setFilter("filter-1274492040")
   *           .build();
   *   while (true) {
   *     ListControlsResponse response = controlServiceClient.listControlsCallable().call(request);
   *     for (Control element : response.getControlsList()) {
   *       // doThingsWith(element);
   *     }
   *     String nextPageToken = response.getNextPageToken();
   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
   *       request = request.toBuilder().setPageToken(nextPageToken).build();
   *     } else {
   *       break;
   *     }
   *   }
   * }
   * }
*/ public final UnaryCallable listControlsCallable() { return stub.listControlsCallable(); } @Override public final void close() { stub.close(); } @Override public void shutdown() { stub.shutdown(); } @Override public boolean isShutdown() { return stub.isShutdown(); } @Override public boolean isTerminated() { return stub.isTerminated(); } @Override public void shutdownNow() { stub.shutdownNow(); } @Override public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { return stub.awaitTermination(duration, unit); } public static class ListControlsPagedResponse extends AbstractPagedListResponse< ListControlsRequest, ListControlsResponse, Control, ListControlsPage, ListControlsFixedSizeCollection> { public static ApiFuture createAsync( PageContext context, ApiFuture futureResponse) { ApiFuture futurePage = ListControlsPage.createEmptyPage().createPageAsync(context, futureResponse); return ApiFutures.transform( futurePage, input -> new ListControlsPagedResponse(input), MoreExecutors.directExecutor()); } private ListControlsPagedResponse(ListControlsPage page) { super(page, ListControlsFixedSizeCollection.createEmptyCollection()); } } public static class ListControlsPage extends AbstractPage { private ListControlsPage( PageContext context, ListControlsResponse response) { super(context, response); } private static ListControlsPage createEmptyPage() { return new ListControlsPage(null, null); } @Override protected ListControlsPage createPage( PageContext context, ListControlsResponse response) { return new ListControlsPage(context, response); } @Override public ApiFuture createPageAsync( PageContext context, ApiFuture futureResponse) { return super.createPageAsync(context, futureResponse); } } public static class ListControlsFixedSizeCollection extends AbstractFixedSizeCollection< ListControlsRequest, ListControlsResponse, Control, ListControlsPage, ListControlsFixedSizeCollection> { private ListControlsFixedSizeCollection(List pages, int collectionSize) { super(pages, collectionSize); } private static ListControlsFixedSizeCollection createEmptyCollection() { return new ListControlsFixedSizeCollection(null, 0); } @Override protected ListControlsFixedSizeCollection createCollection( List pages, int collectionSize) { return new ListControlsFixedSizeCollection(pages, collectionSize); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy