Class ReservationServiceClient (2.20.0)

public class ReservationServiceClient implements BackgroundResource

Service Description: This API allows users to manage their BigQuery reservations.

A reservation provides computational resource guarantees, in the form of slots, to users. A slot is a unit of computational power in BigQuery, and serves as the basic unit of parallelism. In a scan of a multi-partitioned table, a single slot operates on a single partition of the table. A reservation resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/reservations/reservationName.

A capacity commitment is a way to purchase compute capacity for BigQuery jobs (in the form of slots) with some committed period of usage. A capacity commitment resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/capacityCommitments/id.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Reservation reservation = Reservation.newBuilder().build();
   String reservationId = "reservationId1116965383";
   Reservation response =
       reservationServiceClient.createReservation(parent, reservation, reservationId);
 }
 

Note: close() needs to be called on the ReservationServiceClient 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 ReservationServiceSettings 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
 ReservationServiceSettings reservationServiceSettings =
     ReservationServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ReservationServiceClient reservationServiceClient =
     ReservationServiceClient.create(reservationServiceSettings);
 

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
 ReservationServiceSettings reservationServiceSettings =
     ReservationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ReservationServiceClient reservationServiceClient =
     ReservationServiceClient.create(reservationServiceSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // 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
 ReservationServiceSettings reservationServiceSettings =
     ReservationServiceSettings.newHttpJsonBuilder().build();
 ReservationServiceClient reservationServiceClient =
     ReservationServiceClient.create(reservationServiceSettings);
 

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

Inheritance

java.lang.Object > ReservationServiceClient

Implements

BackgroundResource

Static Methods

create()

public static final ReservationServiceClient create()

Constructs an instance of ReservationServiceClient with default settings.

Returns
TypeDescription
ReservationServiceClient
Exceptions
TypeDescription
IOException

create(ReservationServiceSettings settings)

public static final ReservationServiceClient create(ReservationServiceSettings settings)

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

create(ReservationServiceStub stub)

public static final ReservationServiceClient create(ReservationServiceStub stub)

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

Parameter
NameDescription
stubReservationServiceStub
Returns
TypeDescription
ReservationServiceClient

Constructors

ReservationServiceClient(ReservationServiceSettings settings)

protected ReservationServiceClient(ReservationServiceSettings settings)

Constructs an instance of ReservationServiceClient, 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
settingsReservationServiceSettings

ReservationServiceClient(ReservationServiceStub stub)

protected ReservationServiceClient(ReservationServiceStub stub)
Parameter
NameDescription
stubReservationServiceStub

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

createAssignment(CreateAssignmentRequest request)

public final Assignment createAssignment(CreateAssignmentRequest request)

Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation.

Currently a resource (project, folder, organization) can only have one assignment per each (job_type, location) combination, and that reservation will be used for all jobs of the matching type.

Different assignments can be created on different levels of the projects, folders or organization hierarchy. During query execution, the assignment is looked up at the project, folder and organization levels in that order. The first assignment found is applied to the query.

When creating assignments, it does not matter if other assignments exist at higher levels.

Example:

  • The organization organizationA contains two projects, project1 and project2.
  • Assignments for all three entities (organizationA, project1, and project2) could all be created and mapped to the same or different reservations.

"None" assignments represent an absence of the assignment. Projects assigned to None use on-demand pricing. To create a "None" assignment, use "none" as a reservation_id in the parent. Example parent: projects/myproject/locations/US/reservations/none.

Returns google.rpc.Code.PERMISSION_DENIED if user does not have 'bigquery.admin' permissions on the project using the reservation and the project that owns this reservation.

Returns google.rpc.Code.INVALID_ARGUMENT when location of the assignment does not match location of the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CreateAssignmentRequest request =
       CreateAssignmentRequest.newBuilder()
           .setParent(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .setAssignment(Assignment.newBuilder().build())
           .setAssignmentId("assignmentId-1603989304")
           .build();
   Assignment response = reservationServiceClient.createAssignment(request);
 }
 
Parameter
NameDescription
requestCreateAssignmentRequest

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

Returns
TypeDescription
Assignment

createAssignment(ReservationName parent, Assignment assignment)

public final Assignment createAssignment(ReservationName parent, Assignment assignment)

Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation.

Currently a resource (project, folder, organization) can only have one assignment per each (job_type, location) combination, and that reservation will be used for all jobs of the matching type.

Different assignments can be created on different levels of the projects, folders or organization hierarchy. During query execution, the assignment is looked up at the project, folder and organization levels in that order. The first assignment found is applied to the query.

When creating assignments, it does not matter if other assignments exist at higher levels.

Example:

  • The organization organizationA contains two projects, project1 and project2.
  • Assignments for all three entities (organizationA, project1, and project2) could all be created and mapped to the same or different reservations.

"None" assignments represent an absence of the assignment. Projects assigned to None use on-demand pricing. To create a "None" assignment, use "none" as a reservation_id in the parent. Example parent: projects/myproject/locations/US/reservations/none.

Returns google.rpc.Code.PERMISSION_DENIED if user does not have 'bigquery.admin' permissions on the project using the reservation and the project that owns this reservation.

Returns google.rpc.Code.INVALID_ARGUMENT when location of the assignment does not match location of the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ReservationName parent = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]");
   Assignment assignment = Assignment.newBuilder().build();
   Assignment response = reservationServiceClient.createAssignment(parent, assignment);
 }
 
Parameters
NameDescription
parentReservationName

Required. The parent resource name of the assignment E.g. projects/myproject/locations/US/reservations/team1-prod

assignmentAssignment

Assignment resource to create.

Returns
TypeDescription
Assignment

createAssignment(String parent, Assignment assignment)

public final Assignment createAssignment(String parent, Assignment assignment)

Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation.

Currently a resource (project, folder, organization) can only have one assignment per each (job_type, location) combination, and that reservation will be used for all jobs of the matching type.

Different assignments can be created on different levels of the projects, folders or organization hierarchy. During query execution, the assignment is looked up at the project, folder and organization levels in that order. The first assignment found is applied to the query.

When creating assignments, it does not matter if other assignments exist at higher levels.

Example:

  • The organization organizationA contains two projects, project1 and project2.
  • Assignments for all three entities (organizationA, project1, and project2) could all be created and mapped to the same or different reservations.

"None" assignments represent an absence of the assignment. Projects assigned to None use on-demand pricing. To create a "None" assignment, use "none" as a reservation_id in the parent. Example parent: projects/myproject/locations/US/reservations/none.

Returns google.rpc.Code.PERMISSION_DENIED if user does not have 'bigquery.admin' permissions on the project using the reservation and the project that owns this reservation.

Returns google.rpc.Code.INVALID_ARGUMENT when location of the assignment does not match location of the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString();
   Assignment assignment = Assignment.newBuilder().build();
   Assignment response = reservationServiceClient.createAssignment(parent, assignment);
 }
 
Parameters
NameDescription
parentString

Required. The parent resource name of the assignment E.g. projects/myproject/locations/US/reservations/team1-prod

assignmentAssignment

Assignment resource to create.

Returns
TypeDescription
Assignment

createAssignmentCallable()

