Class ApplicationServiceClient (2.2.9)

public class ApplicationServiceClient implements BackgroundResource

Service Description: A service that handles application management, including CRUD and enumeration.

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:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ProfileName parent = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]");
   Application application = Application.newBuilder().build();
   Application response = applicationServiceClient.createApplication(parent, application);
 }
 

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

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ApplicationServiceSettings to create(). For example:

To customize credentials:


 ApplicationServiceSettings applicationServiceSettings =
     ApplicationServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ApplicationServiceClient applicationServiceClient =
     ApplicationServiceClient.create(applicationServiceSettings);
 

To customize the endpoint:


 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

Implements

BackgroundResource

Static Methods

create()

public static final ApplicationServiceClient create()

Constructs an instance of ApplicationServiceClient with default settings.

Returns
TypeDescription
ApplicationServiceClient
Exceptions
TypeDescription
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
NameDescription
settingsApplicationServiceSettings
Returns
TypeDescription
ApplicationServiceClient
Exceptions
TypeDescription
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
NameDescription
stubApplicationServiceStub
Returns
TypeDescription
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
NameDescription
settingsApplicationServiceSettings

ApplicationServiceClient(ApplicationServiceStub stub)

protected ApplicationServiceClient(ApplicationServiceStub stub)
Parameter
NameDescription
stubApplicationServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createApplication(CreateApplicationRequest request)

public final Application createApplication(CreateApplicationRequest request)

Creates a new application entity.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   CreateApplicationRequest request =
       CreateApplicationRequest.newBuilder()
           .setParent(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .setApplication(Application.newBuilder().build())
           .build();
   Application response = applicationServiceClient.createApplication(request);
 }
 
Parameter
NameDescription
requestCreateApplicationRequest

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

Returns
TypeDescription
Application

createApplication(ProfileName parent, Application application)

public final Application createApplication(ProfileName parent, Application application)

Creates a new application entity.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ProfileName parent = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]");
   Application application = Application.newBuilder().build();
   Application response = applicationServiceClient.createApplication(parent, application);
 }
 
Parameters
NameDescription
parentProfileName

Required. Resource name of the profile under which the application is created.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". For example, "projects/foo/tenants/bar/profiles/baz".

applicationApplication

Required. The application to be created.

Returns
TypeDescription
Application

createApplication(String parent, Application application)

public final Application createApplication(String parent, Application application)

Creates a new application entity.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   String parent = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString();
   Application application = Application.newBuilder().build();
   Application response = applicationServiceClient.createApplication(parent, application);
 }
 
Parameters
NameDescription
parentString

Required. Resource name of the profile under which the application is created.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}". For example, "projects/foo/tenants/bar/profiles/baz".

applicationApplication

Required. The application to be created.

Returns
TypeDescription
Application

createApplicationCallable()

public final UnaryCallable<CreateApplicationRequest,Application> createApplicationCallable()

Creates a new application entity.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   CreateApplicationRequest request =
       CreateApplicationRequest.newBuilder()
           .setParent(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .setApplication(Application.newBuilder().build())
           .build();
   ApiFuture<Application> future =
       applicationServiceClient.createApplicationCallable().futureCall(request);
   // Do something.
   Application response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateApplicationRequest,Application>

deleteApplication(ApplicationName name)

public final void deleteApplication(ApplicationName name)

Deletes specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ApplicationName name =
       ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]");
   applicationServiceClient.deleteApplication(name);
 }
 
Parameter
NameDescription
nameApplicationName

Required. The resource name of the application to be deleted.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". For example, "projects/foo/tenants/bar/profiles/baz/applications/qux".

deleteApplication(DeleteApplicationRequest request)

public final void deleteApplication(DeleteApplicationRequest request)

Deletes specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   DeleteApplicationRequest request =
       DeleteApplicationRequest.newBuilder()
           .setName(
               ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]")
                   .toString())
           .build();
   applicationServiceClient.deleteApplication(request);
 }
 
Parameter
NameDescription
requestDeleteApplicationRequest

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

deleteApplication(String name)

public final void deleteApplication(String name)

Deletes specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   String name =
       ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]").toString();
   applicationServiceClient.deleteApplication(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name of the application to be deleted.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". For example, "projects/foo/tenants/bar/profiles/baz/applications/qux".

deleteApplicationCallable()

public final UnaryCallable<DeleteApplicationRequest,Empty> deleteApplicationCallable()

Deletes specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   DeleteApplicationRequest request =
       DeleteApplicationRequest.newBuilder()
           .setName(
               ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]")
                   .toString())
           .build();
   ApiFuture<Empty> future =
       applicationServiceClient.deleteApplicationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteApplicationRequest,Empty>

getApplication(ApplicationName name)

public final Application getApplication(ApplicationName name)

Retrieves specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ApplicationName name =
       ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]");
   Application response = applicationServiceClient.getApplication(name);
 }
 
Parameter
NameDescription
nameApplicationName

Required. The resource name of the application to be retrieved.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". For example, "projects/foo/tenants/bar/profiles/baz/applications/qux".

Returns
TypeDescription
Application

