Class AssuredWorkloadsServiceClient (0.9.0)

public class AssuredWorkloadsServiceClient implements BackgroundResource

Service Description: Service to manage AssuredWorkloads.

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 (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   Workload workload = Workload.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Workload response = assuredWorkloadsServiceClient.updateWorkload(workload, updateMask);
 }
 

Note: close() needs to be called on the AssuredWorkloadsServiceClient 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 AssuredWorkloadsServiceSettings to create(). For example:

To customize credentials:


 AssuredWorkloadsServiceSettings assuredWorkloadsServiceSettings =
     AssuredWorkloadsServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
 

To customize the endpoint:


 AssuredWorkloadsServiceSettings assuredWorkloadsServiceSettings =
     AssuredWorkloadsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
 

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

Inheritance

java.lang.Object > AssuredWorkloadsServiceClient

Implements

BackgroundResource

Constructors

AssuredWorkloadsServiceClient(AssuredWorkloadsServiceSettings settings)

protected AssuredWorkloadsServiceClient(AssuredWorkloadsServiceSettings settings)

Constructs an instance of AssuredWorkloadsServiceClient, 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
settingsAssuredWorkloadsServiceSettings

AssuredWorkloadsServiceClient(AssuredWorkloadsServiceStub stub)

protected AssuredWorkloadsServiceClient(AssuredWorkloadsServiceStub stub)
Parameter
NameDescription
stubAssuredWorkloadsServiceStub

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

create()

public static final AssuredWorkloadsServiceClient create()

Constructs an instance of AssuredWorkloadsServiceClient with default settings.

Returns
TypeDescription
AssuredWorkloadsServiceClient
Exceptions
TypeDescription
IOException

create(AssuredWorkloadsServiceSettings settings)

public static final AssuredWorkloadsServiceClient create(AssuredWorkloadsServiceSettings settings)

Constructs an instance of AssuredWorkloadsServiceClient, 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
settingsAssuredWorkloadsServiceSettings
Returns
TypeDescription
AssuredWorkloadsServiceClient
Exceptions
TypeDescription
IOException

create(AssuredWorkloadsServiceStub stub)

public static final AssuredWorkloadsServiceClient create(AssuredWorkloadsServiceStub stub)

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

Parameter
NameDescription
stubAssuredWorkloadsServiceStub
Returns
TypeDescription
AssuredWorkloadsServiceClient

createWorkloadAsync(CreateWorkloadRequest request)

public final OperationFuture<Workload,CreateWorkloadOperationMetadata> createWorkloadAsync(CreateWorkloadRequest request)

Creates Assured Workload.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   CreateWorkloadRequest request =
       CreateWorkloadRequest.newBuilder()
           .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setWorkload(Workload.newBuilder().build())
           .setExternalId("externalId-1699764666")
           .build();
   Workload response = assuredWorkloadsServiceClient.createWorkloadAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateWorkloadRequest

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

Returns
TypeDescription
OperationFuture<Workload,CreateWorkloadOperationMetadata>

createWorkloadAsync(LocationName parent, Workload workload)

public final OperationFuture<Workload,CreateWorkloadOperationMetadata> createWorkloadAsync(LocationName parent, Workload workload)

Creates Assured Workload.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
   Workload workload = Workload.newBuilder().build();
   Workload response = assuredWorkloadsServiceClient.createWorkloadAsync(parent, workload).get();
 }
 
Parameters
NameDescription
parentLocationName

Required. The resource name of the new Workload's parent. Must be of the form organizations/{org_id}/locations/{location_id}.

workloadWorkload

Required. Assured Workload to create

Returns
TypeDescription
OperationFuture<Workload,CreateWorkloadOperationMetadata>

createWorkloadAsync(String parent, Workload workload)

public final OperationFuture<Workload,CreateWorkloadOperationMetadata> createWorkloadAsync(String parent, Workload workload)

Creates Assured Workload.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   String parent = LocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
   Workload workload = Workload.newBuilder().build();
   Workload response = assuredWorkloadsServiceClient.createWorkloadAsync(parent, workload).get();
 }
 
Parameters
NameDescription
parentString

Required. The resource name of the new Workload's parent. Must be of the form organizations/{org_id}/locations/{location_id}.

