Class CustomFieldServiceClient (0.10.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling CustomField objects.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   CustomFieldName name = CustomFieldName.of("[NETWORK_CODE]", "[CUSTOM_FIELD]");
   CustomField response = customFieldServiceClient.getCustomField(name);
 }
 

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

Methods
Method Description Method Variants

GetCustomField

API to retrieve a CustomField object.

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

  • getCustomField(GetCustomFieldRequest request)

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

  • getCustomField(CustomFieldName name)

  • getCustomField(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.

  • getCustomFieldCallable()

ListCustomFields

API to retrieve a list of CustomField objects.

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

  • listCustomFields(ListCustomFieldsRequest request)

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

  • listCustomFields(NetworkName parent)

  • listCustomFields(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.

  • listCustomFieldsPagedCallable()

  • listCustomFieldsCallable()

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 CustomFieldServiceSettings 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
 CustomFieldServiceSettings customFieldServiceSettings =
     CustomFieldServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 CustomFieldServiceClient customFieldServiceClient =
     CustomFieldServiceClient.create(customFieldServiceSettings);
 

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
 CustomFieldServiceSettings customFieldServiceSettings =
     CustomFieldServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 CustomFieldServiceClient customFieldServiceClient =
     CustomFieldServiceClient.create(customFieldServiceSettings);
 

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

Inheritance

java.lang.Object > CustomFieldServiceClient

Static Methods

create()

public static final CustomFieldServiceClient create()

Constructs an instance of CustomFieldServiceClient with default settings.

Returns
Type Description
CustomFieldServiceClient
Exceptions
Type Description
IOException

create(CustomFieldServiceSettings settings)

public static final CustomFieldServiceClient create(CustomFieldServiceSettings settings)

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

Parameter
Name Description
settings CustomFieldServiceSettings
Returns
Type Description
CustomFieldServiceClient
Exceptions
Type Description
IOException

create(CustomFieldServiceStub stub)

public static final CustomFieldServiceClient create(CustomFieldServiceStub stub)

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

Parameter
Name Description
stub CustomFieldServiceStub
Returns
Type Description
CustomFieldServiceClient

Constructors

CustomFieldServiceClient(CustomFieldServiceSettings settings)

protected CustomFieldServiceClient(CustomFieldServiceSettings settings)

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

Parameter
Name Description
settings CustomFieldServiceSettings

CustomFieldServiceClient(CustomFieldServiceStub stub)

protected CustomFieldServiceClient(CustomFieldServiceStub stub)
Parameter
Name Description
stub CustomFieldServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

getCustomField(CustomFieldName name)

public final CustomField getCustomField(CustomFieldName name)

API to retrieve a CustomField object.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   CustomFieldName name = CustomFieldName.of("[NETWORK_CODE]", "[CUSTOM_FIELD]");
   CustomField response = customFieldServiceClient.getCustomField(name);
 }
 
Parameter
Name Description
name CustomFieldName

Required. The resource name of the CustomField. Format: networks/{network_code}/customFields/{custom_field_id}

Returns
Type Description
CustomField

getCustomField(GetCustomFieldRequest request)

public final CustomField getCustomField(GetCustomFieldRequest request)

API to retrieve a CustomField object.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   GetCustomFieldRequest request =
       GetCustomFieldRequest.newBuilder()
           .setName(CustomFieldName.of("[NETWORK_CODE]", "[CUSTOM_FIELD]").toString())
           .build();
   CustomField response = customFieldServiceClient.getCustomField(request);
 }
 
Parameter
Name Description
request GetCustomFieldRequest

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

Returns
Type Description
CustomField

getCustomField(String name)

public final CustomField getCustomField(String name)

API to retrieve a CustomField object.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   String name = CustomFieldName.of("[NETWORK_CODE]", "[CUSTOM_FIELD]").toString();
   CustomField response = customFieldServiceClient.getCustomField(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the CustomField. Format: networks/{network_code}/customFields/{custom_field_id}

Returns
Type Description
CustomField

getCustomFieldCallable()

public final UnaryCallable<GetCustomFieldRequest,CustomField> getCustomFieldCallable()

API to retrieve a CustomField object.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   GetCustomFieldRequest request =
       GetCustomFieldRequest.newBuilder()
           .setName(CustomFieldName.of("[NETWORK_CODE]", "[CUSTOM_FIELD]").toString())
           .build();
   ApiFuture<CustomField> future =
       customFieldServiceClient.getCustomFieldCallable().futureCall(request);
   // Do something.
   CustomField response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetCustomFieldRequest,CustomField>

getSettings()

public final CustomFieldServiceSettings getSettings()
Returns
Type Description
CustomFieldServiceSettings

getStub()

public CustomFieldServiceStub getStub()
Returns
Type Description
CustomFieldServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listCustomFields(ListCustomFieldsRequest request)

public final CustomFieldServiceClient.ListCustomFieldsPagedResponse listCustomFields(ListCustomFieldsRequest request)

API to retrieve a list of CustomField objects.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   ListCustomFieldsRequest request =
       ListCustomFieldsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   for (CustomField element : customFieldServiceClient.listCustomFields(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListCustomFieldsRequest

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

Returns
Type Description
CustomFieldServiceClient.ListCustomFieldsPagedResponse

listCustomFields(NetworkName parent)

public final CustomFieldServiceClient.ListCustomFieldsPagedResponse listCustomFields(NetworkName parent)

API to retrieve a list of CustomField objects.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   for (CustomField element : customFieldServiceClient.listCustomFields(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent NetworkName

Required. The parent, which owns this collection of CustomFields. Format: networks/{network_code}

Returns
Type Description
CustomFieldServiceClient.ListCustomFieldsPagedResponse

listCustomFields(String parent)

public final CustomFieldServiceClient.ListCustomFieldsPagedResponse listCustomFields(String parent)

API to retrieve a list of CustomField objects.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   for (CustomField element : customFieldServiceClient.listCustomFields(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent, which owns this collection of CustomFields. Format: networks/{network_code}

Returns
Type Description
CustomFieldServiceClient.ListCustomFieldsPagedResponse

listCustomFieldsCallable()

public final UnaryCallable<ListCustomFieldsRequest,ListCustomFieldsResponse> listCustomFieldsCallable()

API to retrieve a list of CustomField objects.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   ListCustomFieldsRequest request =
       ListCustomFieldsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   while (true) {
     ListCustomFieldsResponse response =
         customFieldServiceClient.listCustomFieldsCallable().call(request);
     for (CustomField element : response.getCustomFieldsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListCustomFieldsRequest,ListCustomFieldsResponse>

listCustomFieldsPagedCallable()

public final UnaryCallable<ListCustomFieldsRequest,CustomFieldServiceClient.ListCustomFieldsPagedResponse> listCustomFieldsPagedCallable()

API to retrieve a list of CustomField objects.

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 (CustomFieldServiceClient customFieldServiceClient = CustomFieldServiceClient.create()) {
   ListCustomFieldsRequest request =
       ListCustomFieldsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   ApiFuture<CustomField> future =
       customFieldServiceClient.listCustomFieldsPagedCallable().futureCall(request);
   // Do something.
   for (CustomField element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListCustomFieldsRequest,ListCustomFieldsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()