public final UnaryCallable<CreateAssignmentRequest,Assignment> createAssignmentCallable()

Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation.

Currently a resource (project, folder, organization) can only have one assignment per each (job_type, location) combination, and that reservation will be used for all jobs of the matching type.

Different assignments can be created on different levels of the projects, folders or organization hierarchy. During query execution, the assignment is looked up at the project, folder and organization levels in that order. The first assignment found is applied to the query.

When creating assignments, it does not matter if other assignments exist at higher levels.

Example:

  • The organization organizationA contains two projects, project1 and project2.
  • Assignments for all three entities (organizationA, project1, and project2) could all be created and mapped to the same or different reservations.

"None" assignments represent an absence of the assignment. Projects assigned to None use on-demand pricing. To create a "None" assignment, use "none" as a reservation_id in the parent. Example parent: projects/myproject/locations/US/reservations/none.

Returns google.rpc.Code.PERMISSION_DENIED if user does not have 'bigquery.admin' permissions on the project using the reservation and the project that owns this reservation.

Returns google.rpc.Code.INVALID_ARGUMENT when location of the assignment does not match location of the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CreateAssignmentRequest request =
       CreateAssignmentRequest.newBuilder()
           .setParent(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .setAssignment(Assignment.newBuilder().build())
           .setAssignmentId("assignmentId-1603989304")
           .build();
   ApiFuture<Assignment> future =
       reservationServiceClient.createAssignmentCallable().futureCall(request);
   // Do something.
   Assignment response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateAssignmentRequest,Assignment>

createCapacityCommitment(CreateCapacityCommitmentRequest request)

public final CapacityCommitment createCapacityCommitment(CreateCapacityCommitmentRequest request)

Creates a new capacity commitment resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CreateCapacityCommitmentRequest request =
       CreateCapacityCommitmentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setCapacityCommitment(CapacityCommitment.newBuilder().build())
           .setEnforceSingleAdminProjectPerOrg(true)
           .setCapacityCommitmentId("capacityCommitmentId1185645802")
           .build();
   CapacityCommitment response = reservationServiceClient.createCapacityCommitment(request);
 }
 
Parameter
NameDescription
requestCreateCapacityCommitmentRequest

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

Returns
TypeDescription
CapacityCommitment

createCapacityCommitment(LocationName parent, CapacityCommitment capacityCommitment)

public final CapacityCommitment createCapacityCommitment(LocationName parent, CapacityCommitment capacityCommitment)

Creates a new capacity commitment resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   CapacityCommitment capacityCommitment = CapacityCommitment.newBuilder().build();
   CapacityCommitment response =
       reservationServiceClient.createCapacityCommitment(parent, capacityCommitment);
 }
 
Parameters
NameDescription
parentLocationName

Required. Resource name of the parent reservation. E.g., projects/myproject/locations/US

capacityCommitmentCapacityCommitment

Content of the capacity commitment to create.

Returns
TypeDescription
CapacityCommitment

createCapacityCommitment(String parent, CapacityCommitment capacityCommitment)

public final CapacityCommitment createCapacityCommitment(String parent, CapacityCommitment capacityCommitment)

Creates a new capacity commitment resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   CapacityCommitment capacityCommitment = CapacityCommitment.newBuilder().build();
   CapacityCommitment response =
       reservationServiceClient.createCapacityCommitment(parent, capacityCommitment);
 }
 
Parameters
NameDescription
parentString

Required. Resource name of the parent reservation. E.g., projects/myproject/locations/US

capacityCommitmentCapacityCommitment

Content of the capacity commitment to create.

Returns
TypeDescription
CapacityCommitment

createCapacityCommitmentCallable()

public final UnaryCallable<CreateCapacityCommitmentRequest,CapacityCommitment> createCapacityCommitmentCallable()

Creates a new capacity commitment resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CreateCapacityCommitmentRequest request =
       CreateCapacityCommitmentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setCapacityCommitment(CapacityCommitment.newBuilder().build())
           .setEnforceSingleAdminProjectPerOrg(true)
           .setCapacityCommitmentId("capacityCommitmentId1185645802")
           .build();
   ApiFuture<CapacityCommitment> future =
       reservationServiceClient.createCapacityCommitmentCallable().futureCall(request);
   // Do something.
   CapacityCommitment response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateCapacityCommitmentRequest,CapacityCommitment>

createReservation(CreateReservationRequest request)

public final Reservation createReservation(CreateReservationRequest request)

Creates a new reservation resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CreateReservationRequest request =
       CreateReservationRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setReservationId("reservationId1116965383")
           .setReservation(Reservation.newBuilder().build())
           .build();
   Reservation response = reservationServiceClient.createReservation(request);
 }
 
Parameter
NameDescription
requestCreateReservationRequest

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

Returns
TypeDescription
Reservation

createReservation(LocationName parent, Reservation reservation, String reservationId)

public final Reservation createReservation(LocationName parent, Reservation reservation, String reservationId)

Creates a new reservation resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Reservation reservation = Reservation.newBuilder().build();
   String reservationId = "reservationId1116965383";
   Reservation response =
       reservationServiceClient.createReservation(parent, reservation, reservationId);
 }
 
Parameters
NameDescription
parentLocationName

Required. Project, location. E.g., projects/myproject/locations/US

reservationReservation

Definition of the new reservation to create.

reservationIdString

The reservation ID. It must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.

Returns
TypeDescription
Reservation

createReservation(String parent, Reservation reservation, String reservationId)

public final Reservation createReservation(String parent, Reservation reservation, String reservationId)

Creates a new reservation resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   Reservation reservation = Reservation.newBuilder().build();
   String reservationId = "reservationId1116965383";
   Reservation response =
       reservationServiceClient.createReservation(parent, reservation, reservationId);
 }
 
Parameters
NameDescription
parentString

Required. Project, location. E.g., projects/myproject/locations/US

reservationReservation

Definition of the new reservation to create.

reservationIdString

The reservation ID. It must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.

Returns
TypeDescription
Reservation

createReservationCallable()

public final UnaryCallable<CreateReservationRequest,Reservation> createReservationCallable()

Creates a new reservation resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CreateReservationRequest request =
       CreateReservationRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setReservationId("reservationId1116965383")
           .setReservation(Reservation.newBuilder().build())
           .build();
   ApiFuture<Reservation> future =
       reservationServiceClient.createReservationCallable().futureCall(request);
   // Do something.
   Reservation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateReservationRequest,Reservation>

deleteAssignment(AssignmentName name)

public final void deleteAssignment(AssignmentName name)

Deletes a assignment. No expansion will happen.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, deletion of the <organizationA, res1> assignment won't affect the other assignment <project1, res1>. After said deletion, queries from project1 will still use res1 while queries from project2 will switch to use on-demand mode.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   AssignmentName name =
       AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]");
   reservationServiceClient.deleteAssignment(name);
 }
 
Parameter
NameDescription
nameAssignmentName

Required. Name of the resource, e.g. projects/myproject/locations/US/reservations/team1-prod/assignments/123

deleteAssignment(DeleteAssignmentRequest request)

public final void deleteAssignment(DeleteAssignmentRequest request)