workloadWorkload

Required. Assured Workload to create

Returns
TypeDescription
OperationFuture<Workload,CreateWorkloadOperationMetadata>

createWorkloadCallable()

public final UnaryCallable<CreateWorkloadRequest,Operation> createWorkloadCallable()

Creates Assured Workload.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   CreateWorkloadRequest request =
       CreateWorkloadRequest.newBuilder()
           .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setWorkload(Workload.newBuilder().build())
           .setExternalId("externalId-1699764666")
           .build();
   ApiFuture<Operation> future =
       assuredWorkloadsServiceClient.createWorkloadCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateWorkloadRequest,Operation>

createWorkloadOperationCallable()

public final OperationCallable<CreateWorkloadRequest,Workload,CreateWorkloadOperationMetadata> createWorkloadOperationCallable()

Creates Assured Workload.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   CreateWorkloadRequest request =
       CreateWorkloadRequest.newBuilder()
           .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setWorkload(Workload.newBuilder().build())
           .setExternalId("externalId-1699764666")
           .build();
   OperationFuture
Returns
TypeDescription
OperationCallable<CreateWorkloadRequest,Workload,CreateWorkloadOperationMetadata>

deleteWorkload(DeleteWorkloadRequest request)

public final void deleteWorkload(DeleteWorkloadRequest request)

Deletes the workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail with a FAILED_PRECONDITION error.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   DeleteWorkloadRequest request =
       DeleteWorkloadRequest.newBuilder()
           .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
           .setEtag("etag3123477")
           .build();
   assuredWorkloadsServiceClient.deleteWorkload(request);
 }
 
Parameter
NameDescription
requestDeleteWorkloadRequest

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

deleteWorkload(WorkloadName name)

public final void deleteWorkload(WorkloadName name)

Deletes the workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail with a FAILED_PRECONDITION error.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
   assuredWorkloadsServiceClient.deleteWorkload(name);
 }
 
Parameter
NameDescription
nameWorkloadName

Required. The name field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}

deleteWorkload(String name)

public final void deleteWorkload(String name)

Deletes the workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail with a FAILED_PRECONDITION error.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   String name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString();
   assuredWorkloadsServiceClient.deleteWorkload(name);
 }
 
Parameter
NameDescription
nameString

Required. The name field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}

deleteWorkloadCallable()

public final UnaryCallable<DeleteWorkloadRequest,Empty> deleteWorkloadCallable()

Deletes the workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail with a FAILED_PRECONDITION error.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   DeleteWorkloadRequest request =
       DeleteWorkloadRequest.newBuilder()
           .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
           .setEtag("etag3123477")
           .build();
   ApiFuture<Empty> future =
       assuredWorkloadsServiceClient.deleteWorkloadCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteWorkloadRequest,Empty>

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getSettings()

public final AssuredWorkloadsServiceSettings getSettings()
Returns
TypeDescription
AssuredWorkloadsServiceSettings

getStub()

public AssuredWorkloadsServiceStub getStub()
Returns
TypeDescription
AssuredWorkloadsServiceStub

getWorkload(GetWorkloadRequest request)

public final Workload getWorkload(GetWorkloadRequest request)

Gets Assured Workload associated with a CRM Node

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   GetWorkloadRequest request =
       GetWorkloadRequest.newBuilder()
           .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
           .build();
   Workload response = assuredWorkloadsServiceClient.getWorkload(request);
 }
 
Parameter
NameDescription
requestGetWorkloadRequest

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

Returns
TypeDescription
Workload

getWorkload(WorkloadName name)

public final Workload getWorkload(WorkloadName name)

Gets Assured Workload associated with a CRM Node

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
   Workload response = assuredWorkloadsServiceClient.getWorkload(name);
 }
 
Parameter
NameDescription
nameWorkloadName

Required. The resource name of the Workload to fetch. This is the workloads's relative path in the API, formatted as "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}". For example, "organizations/123/locations/us-east1/workloads/assured-workload-1".

Returns
TypeDescription
Workload

getWorkload(String name)

public final Workload getWorkload(String name)

