Class ApplicationServiceClient (0.39.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ApplicationName name = ApplicationName.of("[NETWORK_CODE]", "[APPLICATION]");
   Application response = applicationServiceClient.getApplication(name);
 }
 

Note: close() needs to be called on the ApplicationServiceClient 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

GetApplication

API to retrieve a Application object.

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

  • getApplication(GetApplicationRequest request)

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

  • getApplication(ApplicationName name)

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

  • getApplicationCallable()

ListApplications

API to retrieve a list of Application objects.

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

  • listApplications(ListApplicationsRequest request)

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

  • listApplications(NetworkName parent)

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

  • listApplicationsPagedCallable()

  • listApplicationsCallable()

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 ApplicationServiceSettings 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
 ApplicationServiceSettings applicationServiceSettings =
     ApplicationServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ApplicationServiceClient applicationServiceClient =
     ApplicationServiceClient.create(applicationServiceSettings);
 

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
 ApplicationServiceSettings applicationServiceSettings =
     ApplicationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ApplicationServiceClient applicationServiceClient =
     ApplicationServiceClient.create(applicationServiceSettings);
 

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

Inheritance

java.lang.Object > ApplicationServiceClient

Static Methods

create()

public static final ApplicationServiceClient create()

Constructs an instance of ApplicationServiceClient with default settings.

Returns
Type Description
ApplicationServiceClient
Exceptions
Type Description
IOException

create(ApplicationServiceSettings settings)

public static final ApplicationServiceClient create(ApplicationServiceSettings settings)

Constructs an instance of ApplicationServiceClient, 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 ApplicationServiceSettings
Returns
Type Description
ApplicationServiceClient
Exceptions
Type Description
IOException

create(ApplicationServiceStub stub)

public static final ApplicationServiceClient create(ApplicationServiceStub stub)

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

Parameter
Name Description
stub ApplicationServiceStub
Returns
Type Description
ApplicationServiceClient

Constructors

ApplicationServiceClient(ApplicationServiceSettings settings)

protected ApplicationServiceClient(ApplicationServiceSettings settings)

Constructs an instance of ApplicationServiceClient, 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 ApplicationServiceSettings

ApplicationServiceClient(ApplicationServiceStub stub)

protected ApplicationServiceClient(ApplicationServiceStub stub)
Parameter
Name Description
stub ApplicationServiceStub

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()

getApplication(ApplicationName name)

public final Application getApplication(ApplicationName name)

API to retrieve a Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ApplicationName name = ApplicationName.of("[NETWORK_CODE]", "[APPLICATION]");
   Application response = applicationServiceClient.getApplication(name);
 }
 
Parameter
Name Description
name ApplicationName

Required. The resource name of the Application. Format: networks/{network_code}/applications/{application_id}

Returns
Type Description
Application

getApplication(GetApplicationRequest request)

public final Application getApplication(GetApplicationRequest request)

API to retrieve a Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   GetApplicationRequest request =
       GetApplicationRequest.newBuilder()
           .setName(ApplicationName.of("[NETWORK_CODE]", "[APPLICATION]").toString())
           .build();
   Application response = applicationServiceClient.getApplication(request);
 }
 
Parameter
Name Description
request GetApplicationRequest

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

Returns
Type Description
Application

getApplication(String name)

public final Application getApplication(String name)

API to retrieve a Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   String name = ApplicationName.of("[NETWORK_CODE]", "[APPLICATION]").toString();
   Application response = applicationServiceClient.getApplication(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the Application. Format: networks/{network_code}/applications/{application_id}

Returns
Type Description
Application

getApplicationCallable()

public final UnaryCallable<GetApplicationRequest,Application> getApplicationCallable()

API to retrieve a Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   GetApplicationRequest request =
       GetApplicationRequest.newBuilder()
           .setName(ApplicationName.of("[NETWORK_CODE]", "[APPLICATION]").toString())
           .build();
   ApiFuture<Application> future =
       applicationServiceClient.getApplicationCallable().futureCall(request);
   // Do something.
   Application response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetApplicationRequest,Application>

getSettings()

public final ApplicationServiceSettings getSettings()
Returns
Type Description
ApplicationServiceSettings

getStub()

public ApplicationServiceStub getStub()
Returns
Type Description
ApplicationServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listApplications(ListApplicationsRequest request)

public final ApplicationServiceClient.ListApplicationsPagedResponse listApplications(ListApplicationsRequest request)

API to retrieve a list of Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ListApplicationsRequest request =
       ListApplicationsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   for (Application element : applicationServiceClient.listApplications(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListApplicationsRequest

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

Returns
Type Description
ApplicationServiceClient.ListApplicationsPagedResponse

listApplications(NetworkName parent)

public final ApplicationServiceClient.ListApplicationsPagedResponse listApplications(NetworkName parent)

API to retrieve a list of Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   for (Application element : applicationServiceClient.listApplications(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent NetworkName

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

Returns
Type Description
ApplicationServiceClient.ListApplicationsPagedResponse

listApplications(String parent)

public final ApplicationServiceClient.ListApplicationsPagedResponse listApplications(String parent)

API to retrieve a list of Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   for (Application element : applicationServiceClient.listApplications(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

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

Returns
Type Description
ApplicationServiceClient.ListApplicationsPagedResponse

listApplicationsCallable()

public final UnaryCallable<ListApplicationsRequest,ListApplicationsResponse> listApplicationsCallable()

API to retrieve a list of Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ListApplicationsRequest request =
       ListApplicationsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   while (true) {
     ListApplicationsResponse response =
         applicationServiceClient.listApplicationsCallable().call(request);
     for (Application element : response.getApplicationsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListApplicationsRequest,ListApplicationsResponse>

listApplicationsPagedCallable()

public final UnaryCallable<ListApplicationsRequest,ApplicationServiceClient.ListApplicationsPagedResponse> listApplicationsPagedCallable()

API to retrieve a list of Application 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 (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ListApplicationsRequest request =
       ListApplicationsRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   ApiFuture<Application> future =
       applicationServiceClient.listApplicationsPagedCallable().futureCall(request);
   // Do something.
   for (Application element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListApplicationsRequest,ListApplicationsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()