Deletes a assignment. No expansion will happen.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, deletion of the <organizationA, res1> assignment won't affect the other assignment <project1, res1>. After said deletion, queries from project1 will still use res1 while queries from project2 will switch to use on-demand mode.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   DeleteAssignmentRequest request =
       DeleteAssignmentRequest.newBuilder()
           .setName(
               AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]")
                   .toString())
           .build();
   reservationServiceClient.deleteAssignment(request);
 }
 
Parameter
NameDescription
requestDeleteAssignmentRequest

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

deleteAssignment(String name)

public final void deleteAssignment(String name)

Deletes a assignment. No expansion will happen.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, deletion of the <organizationA, res1> assignment won't affect the other assignment <project1, res1>. After said deletion, queries from project1 will still use res1 while queries from project2 will switch to use on-demand mode.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name =
       AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]").toString();
   reservationServiceClient.deleteAssignment(name);
 }
 
Parameter
NameDescription
nameString

Required. Name of the resource, e.g. projects/myproject/locations/US/reservations/team1-prod/assignments/123

deleteAssignmentCallable()

public final UnaryCallable<DeleteAssignmentRequest,Empty> deleteAssignmentCallable()

Deletes a assignment. No expansion will happen.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, deletion of the <organizationA, res1> assignment won't affect the other assignment <project1, res1>. After said deletion, queries from project1 will still use res1 while queries from project2 will switch to use on-demand mode.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   DeleteAssignmentRequest request =
       DeleteAssignmentRequest.newBuilder()
           .setName(
               AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]")
                   .toString())
           .build();
   ApiFuture<Empty> future =
       reservationServiceClient.deleteAssignmentCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteAssignmentRequest,Empty>

deleteCapacityCommitment(CapacityCommitmentName name)

public final void deleteCapacityCommitment(CapacityCommitmentName name)

Deletes a capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CapacityCommitmentName name =
       CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]");
   reservationServiceClient.deleteCapacityCommitment(name);
 }
 
Parameter
NameDescription
nameCapacityCommitmentName

Required. Resource name of the capacity commitment to delete. E.g., projects/myproject/locations/US/capacityCommitments/123

deleteCapacityCommitment(DeleteCapacityCommitmentRequest request)

public final void deleteCapacityCommitment(DeleteCapacityCommitmentRequest request)

Deletes a capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   DeleteCapacityCommitmentRequest request =
       DeleteCapacityCommitmentRequest.newBuilder()
           .setName(
               CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]")
                   .toString())
           .setForce(true)
           .build();
   reservationServiceClient.deleteCapacityCommitment(request);
 }
 
Parameter
NameDescription
requestDeleteCapacityCommitmentRequest

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

deleteCapacityCommitment(String name)

public final void deleteCapacityCommitment(String name)

Deletes a capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name =
       CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]").toString();
   reservationServiceClient.deleteCapacityCommitment(name);
 }
 
Parameter
NameDescription
nameString

Required. Resource name of the capacity commitment to delete. E.g., projects/myproject/locations/US/capacityCommitments/123

deleteCapacityCommitmentCallable()

public final UnaryCallable<DeleteCapacityCommitmentRequest,Empty> deleteCapacityCommitmentCallable()

Deletes a capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   DeleteCapacityCommitmentRequest request =
       DeleteCapacityCommitmentRequest.newBuilder()
           .setName(
               CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]")
                   .toString())
           .setForce(true)
           .build();
   ApiFuture<Empty> future =
       reservationServiceClient.deleteCapacityCommitmentCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteCapacityCommitmentRequest,Empty>

deleteReservation(DeleteReservationRequest request)

public final void deleteReservation(DeleteReservationRequest request)

Deletes a reservation. Returns google.rpc.Code.FAILED_PRECONDITION when reservation has assignments.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   DeleteReservationRequest request =
       DeleteReservationRequest.newBuilder()
           .setName(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .build();
   reservationServiceClient.deleteReservation(request);
 }
 
Parameter
NameDescription
requestDeleteReservationRequest

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

deleteReservation(ReservationName name)

public final void deleteReservation(ReservationName name)

Deletes a reservation. Returns google.rpc.Code.FAILED_PRECONDITION when reservation has assignments.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ReservationName name = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]");
   reservationServiceClient.deleteReservation(name);
 }
 
Parameter
NameDescription
nameReservationName

Required. Resource name of the reservation to retrieve. E.g., projects/myproject/locations/US/reservations/team1-prod

deleteReservation(String name)

public final void deleteReservation(String name)

Deletes a reservation. Returns google.rpc.Code.FAILED_PRECONDITION when reservation has assignments.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString();
   reservationServiceClient.deleteReservation(name);
 }
 
Parameter
NameDescription
nameString

Required. Resource name of the reservation to retrieve. E.g., projects/myproject/locations/US/reservations/team1-prod

deleteReservationCallable()

public final UnaryCallable<DeleteReservationRequest,Empty> deleteReservationCallable()

Deletes a reservation. Returns google.rpc.Code.FAILED_PRECONDITION when reservation has assignments.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   DeleteReservationRequest request =
       DeleteReservationRequest.newBuilder()
           .setName(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .build();
   ApiFuture<Empty> future =
       reservationServiceClient.deleteReservationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteReservationRequest,Empty>

getBiReservation(BiReservationName name)

public final BiReservation getBiReservation(BiReservationName name)

Retrieves a BI reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   BiReservationName name = BiReservationName.of("[PROJECT]", "[LOCATION]");
   BiReservation response = reservationServiceClient.getBiReservation(name);
 }
 
Parameter
NameDescription
nameBiReservationName

Required. Name of the requested reservation, for example: projects/{project_id}/locations/{location_id}/biReservation

Returns
TypeDescription
BiReservation

getBiReservation(GetBiReservationRequest request)

public final BiReservation getBiReservation(GetBiReservationRequest request)

Retrieves a BI reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   GetBiReservationRequest request =
       GetBiReservationRequest.newBuilder()
           .setName(BiReservationName.of("[PROJECT]", "[LOCATION]").toString())
           .build();
   BiReservation response = reservationServiceClient.getBiReservation(request);
 }
 
Parameter
NameDescription
requestGetBiReservationRequest

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

Returns
TypeDescription
BiReservation

getBiReservation(String name)

public final BiReservation getBiReservation(String name)

Retrieves a BI reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name = BiReservationName.of("[PROJECT]", "[LOCATION]").toString();
   BiReservation response = reservationServiceClient.getBiReservation(name);
 }
 
Parameter
NameDescription
nameString

Required. Name of the requested reservation, for example: projects/{project_id}/locations/{location_id}/biReservation

Returns
TypeDescription
BiReservation

getBiReservationCallable()

public final UnaryCallable<GetBiReservationRequest,BiReservation> getBiReservationCallable()

Retrieves a BI reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   GetBiReservationRequest request =
       GetBiReservationRequest.newBuilder()
           .setName(BiReservationName.of("[PROJECT]", "[LOCATION]").toString())
           .build();
   ApiFuture<BiReservation> future =
       reservationServiceClient.getBiReservationCallable().futureCall(request);
   // Do something.
   BiReservation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetBiReservationRequest,BiReservation>

getCapacityCommitment(CapacityCommitmentName name)