Gets Assured Workload associated with a CRM Node

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   String name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString();
   Workload response = assuredWorkloadsServiceClient.getWorkload(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name of the Workload to fetch. This is the workloads's relative path in the API, formatted as "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}". For example, "organizations/123/locations/us-east1/workloads/assured-workload-1".

Returns
TypeDescription
Workload

getWorkloadCallable()

public final UnaryCallable<GetWorkloadRequest,Workload> getWorkloadCallable()

Gets Assured Workload associated with a CRM Node

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   GetWorkloadRequest request =
       GetWorkloadRequest.newBuilder()
           .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
           .build();
   ApiFuture<Workload> future =
       assuredWorkloadsServiceClient.getWorkloadCallable().futureCall(request);
   // Do something.
   Workload response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetWorkloadRequest,Workload>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listWorkloads(ListWorkloadsRequest request)

public final AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse listWorkloads(ListWorkloadsRequest request)

Lists Assured Workloads under a CRM Node.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   ListWorkloadsRequest request =
       ListWorkloadsRequest.newBuilder()
           .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (Workload element : assuredWorkloadsServiceClient.listWorkloads(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListWorkloadsRequest

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

Returns
TypeDescription
AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse

listWorkloads(LocationName parent)

public final AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse listWorkloads(LocationName parent)

Lists Assured Workloads under a CRM Node.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
   for (Workload element : assuredWorkloadsServiceClient.listWorkloads(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. Parent Resource to list workloads from. Must be of the form organizations/{org_id}/locations/{location}.

Returns
TypeDescription
AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse

listWorkloads(String parent)

public final AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse listWorkloads(String parent)

Lists Assured Workloads under a CRM Node.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   String parent = LocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
   for (Workload element : assuredWorkloadsServiceClient.listWorkloads(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. Parent Resource to list workloads from. Must be of the form organizations/{org_id}/locations/{location}.

Returns
TypeDescription
AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse

listWorkloadsCallable()

public final UnaryCallable<ListWorkloadsRequest,ListWorkloadsResponse> listWorkloadsCallable()

Lists Assured Workloads under a CRM Node.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   ListWorkloadsRequest request =
       ListWorkloadsRequest.newBuilder()
           .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListWorkloadsResponse response =
         assuredWorkloadsServiceClient.listWorkloadsCallable().call(request);
     for (Workload element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListWorkloadsRequest,ListWorkloadsResponse>

listWorkloadsPagedCallable()

public final UnaryCallable<ListWorkloadsRequest,AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse> listWorkloadsPagedCallable()

Lists Assured Workloads under a CRM Node.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   ListWorkloadsRequest request =
       ListWorkloadsRequest.newBuilder()
           .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<Workload> future =
       assuredWorkloadsServiceClient.listWorkloadsPagedCallable().futureCall(request);
   // Do something.
   for (Workload element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListWorkloadsRequest,ListWorkloadsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateWorkload(UpdateWorkloadRequest request)

public final Workload updateWorkload(UpdateWorkloadRequest request)

Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   UpdateWorkloadRequest request =
       UpdateWorkloadRequest.newBuilder()
           .setWorkload(Workload.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Workload response = assuredWorkloadsServiceClient.updateWorkload(request);
 }
 
Parameter
NameDescription
requestUpdateWorkloadRequest

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

Returns
TypeDescription
Workload

updateWorkload(Workload workload, FieldMask updateMask)

public final Workload updateWorkload(Workload workload, FieldMask updateMask)

Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   Workload workload = Workload.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Workload response = assuredWorkloadsServiceClient.updateWorkload(workload, updateMask);
 }
 
Parameters
NameDescription
workloadWorkload

Required. The workload to update. The workload\u2019s name field is used to identify the workload to be updated. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}

updateMaskFieldMask

Required. The list of fields to be updated.

Returns
TypeDescription
Workload

updateWorkloadCallable()

public final UnaryCallable<UpdateWorkloadRequest,Workload> updateWorkloadCallable()

Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.

Sample code:


 try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
     AssuredWorkloadsServiceClient.create()) {
   UpdateWorkloadRequest request =
       UpdateWorkloadRequest.newBuilder()
           .setWorkload(Workload.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Workload> future =
       assuredWorkloadsServiceClient.updateWorkloadCallable().futureCall(request);
   // Do something.
   Workload response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateWorkloadRequest,Workload>