getApplication(GetApplicationRequest request)

public final Application getApplication(GetApplicationRequest request)

Retrieves specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   GetApplicationRequest request =
       GetApplicationRequest.newBuilder()
           .setName(
               ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]")
                   .toString())
           .build();
   Application response = applicationServiceClient.getApplication(request);
 }
 
Parameter
NameDescription
requestGetApplicationRequest

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

Returns
TypeDescription
Application

getApplication(String name)

public final Application getApplication(String name)

Retrieves specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   String name =
       ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]").toString();
   Application response = applicationServiceClient.getApplication(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name of the application to be retrieved.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}". For example, "projects/foo/tenants/bar/profiles/baz/applications/qux".

Returns
TypeDescription
Application

getApplicationCallable()

public final UnaryCallable<GetApplicationRequest,Application> getApplicationCallable()

Retrieves specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   GetApplicationRequest request =
       GetApplicationRequest.newBuilder()
           .setName(
               ApplicationName.of("[PROJECT]", "[TENANT]", "[PROFILE]", "[APPLICATION]")
                   .toString())
           .build();
   ApiFuture<Application> future =
       applicationServiceClient.getApplicationCallable().futureCall(request);
   // Do something.
   Application response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetApplicationRequest,Application>

getSettings()

public final ApplicationServiceSettings getSettings()
Returns
TypeDescription
ApplicationServiceSettings

getStub()

public ApplicationServiceStub getStub()
Returns
TypeDescription
ApplicationServiceStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listApplications(ListApplicationsRequest request)

public final ApplicationServiceClient.ListApplicationsPagedResponse listApplications(ListApplicationsRequest request)

Lists all applications associated with the profile.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ListApplicationsRequest request =
       ListApplicationsRequest.newBuilder()
           .setParent(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .build();
   for (Application element : applicationServiceClient.listApplications(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListApplicationsRequest

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

Returns
TypeDescription
ApplicationServiceClient.ListApplicationsPagedResponse

listApplications(ProfileName parent)

public final ApplicationServiceClient.ListApplicationsPagedResponse listApplications(ProfileName parent)

Lists all applications associated with the profile.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ProfileName parent = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]");
   for (Application element : applicationServiceClient.listApplications(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentProfileName

Required. Resource name of the profile under which the application is created.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}", for example, "projects/foo/tenants/bar/profiles/baz".

Returns
TypeDescription
ApplicationServiceClient.ListApplicationsPagedResponse

listApplications(String parent)

public final ApplicationServiceClient.ListApplicationsPagedResponse listApplications(String parent)

Lists all applications associated with the profile.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   String parent = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString();
   for (Application element : applicationServiceClient.listApplications(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. Resource name of the profile under which the application is created.

The format is "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}", for example, "projects/foo/tenants/bar/profiles/baz".

Returns
TypeDescription
ApplicationServiceClient.ListApplicationsPagedResponse

listApplicationsCallable()

public final UnaryCallable<ListApplicationsRequest,ListApplicationsResponse> listApplicationsCallable()

Lists all applications associated with the profile.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ListApplicationsRequest request =
       ListApplicationsRequest.newBuilder()
           .setParent(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .build();
   while (true) {
     ListApplicationsResponse response =
         applicationServiceClient.listApplicationsCallable().call(request);
     for (Application element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListApplicationsRequest,ListApplicationsResponse>

listApplicationsPagedCallable()

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

Lists all applications associated with the profile.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   ListApplicationsRequest request =
       ListApplicationsRequest.newBuilder()
           .setParent(ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]").toString())
           .setPageToken("pageToken873572522")
           .setPageSize(883849137)
           .build();
   ApiFuture<Application> future =
       applicationServiceClient.listApplicationsPagedCallable().futureCall(request);
   // Do something.
   for (Application element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListApplicationsRequest,ListApplicationsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateApplication(Application application)

public final Application updateApplication(Application application)

Updates specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   Application application = Application.newBuilder().build();
   Application response = applicationServiceClient.updateApplication(application);
 }
 
Parameter
NameDescription
applicationApplication

Required. The application resource to replace the current resource in the system.

Returns
TypeDescription
Application

updateApplication(UpdateApplicationRequest request)

public final Application updateApplication(UpdateApplicationRequest request)

Updates specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   UpdateApplicationRequest request =
       UpdateApplicationRequest.newBuilder()
           .setApplication(Application.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Application response = applicationServiceClient.updateApplication(request);
 }
 
Parameter
NameDescription
requestUpdateApplicationRequest

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

Returns
TypeDescription
Application

updateApplicationCallable()

public final UnaryCallable<UpdateApplicationRequest,Application> updateApplicationCallable()

Updates specified application.

Sample code:


 try (ApplicationServiceClient applicationServiceClient = ApplicationServiceClient.create()) {
   UpdateApplicationRequest request =
       UpdateApplicationRequest.newBuilder()
           .setApplication(Application.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Application> future =
       applicationServiceClient.updateApplicationCallable().futureCall(request);
   // Do something.
   Application response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateApplicationRequest,Application>