public final CapacityCommitment getCapacityCommitment(CapacityCommitmentName name)

Returns information about the capacity commitment.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CapacityCommitmentName name =
       CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]");
   CapacityCommitment response = reservationServiceClient.getCapacityCommitment(name);
 }
 
Parameter
NameDescription
nameCapacityCommitmentName

Required. Resource name of the capacity commitment to retrieve. E.g., projects/myproject/locations/US/capacityCommitments/123

Returns
TypeDescription
CapacityCommitment

getCapacityCommitment(GetCapacityCommitmentRequest request)

public final CapacityCommitment getCapacityCommitment(GetCapacityCommitmentRequest request)

Returns information about the capacity commitment.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   GetCapacityCommitmentRequest request =
       GetCapacityCommitmentRequest.newBuilder()
           .setName(
               CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]")
                   .toString())
           .build();
   CapacityCommitment response = reservationServiceClient.getCapacityCommitment(request);
 }
 
Parameter
NameDescription
requestGetCapacityCommitmentRequest

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

Returns
TypeDescription
CapacityCommitment

getCapacityCommitment(String name)

public final CapacityCommitment getCapacityCommitment(String name)

Returns information about the capacity commitment.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name =
       CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]").toString();
   CapacityCommitment response = reservationServiceClient.getCapacityCommitment(name);
 }
 
Parameter
NameDescription
nameString

Required. Resource name of the capacity commitment to retrieve. E.g., projects/myproject/locations/US/capacityCommitments/123

Returns
TypeDescription
CapacityCommitment

getCapacityCommitmentCallable()

public final UnaryCallable<GetCapacityCommitmentRequest,CapacityCommitment> getCapacityCommitmentCallable()

Returns information about the capacity commitment.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   GetCapacityCommitmentRequest request =
       GetCapacityCommitmentRequest.newBuilder()
           .setName(
               CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]")
                   .toString())
           .build();
   ApiFuture<CapacityCommitment> future =
       reservationServiceClient.getCapacityCommitmentCallable().futureCall(request);
   // Do something.
   CapacityCommitment response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetCapacityCommitmentRequest,CapacityCommitment>

getReservation(GetReservationRequest request)

public final Reservation getReservation(GetReservationRequest request)

Returns information about the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   GetReservationRequest request =
       GetReservationRequest.newBuilder()
           .setName(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .build();
   Reservation response = reservationServiceClient.getReservation(request);
 }
 
Parameter
NameDescription
requestGetReservationRequest

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

Returns
TypeDescription
Reservation

getReservation(ReservationName name)

public final Reservation getReservation(ReservationName name)

Returns information about the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ReservationName name = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]");
   Reservation response = reservationServiceClient.getReservation(name);
 }
 
Parameter
NameDescription
nameReservationName

Required. Resource name of the reservation to retrieve. E.g., projects/myproject/locations/US/reservations/team1-prod

Returns
TypeDescription
Reservation

getReservation(String name)

public final Reservation getReservation(String name)

Returns information about the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString();
   Reservation response = reservationServiceClient.getReservation(name);
 }
 
Parameter
NameDescription
nameString

Required. Resource name of the reservation to retrieve. E.g., projects/myproject/locations/US/reservations/team1-prod

Returns
TypeDescription
Reservation

getReservationCallable()

public final UnaryCallable<GetReservationRequest,Reservation> getReservationCallable()

Returns information about the reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   GetReservationRequest request =
       GetReservationRequest.newBuilder()
           .setName(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .build();
   ApiFuture<Reservation> future =
       reservationServiceClient.getReservationCallable().futureCall(request);
   // Do something.
   Reservation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetReservationRequest,Reservation>

getSettings()

public final ReservationServiceSettings getSettings()
Returns
TypeDescription
ReservationServiceSettings

getStub()

public ReservationServiceStub getStub()
Returns
TypeDescription
ReservationServiceStub

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listAssignments(ListAssignmentsRequest request)

public final ReservationServiceClient.ListAssignmentsPagedResponse listAssignments(ListAssignmentsRequest request)

Lists assignments.

Only explicitly created assignments will be returned.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, ListAssignments will just return the above two assignments for reservation res1, and no expansion/merge will happen.

The wildcard "-" can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListAssignmentsRequest request =
       ListAssignmentsRequest.newBuilder()
           .setParent(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Assignment element : reservationServiceClient.listAssignments(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListAssignmentsRequest

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

Returns
TypeDescription
ReservationServiceClient.ListAssignmentsPagedResponse

listAssignments(ReservationName parent)

public final ReservationServiceClient.ListAssignmentsPagedResponse listAssignments(ReservationName parent)

Lists assignments.

Only explicitly created assignments will be returned.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, ListAssignments will just return the above two assignments for reservation res1, and no expansion/merge will happen.

The wildcard "-" can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ReservationName parent = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]");
   for (Assignment element : reservationServiceClient.listAssignments(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentReservationName

Required. The parent resource name e.g.:

projects/myproject/locations/US/reservations/team1-prod

Or:

projects/myproject/locations/US/reservations/-

Returns
TypeDescription
ReservationServiceClient.ListAssignmentsPagedResponse

listAssignments(String parent)

public final ReservationServiceClient.ListAssignmentsPagedResponse listAssignments(String parent)

Lists assignments.

Only explicitly created assignments will be returned.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, ListAssignments will just return the above two assignments for reservation res1, and no expansion/merge will happen.

The wildcard "-" can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString();
   for (Assignment element : reservationServiceClient.listAssignments(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The parent resource name e.g.:

projects/myproject/locations/US/reservations/team1-prod

Or:

projects/myproject/locations/US/reservations/-

Returns
TypeDescription
ReservationServiceClient.ListAssignmentsPagedResponse

listAssignmentsCallable()

public final UnaryCallable<ListAssignmentsRequest,ListAssignmentsResponse> listAssignmentsCallable()

Lists assignments.

Only explicitly created assignments will be returned.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, ListAssignments will just return the above two assignments for reservation res1, and no expansion/merge will happen.

The wildcard "-" can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListAssignmentsRequest request =
       ListAssignmentsRequest.newBuilder()
           .setParent(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListAssignmentsResponse response =
         reservationServiceClient.listAssignmentsCallable().call(request);
     for (Assignment element : response.getAssignmentsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAssignmentsRequest,ListAssignmentsResponse>

listAssignmentsPagedCallable()

public final UnaryCallable<ListAssignmentsRequest,ReservationServiceClient.ListAssignmentsPagedResponse> listAssignmentsPagedCallable()

Lists assignments.

Only explicitly created assignments will be returned.

Example:

  • Organization organizationA contains two projects, project1 and project2.
  • Reservation res1 exists and was created previously.
  • CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>

In this example, ListAssignments will just return the above two assignments for reservation res1, and no expansion/merge will happen.

The wildcard "-" can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListAssignmentsRequest request =
       ListAssignmentsRequest.newBuilder()
           .setParent(ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Assignment> future =
       reservationServiceClient.listAssignmentsPagedCallable().futureCall(request);
   // Do something.
   for (Assignment element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListAssignmentsRequest,ListAssignmentsPagedResponse>

listCapacityCommitments(ListCapacityCommitmentsRequest request)

public final ReservationServiceClient.ListCapacityCommitmentsPagedResponse listCapacityCommitments(ListCapacityCommitmentsRequest request)

Lists all the capacity commitments for the admin project.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListCapacityCommitmentsRequest request =
       ListCapacityCommitmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (CapacityCommitment element :
       reservationServiceClient.listCapacityCommitments(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListCapacityCommitmentsRequest

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

Returns
TypeDescription
ReservationServiceClient.ListCapacityCommitmentsPagedResponse

listCapacityCommitments(LocationName parent)

public final ReservationServiceClient.ListCapacityCommitmentsPagedResponse listCapacityCommitments(LocationName parent)

Lists all the capacity commitments for the admin project.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (CapacityCommitment element :
       reservationServiceClient.listCapacityCommitments(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. Resource name of the parent reservation. E.g., projects/myproject/locations/US

Returns
TypeDescription
ReservationServiceClient.ListCapacityCommitmentsPagedResponse

listCapacityCommitments(String parent)

public final ReservationServiceClient.ListCapacityCommitmentsPagedResponse listCapacityCommitments(String parent)

Lists all the capacity commitments for the admin project.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (CapacityCommitment element :
       reservationServiceClient.listCapacityCommitments(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. Resource name of the parent reservation. E.g., projects/myproject/locations/US

Returns
TypeDescription
ReservationServiceClient.ListCapacityCommitmentsPagedResponse

listCapacityCommitmentsCallable()

public final UnaryCallable<ListCapacityCommitmentsRequest,ListCapacityCommitmentsResponse> listCapacityCommitmentsCallable()

Lists all the capacity commitments for the admin project.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListCapacityCommitmentsRequest request =
       ListCapacityCommitmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListCapacityCommitmentsResponse response =
         reservationServiceClient.listCapacityCommitmentsCallable().call(request);
     for (CapacityCommitment element : response.getCapacityCommitmentsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListCapacityCommitmentsRequest,ListCapacityCommitmentsResponse>

listCapacityCommitmentsPagedCallable()

public final UnaryCallable<ListCapacityCommitmentsRequest,ReservationServiceClient.ListCapacityCommitmentsPagedResponse> listCapacityCommitmentsPagedCallable()

Lists all the capacity commitments for the admin project.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListCapacityCommitmentsRequest request =
       ListCapacityCommitmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<CapacityCommitment> future =
       reservationServiceClient.listCapacityCommitmentsPagedCallable().futureCall(request);
   // Do something.
   for (CapacityCommitment element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListCapacityCommitmentsRequest,ListCapacityCommitmentsPagedResponse>

listReservations(ListReservationsRequest request)

public final ReservationServiceClient.ListReservationsPagedResponse listReservations(ListReservationsRequest request)

Lists all the reservations for the project in the specified location.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListReservationsRequest request =
       ListReservationsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Reservation element : reservationServiceClient.listReservations(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListReservationsRequest

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

Returns
TypeDescription
ReservationServiceClient.ListReservationsPagedResponse

listReservations(LocationName parent)

public final ReservationServiceClient.ListReservationsPagedResponse listReservations(LocationName parent)

Lists all the reservations for the project in the specified location.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Reservation element : reservationServiceClient.listReservations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The parent resource name containing project and location, e.g.: projects/myproject/locations/US

Returns
TypeDescription
ReservationServiceClient.ListReservationsPagedResponse

listReservations(String parent)

public final ReservationServiceClient.ListReservationsPagedResponse listReservations(String parent)

Lists all the reservations for the project in the specified location.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (Reservation element : reservationServiceClient.listReservations(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The parent resource name containing project and location, e.g.: projects/myproject/locations/US

Returns
TypeDescription
ReservationServiceClient.ListReservationsPagedResponse

listReservationsCallable()

public final UnaryCallable<ListReservationsRequest,ListReservationsResponse> listReservationsCallable()

Lists all the reservations for the project in the specified location.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListReservationsRequest request =
       ListReservationsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListReservationsResponse response =
         reservationServiceClient.listReservationsCallable().call(request);
     for (Reservation element : response.getReservationsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListReservationsRequest,ListReservationsResponse>

listReservationsPagedCallable()

public final UnaryCallable<ListReservationsRequest,ReservationServiceClient.ListReservationsPagedResponse> listReservationsPagedCallable()

Lists all the reservations for the project in the specified location.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   ListReservationsRequest request =
       ListReservationsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Reservation> future =
       reservationServiceClient.listReservationsPagedCallable().futureCall(request);
   // Do something.
   for (Reservation element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListReservationsRequest,ListReservationsPagedResponse>

mergeCapacityCommitments(LocationName parent, List<String> capacityCommitmentIds)

public final CapacityCommitment mergeCapacityCommitments(LocationName parent, List<String> capacityCommitmentIds)

Merges capacity commitments of the same plan into a single commitment.

The resulting capacity commitment has the greater commitment_end_time out of the to-be-merged capacity commitments.

Attempting to merge capacity commitments of different plan will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   List<String> capacityCommitmentIds = new ArrayList<>();
   CapacityCommitment response =
       reservationServiceClient.mergeCapacityCommitments(parent, capacityCommitmentIds);
 }
 
Parameters
NameDescription
parentLocationName

Parent resource that identifies admin project and location e.g., projects/myproject/locations/us

capacityCommitmentIdsList<String>

Ids of capacity commitments to merge. These capacity commitments must exist under admin project and location specified in the parent. ID is the last portion of capacity commitment name e.g., 'abc' for projects/myproject/locations/US/capacityCommitments/abc

Returns
TypeDescription
CapacityCommitment

mergeCapacityCommitments(MergeCapacityCommitmentsRequest request)

public final CapacityCommitment mergeCapacityCommitments(MergeCapacityCommitmentsRequest request)

Merges capacity commitments of the same plan into a single commitment.

The resulting capacity commitment has the greater commitment_end_time out of the to-be-merged capacity commitments.

Attempting to merge capacity commitments of different plan will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   MergeCapacityCommitmentsRequest request =
       MergeCapacityCommitmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .addAllCapacityCommitmentIds(new ArrayList<String>())
           .build();
   CapacityCommitment response = reservationServiceClient.mergeCapacityCommitments(request);
 }
 
Parameter
NameDescription
requestMergeCapacityCommitmentsRequest

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

Returns
TypeDescription
CapacityCommitment

mergeCapacityCommitments(String parent, List<String> capacityCommitmentIds)

public final CapacityCommitment mergeCapacityCommitments(String parent, List<String> capacityCommitmentIds)

Merges capacity commitments of the same plan into a single commitment.

The resulting capacity commitment has the greater commitment_end_time out of the to-be-merged capacity commitments.

Attempting to merge capacity commitments of different plan will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   List<String> capacityCommitmentIds = new ArrayList<>();
   CapacityCommitment response =
       reservationServiceClient.mergeCapacityCommitments(parent, capacityCommitmentIds);
 }
 
Parameters
NameDescription
parentString

Parent resource that identifies admin project and location e.g., projects/myproject/locations/us

capacityCommitmentIdsList<String>

Ids of capacity commitments to merge. These capacity commitments must exist under admin project and location specified in the parent. ID is the last portion of capacity commitment name e.g., 'abc' for projects/myproject/locations/US/capacityCommitments/abc

Returns
TypeDescription
CapacityCommitment

mergeCapacityCommitmentsCallable()

public final UnaryCallable<MergeCapacityCommitmentsRequest,CapacityCommitment> mergeCapacityCommitmentsCallable()

Merges capacity commitments of the same plan into a single commitment.

The resulting capacity commitment has the greater commitment_end_time out of the to-be-merged capacity commitments.

Attempting to merge capacity commitments of different plan will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   MergeCapacityCommitmentsRequest request =
       MergeCapacityCommitmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .addAllCapacityCommitmentIds(new ArrayList<String>())
           .build();
   ApiFuture<CapacityCommitment> future =
       reservationServiceClient.mergeCapacityCommitmentsCallable().futureCall(request);
   // Do something.
   CapacityCommitment response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<MergeCapacityCommitmentsRequest,CapacityCommitment>

moveAssignment(AssignmentName name, ReservationName destinationId)

public final Assignment moveAssignment(AssignmentName name, ReservationName destinationId)

Moves an assignment under a new reservation.

This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   AssignmentName name =
       AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]");
   ReservationName destinationId =
       ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]");
   Assignment response = reservationServiceClient.moveAssignment(name, destinationId);
 }
 
Parameters
NameDescription
nameAssignmentName

Required. The resource name of the assignment, e.g. projects/myproject/locations/US/reservations/team1-prod/assignments/123

destinationIdReservationName

The new reservation ID, e.g.: projects/myotherproject/locations/US/reservations/team2-prod

Returns
TypeDescription
Assignment

moveAssignment(AssignmentName name, String destinationId)

public final Assignment moveAssignment(AssignmentName name, String destinationId)

Moves an assignment under a new reservation.

This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   AssignmentName name =
       AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]");
   String destinationId =
       ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString();
   Assignment response = reservationServiceClient.moveAssignment(name, destinationId);
 }
 
Parameters
NameDescription
nameAssignmentName

Required. The resource name of the assignment, e.g. projects/myproject/locations/US/reservations/team1-prod/assignments/123

destinationIdString

The new reservation ID, e.g.: projects/myotherproject/locations/US/reservations/team2-prod

Returns
TypeDescription
Assignment

moveAssignment(MoveAssignmentRequest request)

public final Assignment moveAssignment(MoveAssignmentRequest request)

Moves an assignment under a new reservation.

This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   MoveAssignmentRequest request =
       MoveAssignmentRequest.newBuilder()
           .setName(
               AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]")
                   .toString())
           .setDestinationId(
               ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .setAssignmentId("assignmentId-1603989304")
           .build();
   Assignment response = reservationServiceClient.moveAssignment(request);
 }
 
Parameter
NameDescription
requestMoveAssignmentRequest

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

Returns
TypeDescription
Assignment

moveAssignment(String name, ReservationName destinationId)

public final Assignment moveAssignment(String name, ReservationName destinationId)

Moves an assignment under a new reservation.

This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name =
       AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]").toString();
   ReservationName destinationId =
       ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]");
   Assignment response = reservationServiceClient.moveAssignment(name, destinationId);
 }
 
Parameters
NameDescription
nameString

Required. The resource name of the assignment, e.g. projects/myproject/locations/US/reservations/team1-prod/assignments/123

destinationIdReservationName

The new reservation ID, e.g.: projects/myotherproject/locations/US/reservations/team2-prod

Returns
TypeDescription
Assignment

moveAssignment(String name, String destinationId)

public final Assignment moveAssignment(String name, String destinationId)

Moves an assignment under a new reservation.

This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name =
       AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]").toString();
   String destinationId =
       ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString();
   Assignment response = reservationServiceClient.moveAssignment(name, destinationId);
 }
 
Parameters
NameDescription
nameString

Required. The resource name of the assignment, e.g. projects/myproject/locations/US/reservations/team1-prod/assignments/123

destinationIdString

The new reservation ID, e.g.: projects/myotherproject/locations/US/reservations/team2-prod

Returns
TypeDescription
Assignment

moveAssignmentCallable()

public final UnaryCallable<MoveAssignmentRequest,Assignment> moveAssignmentCallable()

Moves an assignment under a new reservation.

This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   MoveAssignmentRequest request =
       MoveAssignmentRequest.newBuilder()
           .setName(
               AssignmentName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]", "[ASSIGNMENT]")
                   .toString())
           .setDestinationId(
               ReservationName.of("[PROJECT]", "[LOCATION]", "[RESERVATION]").toString())
           .setAssignmentId("assignmentId-1603989304")
           .build();
   ApiFuture<Assignment> future =
       reservationServiceClient.moveAssignmentCallable().futureCall(request);
   // Do something.
   Assignment response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<MoveAssignmentRequest,Assignment>

searchAllAssignments(LocationName parent, String query)

public final ReservationServiceClient.SearchAllAssignmentsPagedResponse searchAllAssignments(LocationName parent, String query)

Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   String query = "query107944136";
   for (Assignment element :
       reservationServiceClient.searchAllAssignments(parent, query).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
NameDescription
parentLocationName

Required. The resource name with location (project name could be the wildcard '-'), e.g.: projects/-/locations/US.

queryString

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456

Returns
TypeDescription
ReservationServiceClient.SearchAllAssignmentsPagedResponse

searchAllAssignments(SearchAllAssignmentsRequest request)

public final ReservationServiceClient.SearchAllAssignmentsPagedResponse searchAllAssignments(SearchAllAssignmentsRequest request)

Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SearchAllAssignmentsRequest request =
       SearchAllAssignmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setQuery("query107944136")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Assignment element :
       reservationServiceClient.searchAllAssignments(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestSearchAllAssignmentsRequest

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

Returns
TypeDescription
ReservationServiceClient.SearchAllAssignmentsPagedResponse

searchAllAssignments(String parent, String query)

public final ReservationServiceClient.SearchAllAssignmentsPagedResponse searchAllAssignments(String parent, String query)

Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   String query = "query107944136";
   for (Assignment element :
       reservationServiceClient.searchAllAssignments(parent, query).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
NameDescription
parentString

Required. The resource name with location (project name could be the wildcard '-'), e.g.: projects/-/locations/US.

queryString

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456

Returns
TypeDescription
ReservationServiceClient.SearchAllAssignmentsPagedResponse

searchAllAssignmentsCallable()

public final UnaryCallable<SearchAllAssignmentsRequest,SearchAllAssignmentsResponse> searchAllAssignmentsCallable()

Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SearchAllAssignmentsRequest request =
       SearchAllAssignmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setQuery("query107944136")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     SearchAllAssignmentsResponse response =
         reservationServiceClient.searchAllAssignmentsCallable().call(request);
     for (Assignment element : response.getAssignmentsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchAllAssignmentsRequest,SearchAllAssignmentsResponse>

searchAllAssignmentsPagedCallable()

public final UnaryCallable<SearchAllAssignmentsRequest,ReservationServiceClient.SearchAllAssignmentsPagedResponse> searchAllAssignmentsPagedCallable()

Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SearchAllAssignmentsRequest request =
       SearchAllAssignmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setQuery("query107944136")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Assignment> future =
       reservationServiceClient.searchAllAssignmentsPagedCallable().futureCall(request);
   // Do something.
   for (Assignment element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchAllAssignmentsRequest,SearchAllAssignmentsPagedResponse>

searchAssignments(LocationName parent, String query) (deprecated)

public final ReservationServiceClient.SearchAssignmentsPagedResponse searchAssignments(LocationName parent, String query)

Deprecated. This method is deprecated and will be removed in the next major version update.

Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   String query = "query107944136";
   for (Assignment element :
       reservationServiceClient.searchAssignments(parent, query).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
NameDescription
parentLocationName

Required. The resource name of the admin project(containing project and location), e.g.: projects/myproject/locations/US.

queryString

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456

Returns
TypeDescription
ReservationServiceClient.SearchAssignmentsPagedResponse

searchAssignments(SearchAssignmentsRequest request) (deprecated)

public final ReservationServiceClient.SearchAssignmentsPagedResponse searchAssignments(SearchAssignmentsRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SearchAssignmentsRequest request =
       SearchAssignmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setQuery("query107944136")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Assignment element : reservationServiceClient.searchAssignments(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestSearchAssignmentsRequest

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

Returns
TypeDescription
ReservationServiceClient.SearchAssignmentsPagedResponse

searchAssignments(String parent, String query) (deprecated)

public final ReservationServiceClient.SearchAssignmentsPagedResponse searchAssignments(String parent, String query)

Deprecated. This method is deprecated and will be removed in the next major version update.

Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   String query = "query107944136";
   for (Assignment element :
       reservationServiceClient.searchAssignments(parent, query).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
NameDescription
parentString

Required. The resource name of the admin project(containing project and location), e.g.: projects/myproject/locations/US.

queryString

Please specify resource name as assignee in the query.

Examples:

  • assignee=projects/myproject
  • assignee=folders/123
  • assignee=organizations/456

Returns
TypeDescription
ReservationServiceClient.SearchAssignmentsPagedResponse

searchAssignmentsCallable() (deprecated)

public final UnaryCallable<SearchAssignmentsRequest,SearchAssignmentsResponse> searchAssignmentsCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SearchAssignmentsRequest request =
       SearchAssignmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setQuery("query107944136")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     SearchAssignmentsResponse response =
         reservationServiceClient.searchAssignmentsCallable().call(request);
     for (Assignment element : response.getAssignmentsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchAssignmentsRequest,SearchAssignmentsResponse>

searchAssignmentsPagedCallable() (deprecated)

public final UnaryCallable<SearchAssignmentsRequest,ReservationServiceClient.SearchAssignmentsPagedResponse> searchAssignmentsPagedCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project:

1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned.

The same logic applies if the request is about a folder.

If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors).

Comparing to ListAssignments, there are some behavior differences:

1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.

**Note** "-" cannot be used for projects nor locations.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SearchAssignmentsRequest request =
       SearchAssignmentsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setQuery("query107944136")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Assignment> future =
       reservationServiceClient.searchAssignmentsPagedCallable().futureCall(request);
   // Do something.
   for (Assignment element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<SearchAssignmentsRequest,SearchAssignmentsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

splitCapacityCommitment(CapacityCommitmentName name, long slotCount)

public final SplitCapacityCommitmentResponse splitCapacityCommitment(CapacityCommitmentName name, long slotCount)

Splits capacity commitment to two commitments of the same plan and commitment_end_time.

A common use case is to enable downgrading commitments.

For example, in order to downgrade from 10000 slots to 8000, you might split a 10000 capacity commitment into commitments of 2000 and 8000. Then, you delete the first one after the commitment end time passes.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CapacityCommitmentName name =
       CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]");
   long slotCount = -191518834;
   SplitCapacityCommitmentResponse response =
       reservationServiceClient.splitCapacityCommitment(name, slotCount);
 }
 
Parameters
NameDescription
nameCapacityCommitmentName

Required. The resource name e.g.,: projects/myproject/locations/US/capacityCommitments/123

slotCountlong

Number of slots in the capacity commitment after the split.

Returns
TypeDescription
SplitCapacityCommitmentResponse

splitCapacityCommitment(SplitCapacityCommitmentRequest request)

public final SplitCapacityCommitmentResponse splitCapacityCommitment(SplitCapacityCommitmentRequest request)

Splits capacity commitment to two commitments of the same plan and commitment_end_time.

A common use case is to enable downgrading commitments.

For example, in order to downgrade from 10000 slots to 8000, you might split a 10000 capacity commitment into commitments of 2000 and 8000. Then, you delete the first one after the commitment end time passes.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SplitCapacityCommitmentRequest request =
       SplitCapacityCommitmentRequest.newBuilder()
           .setName(
               CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]")
                   .toString())
           .setSlotCount(-191518834)
           .build();
   SplitCapacityCommitmentResponse response =
       reservationServiceClient.splitCapacityCommitment(request);
 }
 
Parameter
NameDescription
requestSplitCapacityCommitmentRequest

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

Returns
TypeDescription
SplitCapacityCommitmentResponse

splitCapacityCommitment(String name, long slotCount)

public final SplitCapacityCommitmentResponse splitCapacityCommitment(String name, long slotCount)

Splits capacity commitment to two commitments of the same plan and commitment_end_time.

A common use case is to enable downgrading commitments.

For example, in order to downgrade from 10000 slots to 8000, you might split a 10000 capacity commitment into commitments of 2000 and 8000. Then, you delete the first one after the commitment end time passes.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   String name =
       CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]").toString();
   long slotCount = -191518834;
   SplitCapacityCommitmentResponse response =
       reservationServiceClient.splitCapacityCommitment(name, slotCount);
 }
 
Parameters
NameDescription
nameString

Required. The resource name e.g.,: projects/myproject/locations/US/capacityCommitments/123

slotCountlong

Number of slots in the capacity commitment after the split.

Returns
TypeDescription
SplitCapacityCommitmentResponse

splitCapacityCommitmentCallable()

public final UnaryCallable<SplitCapacityCommitmentRequest,SplitCapacityCommitmentResponse> splitCapacityCommitmentCallable()

Splits capacity commitment to two commitments of the same plan and commitment_end_time.

A common use case is to enable downgrading commitments.

For example, in order to downgrade from 10000 slots to 8000, you might split a 10000 capacity commitment into commitments of 2000 and 8000. Then, you delete the first one after the commitment end time passes.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   SplitCapacityCommitmentRequest request =
       SplitCapacityCommitmentRequest.newBuilder()
           .setName(
               CapacityCommitmentName.of("[PROJECT]", "[LOCATION]", "[CAPACITY_COMMITMENT]")
                   .toString())
           .setSlotCount(-191518834)
           .build();
   ApiFuture<SplitCapacityCommitmentResponse> future =
       reservationServiceClient.splitCapacityCommitmentCallable().futureCall(request);
   // Do something.
   SplitCapacityCommitmentResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<SplitCapacityCommitmentRequest,SplitCapacityCommitmentResponse>

updateAssignment(Assignment assignment, FieldMask updateMask)

public final Assignment updateAssignment(Assignment assignment, FieldMask updateMask)

Updates an existing assignment.

Only the priority field can be updated.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   Assignment assignment = Assignment.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Assignment response = reservationServiceClient.updateAssignment(assignment, updateMask);
 }
 
Parameters
NameDescription
assignmentAssignment

Content of the assignment to update.

updateMaskFieldMask

Standard field mask for the set of fields to be updated.

Returns
TypeDescription
Assignment

updateAssignment(UpdateAssignmentRequest request)

public final Assignment updateAssignment(UpdateAssignmentRequest request)

Updates an existing assignment.

Only the priority field can be updated.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateAssignmentRequest request =
       UpdateAssignmentRequest.newBuilder()
           .setAssignment(Assignment.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Assignment response = reservationServiceClient.updateAssignment(request);
 }
 
Parameter
NameDescription
requestUpdateAssignmentRequest

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

Returns
TypeDescription
Assignment

updateAssignmentCallable()

public final UnaryCallable<UpdateAssignmentRequest,Assignment> updateAssignmentCallable()

Updates an existing assignment.

Only the priority field can be updated.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateAssignmentRequest request =
       UpdateAssignmentRequest.newBuilder()
           .setAssignment(Assignment.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Assignment> future =
       reservationServiceClient.updateAssignmentCallable().futureCall(request);
   // Do something.
   Assignment response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateAssignmentRequest,Assignment>

updateBiReservation(BiReservation biReservation, FieldMask updateMask)

public final BiReservation updateBiReservation(BiReservation biReservation, FieldMask updateMask)

Updates a BI reservation.

Only fields specified in the field_mask are updated.

A singleton BI reservation always exists with default size 0. In order to reserve BI capacity it needs to be updated to an amount greater than 0. In order to release BI capacity reservation size must be set to 0.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   BiReservation biReservation = BiReservation.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   BiReservation response =
       reservationServiceClient.updateBiReservation(biReservation, updateMask);
 }
 
Parameters
NameDescription
biReservationBiReservation

A reservation to update.

updateMaskFieldMask

A list of fields to be updated in this request.

Returns
TypeDescription
BiReservation

updateBiReservation(UpdateBiReservationRequest request)

public final BiReservation updateBiReservation(UpdateBiReservationRequest request)

Updates a BI reservation.

Only fields specified in the field_mask are updated.

A singleton BI reservation always exists with default size 0. In order to reserve BI capacity it needs to be updated to an amount greater than 0. In order to release BI capacity reservation size must be set to 0.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateBiReservationRequest request =
       UpdateBiReservationRequest.newBuilder()
           .setBiReservation(BiReservation.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   BiReservation response = reservationServiceClient.updateBiReservation(request);
 }
 
Parameter
NameDescription
requestUpdateBiReservationRequest

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

Returns
TypeDescription
BiReservation

updateBiReservationCallable()

public final UnaryCallable<UpdateBiReservationRequest,BiReservation> updateBiReservationCallable()

Updates a BI reservation.

Only fields specified in the field_mask are updated.

A singleton BI reservation always exists with default size 0. In order to reserve BI capacity it needs to be updated to an amount greater than 0. In order to release BI capacity reservation size must be set to 0.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateBiReservationRequest request =
       UpdateBiReservationRequest.newBuilder()
           .setBiReservation(BiReservation.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<BiReservation> future =
       reservationServiceClient.updateBiReservationCallable().futureCall(request);
   // Do something.
   BiReservation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateBiReservationRequest,BiReservation>

updateCapacityCommitment(CapacityCommitment capacityCommitment, FieldMask updateMask)

public final CapacityCommitment updateCapacityCommitment(CapacityCommitment capacityCommitment, FieldMask updateMask)

Updates an existing capacity commitment.

Only plan and renewal_plan fields can be updated.

Plan can only be changed to a plan of a longer commitment period. Attempting to change to a plan with shorter commitment period will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   CapacityCommitment capacityCommitment = CapacityCommitment.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   CapacityCommitment response =
       reservationServiceClient.updateCapacityCommitment(capacityCommitment, updateMask);
 }
 
Parameters
NameDescription
capacityCommitmentCapacityCommitment

Content of the capacity commitment to update.

updateMaskFieldMask

Standard field mask for the set of fields to be updated.

Returns
TypeDescription
CapacityCommitment

updateCapacityCommitment(UpdateCapacityCommitmentRequest request)

public final CapacityCommitment updateCapacityCommitment(UpdateCapacityCommitmentRequest request)

Updates an existing capacity commitment.

Only plan and renewal_plan fields can be updated.

Plan can only be changed to a plan of a longer commitment period. Attempting to change to a plan with shorter commitment period will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateCapacityCommitmentRequest request =
       UpdateCapacityCommitmentRequest.newBuilder()
           .setCapacityCommitment(CapacityCommitment.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   CapacityCommitment response = reservationServiceClient.updateCapacityCommitment(request);
 }
 
Parameter
NameDescription
requestUpdateCapacityCommitmentRequest

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

Returns
TypeDescription
CapacityCommitment

updateCapacityCommitmentCallable()

public final UnaryCallable<UpdateCapacityCommitmentRequest,CapacityCommitment> updateCapacityCommitmentCallable()

Updates an existing capacity commitment.

Only plan and renewal_plan fields can be updated.

Plan can only be changed to a plan of a longer commitment period. Attempting to change to a plan with shorter commitment period will fail with the error code google.rpc.Code.FAILED_PRECONDITION.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateCapacityCommitmentRequest request =
       UpdateCapacityCommitmentRequest.newBuilder()
           .setCapacityCommitment(CapacityCommitment.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<CapacityCommitment> future =
       reservationServiceClient.updateCapacityCommitmentCallable().futureCall(request);
   // Do something.
   CapacityCommitment response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateCapacityCommitmentRequest,CapacityCommitment>

updateReservation(Reservation reservation, FieldMask updateMask)

public final Reservation updateReservation(Reservation reservation, FieldMask updateMask)

Updates an existing reservation resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   Reservation reservation = Reservation.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Reservation response = reservationServiceClient.updateReservation(reservation, updateMask);
 }
 
Parameters
NameDescription
reservationReservation

Content of the reservation to update.

updateMaskFieldMask

Standard field mask for the set of fields to be updated.

Returns
TypeDescription
Reservation

updateReservation(UpdateReservationRequest request)

public final Reservation updateReservation(UpdateReservationRequest request)

Updates an existing reservation resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateReservationRequest request =
       UpdateReservationRequest.newBuilder()
           .setReservation(Reservation.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Reservation response = reservationServiceClient.updateReservation(request);
 }
 
Parameter
NameDescription
requestUpdateReservationRequest

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

Returns
TypeDescription
Reservation

updateReservationCallable()

public final UnaryCallable<UpdateReservationRequest,Reservation> updateReservationCallable()

Updates an existing reservation resource.

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 (ReservationServiceClient reservationServiceClient = ReservationServiceClient.create()) {
   UpdateReservationRequest request =
       UpdateReservationRequest.newBuilder()
           .setReservation(Reservation.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Reservation> future =
       reservationServiceClient.updateReservationCallable().futureCall(request);
   // Do something.
   Reservation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateReservationRequest,Reservation>