@Generated(value="by gapic-generator-java") public class ReservationServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
A reservation provides computational resource guarantees, in the form of [slots](https://cloud.google.com/bigquery/docs/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:
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.
| Modifier | Constructor and Description |
|---|---|
protected |
ReservationServiceClient(ReservationServiceSettings settings)
Constructs an instance of ReservationServiceClient, using the given settings.
|
protected |
ReservationServiceClient(ReservationServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ReservationServiceClient |
create()
Constructs an instance of ReservationServiceClient with default settings.
|
static ReservationServiceClient |
create(ReservationServiceSettings settings)
Constructs an instance of ReservationServiceClient, using the given settings.
|
static ReservationServiceClient |
create(ReservationServiceStub stub)
Constructs an instance of ReservationServiceClient, using the given stub for making calls.
|
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.
|
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.
|
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.
|
com.google.api.gax.rpc.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.
|
CapacityCommitment |
createCapacityCommitment(CreateCapacityCommitmentRequest request)
Creates a new capacity commitment resource.
|
CapacityCommitment |
createCapacityCommitment(LocationName parent,
CapacityCommitment capacityCommitment)
Creates a new capacity commitment resource.
|
CapacityCommitment |
createCapacityCommitment(String parent,
CapacityCommitment capacityCommitment)
Creates a new capacity commitment resource.
|
com.google.api.gax.rpc.UnaryCallable<CreateCapacityCommitmentRequest,CapacityCommitment> |
createCapacityCommitmentCallable()
Creates a new capacity commitment resource.
|
Reservation |
createReservation(CreateReservationRequest request)
Creates a new reservation resource.
|
Reservation |
createReservation(LocationName parent,
Reservation reservation,
String reservationId)
Creates a new reservation resource.
|
Reservation |
createReservation(String parent,
Reservation reservation,
String reservationId)
Creates a new reservation resource.
|
com.google.api.gax.rpc.UnaryCallable<CreateReservationRequest,Reservation> |
createReservationCallable()
Creates a new reservation resource.
|
void |
deleteAssignment(AssignmentName name)
Deletes a assignment.
|
void |
deleteAssignment(DeleteAssignmentRequest request)
Deletes a assignment.
|
void |
deleteAssignment(String name)
Deletes a assignment.
|
com.google.api.gax.rpc.UnaryCallable<DeleteAssignmentRequest,com.google.protobuf.Empty> |
deleteAssignmentCallable()
Deletes a assignment.
|
void |
deleteCapacityCommitment(CapacityCommitmentName name)
Deletes a capacity commitment.
|
void |
deleteCapacityCommitment(DeleteCapacityCommitmentRequest request)
Deletes a capacity commitment.
|
void |
deleteCapacityCommitment(String name)
Deletes a capacity commitment.
|
com.google.api.gax.rpc.UnaryCallable<DeleteCapacityCommitmentRequest,com.google.protobuf.Empty> |
deleteCapacityCommitmentCallable()
Deletes a capacity commitment.
|
void |
deleteReservation(DeleteReservationRequest request)
Deletes a reservation.
|
void |
deleteReservation(ReservationName name)
Deletes a reservation.
|
void |
deleteReservation(String name)
Deletes a reservation.
|
com.google.api.gax.rpc.UnaryCallable<DeleteReservationRequest,com.google.protobuf.Empty> |
deleteReservationCallable()
Deletes a reservation.
|
BiReservation |
getBiReservation(BiReservationName name)
Retrieves a BI reservation.
|
BiReservation |
getBiReservation(GetBiReservationRequest request)
Retrieves a BI reservation.
|
BiReservation |
getBiReservation(String name)
Retrieves a BI reservation.
|
com.google.api.gax.rpc.UnaryCallable<GetBiReservationRequest,BiReservation> |
getBiReservationCallable()
Retrieves a BI reservation.
|
CapacityCommitment |
getCapacityCommitment(CapacityCommitmentName name)
Returns information about the capacity commitment.
|
CapacityCommitment |
getCapacityCommitment(GetCapacityCommitmentRequest request)
Returns information about the capacity commitment.
|
CapacityCommitment |
getCapacityCommitment(String name)
Returns information about the capacity commitment.
|
com.google.api.gax.rpc.UnaryCallable<GetCapacityCommitmentRequest,CapacityCommitment> |
getCapacityCommitmentCallable()
Returns information about the capacity commitment.
|
Reservation |
getReservation(GetReservationRequest request)
Returns information about the reservation.
|
Reservation |
getReservation(ReservationName name)
Returns information about the reservation.
|
Reservation |
getReservation(String name)
Returns information about the reservation.
|
com.google.api.gax.rpc.UnaryCallable<GetReservationRequest,Reservation> |
getReservationCallable()
Returns information about the reservation.
|
ReservationServiceSettings |
getSettings() |
ReservationServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
ReservationServiceClient.ListAssignmentsPagedResponse |
listAssignments(ListAssignmentsRequest request)
Lists assignments.
|
ReservationServiceClient.ListAssignmentsPagedResponse |
listAssignments(ReservationName parent)
Lists assignments.
|
ReservationServiceClient.ListAssignmentsPagedResponse |
listAssignments(String parent)
Lists assignments.
|
com.google.api.gax.rpc.UnaryCallable<ListAssignmentsRequest,ListAssignmentsResponse> |
listAssignmentsCallable()
Lists assignments.
|
com.google.api.gax.rpc.UnaryCallable<ListAssignmentsRequest,ReservationServiceClient.ListAssignmentsPagedResponse> |
listAssignmentsPagedCallable()
Lists assignments.
|
ReservationServiceClient.ListCapacityCommitmentsPagedResponse |
listCapacityCommitments(ListCapacityCommitmentsRequest request)
Lists all the capacity commitments for the admin project.
|
ReservationServiceClient.ListCapacityCommitmentsPagedResponse |
listCapacityCommitments(LocationName parent)
Lists all the capacity commitments for the admin project.
|
ReservationServiceClient.ListCapacityCommitmentsPagedResponse |
listCapacityCommitments(String parent)
Lists all the capacity commitments for the admin project.
|
com.google.api.gax.rpc.UnaryCallable<ListCapacityCommitmentsRequest,ListCapacityCommitmentsResponse> |
listCapacityCommitmentsCallable()
Lists all the capacity commitments for the admin project.
|
com.google.api.gax.rpc.UnaryCallable<ListCapacityCommitmentsRequest,ReservationServiceClient.ListCapacityCommitmentsPagedResponse> |
listCapacityCommitmentsPagedCallable()
Lists all the capacity commitments for the admin project.
|
ReservationServiceClient.ListReservationsPagedResponse |
listReservations(ListReservationsRequest request)
Lists all the reservations for the project in the specified location.
|
ReservationServiceClient.ListReservationsPagedResponse |
listReservations(LocationName parent)
Lists all the reservations for the project in the specified location.
|
ReservationServiceClient.ListReservationsPagedResponse |
listReservations(String parent)
Lists all the reservations for the project in the specified location.
|
com.google.api.gax.rpc.UnaryCallable<ListReservationsRequest,ListReservationsResponse> |
listReservationsCallable()
Lists all the reservations for the project in the specified location.
|
com.google.api.gax.rpc.UnaryCallable<ListReservationsRequest,ReservationServiceClient.ListReservationsPagedResponse> |
listReservationsPagedCallable()
Lists all the reservations for the project in the specified location.
|
CapacityCommitment |
mergeCapacityCommitments(LocationName parent,
List<String> capacityCommitmentIds)
Merges capacity commitments of the same plan into a single commitment.
|
CapacityCommitment |
mergeCapacityCommitments(MergeCapacityCommitmentsRequest request)
Merges capacity commitments of the same plan into a single commitment.
|
CapacityCommitment |
mergeCapacityCommitments(String parent,
List<String> capacityCommitmentIds)
Merges capacity commitments of the same plan into a single commitment.
|
com.google.api.gax.rpc.UnaryCallable<MergeCapacityCommitmentsRequest,CapacityCommitment> |
mergeCapacityCommitmentsCallable()
Merges capacity commitments of the same plan into a single commitment.
|
Assignment |
moveAssignment(AssignmentName name,
ReservationName destinationId)
Moves an assignment under a new reservation.
|
Assignment |
moveAssignment(AssignmentName name,
String destinationId)
Moves an assignment under a new reservation.
|
Assignment |
moveAssignment(MoveAssignmentRequest request)
Moves an assignment under a new reservation.
|
Assignment |
moveAssignment(String name,
ReservationName destinationId)
Moves an assignment under a new reservation.
|
Assignment |
moveAssignment(String name,
String destinationId)
Moves an assignment under a new reservation.
|
com.google.api.gax.rpc.UnaryCallable<MoveAssignmentRequest,Assignment> |
moveAssignmentCallable()
Moves an assignment under a new reservation.
|
ReservationServiceClient.SearchAllAssignmentsPagedResponse |
searchAllAssignments(LocationName parent,
String query)
Looks up assignments for a specified resource for a particular region.
|
ReservationServiceClient.SearchAllAssignmentsPagedResponse |
searchAllAssignments(SearchAllAssignmentsRequest request)
Looks up assignments for a specified resource for a particular region.
|
ReservationServiceClient.SearchAllAssignmentsPagedResponse |
searchAllAssignments(String parent,
String query)
Looks up assignments for a specified resource for a particular region.
|
com.google.api.gax.rpc.UnaryCallable<SearchAllAssignmentsRequest,SearchAllAssignmentsResponse> |
searchAllAssignmentsCallable()
Looks up assignments for a specified resource for a particular region.
|
com.google.api.gax.rpc.UnaryCallable<SearchAllAssignmentsRequest,ReservationServiceClient.SearchAllAssignmentsPagedResponse> |
searchAllAssignmentsPagedCallable()
Looks up assignments for a specified resource for a particular region.
|
ReservationServiceClient.SearchAssignmentsPagedResponse |
searchAssignments(LocationName parent,
String query)
Deprecated.
This method is deprecated and will be removed in the next major version update.
|
ReservationServiceClient.SearchAssignmentsPagedResponse |
searchAssignments(SearchAssignmentsRequest request)
Deprecated.
This method is deprecated and will be removed in the next major version update.
|
ReservationServiceClient.SearchAssignmentsPagedResponse |
searchAssignments(String parent,
String query)
Deprecated.
This method is deprecated and will be removed in the next major version update.
|
com.google.api.gax.rpc.UnaryCallable<SearchAssignmentsRequest,SearchAssignmentsResponse> |
searchAssignmentsCallable()
Deprecated.
This method is deprecated and will be removed in the next major version update.
|
com.google.api.gax.rpc.UnaryCallable<SearchAssignmentsRequest,ReservationServiceClient.SearchAssignmentsPagedResponse> |
searchAssignmentsPagedCallable()
Deprecated.
This method is deprecated and will be removed in the next major version update.
|
void |
shutdown() |
void |
shutdownNow() |
SplitCapacityCommitmentResponse |
splitCapacityCommitment(CapacityCommitmentName name,
long slotCount)
Splits capacity commitment to two commitments of the same plan and `commitment_end_time`.
|
SplitCapacityCommitmentResponse |
splitCapacityCommitment(SplitCapacityCommitmentRequest request)
Splits capacity commitment to two commitments of the same plan and `commitment_end_time`.
|
SplitCapacityCommitmentResponse |
splitCapacityCommitment(String name,
long slotCount)
Splits capacity commitment to two commitments of the same plan and `commitment_end_time`.
|
com.google.api.gax.rpc.UnaryCallable<SplitCapacityCommitmentRequest,SplitCapacityCommitmentResponse> |
splitCapacityCommitmentCallable()
Splits capacity commitment to two commitments of the same plan and `commitment_end_time`.
|
Assignment |
updateAssignment(Assignment assignment,
com.google.protobuf.FieldMask updateMask)
Updates an existing assignment.
|
Assignment |
updateAssignment(UpdateAssignmentRequest request)
Updates an existing assignment.
|
com.google.api.gax.rpc.UnaryCallable<UpdateAssignmentRequest,Assignment> |
updateAssignmentCallable()
Updates an existing assignment.
|
BiReservation |
updateBiReservation(BiReservation biReservation,
com.google.protobuf.FieldMask updateMask)
Updates a BI reservation.
|
BiReservation |
updateBiReservation(UpdateBiReservationRequest request)
Updates a BI reservation.
|
com.google.api.gax.rpc.UnaryCallable<UpdateBiReservationRequest,BiReservation> |
updateBiReservationCallable()
Updates a BI reservation.
|
CapacityCommitment |
updateCapacityCommitment(CapacityCommitment capacityCommitment,
com.google.protobuf.FieldMask updateMask)
Updates an existing capacity commitment.
|
CapacityCommitment |
updateCapacityCommitment(UpdateCapacityCommitmentRequest request)
Updates an existing capacity commitment.
|
com.google.api.gax.rpc.UnaryCallable<UpdateCapacityCommitmentRequest,CapacityCommitment> |
updateCapacityCommitmentCallable()
Updates an existing capacity commitment.
|
Reservation |
updateReservation(Reservation reservation,
com.google.protobuf.FieldMask updateMask)
Updates an existing reservation resource.
|
Reservation |
updateReservation(UpdateReservationRequest request)
Updates an existing reservation resource.
|
com.google.api.gax.rpc.UnaryCallable<UpdateReservationRequest,Reservation> |
updateReservationCallable()
Updates an existing reservation resource.
|
protected ReservationServiceClient(ReservationServiceSettings settings) throws IOException
IOExceptionprotected ReservationServiceClient(ReservationServiceStub stub)
public static final ReservationServiceClient create() throws IOException
IOExceptionpublic static final ReservationServiceClient create(ReservationServiceSettings settings) throws IOException
IOExceptionpublic static final ReservationServiceClient create(ReservationServiceStub stub)
public final ReservationServiceSettings getSettings()
public ReservationServiceStub getStub()
public final Reservation createReservation(LocationName parent, Reservation reservation, String reservationId)
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);
}
parent - Required. Project, location. E.g., `projects/myproject/locations/US`reservation - Definition of the new reservation to create.reservationId - 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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Reservation createReservation(String parent, Reservation reservation, String reservationId)
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);
}
parent - Required. Project, location. E.g., `projects/myproject/locations/US`reservation - Definition of the new reservation to create.reservationId - 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.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Reservation createReservation(CreateReservationRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateReservationRequest,Reservation> createReservationCallable()
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();
}
public final ReservationServiceClient.ListReservationsPagedResponse listReservations(LocationName parent)
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);
}
}
parent - Required. The parent resource name containing project and location, e.g.:
`projects/myproject/locations/US`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.ListReservationsPagedResponse listReservations(String parent)
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);
}
}
parent - Required. The parent resource name containing project and location, e.g.:
`projects/myproject/locations/US`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.ListReservationsPagedResponse listReservations(ListReservationsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListReservationsRequest,ReservationServiceClient.ListReservationsPagedResponse> listReservationsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListReservationsRequest,ListReservationsResponse> listReservationsCallable()
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;
}
}
}
public final Reservation getReservation(ReservationName name)
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);
}
name - Required. Resource name of the reservation to retrieve. E.g.,
`projects/myproject/locations/US/reservations/team1-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Reservation getReservation(String name)
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);
}
name - Required. Resource name of the reservation to retrieve. E.g.,
`projects/myproject/locations/US/reservations/team1-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Reservation getReservation(GetReservationRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetReservationRequest,Reservation> getReservationCallable()
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();
}
public final void deleteReservation(ReservationName name)
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);
}
name - Required. Resource name of the reservation to retrieve. E.g.,
`projects/myproject/locations/US/reservations/team1-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteReservation(String name)
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);
}
name - Required. Resource name of the reservation to retrieve. E.g.,
`projects/myproject/locations/US/reservations/team1-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteReservation(DeleteReservationRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteReservationRequest,com.google.protobuf.Empty> deleteReservationCallable()
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();
}
public final Reservation updateReservation(Reservation reservation, com.google.protobuf.FieldMask updateMask)
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);
}
reservation - Content of the reservation to update.updateMask - Standard field mask for the set of fields to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Reservation updateReservation(UpdateReservationRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateReservationRequest,Reservation> updateReservationCallable()
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();
}
public final CapacityCommitment createCapacityCommitment(LocationName parent, CapacityCommitment capacityCommitment)
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);
}
parent - Required. Resource name of the parent reservation. E.g.,
`projects/myproject/locations/US`capacityCommitment - Content of the capacity commitment to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CapacityCommitment createCapacityCommitment(String parent, CapacityCommitment capacityCommitment)
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);
}
parent - Required. Resource name of the parent reservation. E.g.,
`projects/myproject/locations/US`capacityCommitment - Content of the capacity commitment to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CapacityCommitment createCapacityCommitment(CreateCapacityCommitmentRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateCapacityCommitmentRequest,CapacityCommitment> createCapacityCommitmentCallable()
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();
}
public final ReservationServiceClient.ListCapacityCommitmentsPagedResponse listCapacityCommitments(LocationName parent)
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);
}
}
parent - Required. Resource name of the parent reservation. E.g.,
`projects/myproject/locations/US`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.ListCapacityCommitmentsPagedResponse listCapacityCommitments(String parent)
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);
}
}
parent - Required. Resource name of the parent reservation. E.g.,
`projects/myproject/locations/US`com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.ListCapacityCommitmentsPagedResponse listCapacityCommitments(ListCapacityCommitmentsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListCapacityCommitmentsRequest,ReservationServiceClient.ListCapacityCommitmentsPagedResponse> listCapacityCommitmentsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListCapacityCommitmentsRequest,ListCapacityCommitmentsResponse> listCapacityCommitmentsCallable()
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;
}
}
}
public final CapacityCommitment getCapacityCommitment(CapacityCommitmentName name)
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);
}
name - Required. Resource name of the capacity commitment to retrieve. E.g.,
`projects/myproject/locations/US/capacityCommitments/123`com.google.api.gax.rpc.ApiException - if the remote call failspublic final CapacityCommitment getCapacityCommitment(String name)
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);
}
name - Required. Resource name of the capacity commitment to retrieve. E.g.,
`projects/myproject/locations/US/capacityCommitments/123`com.google.api.gax.rpc.ApiException - if the remote call failspublic final CapacityCommitment getCapacityCommitment(GetCapacityCommitmentRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetCapacityCommitmentRequest,CapacityCommitment> getCapacityCommitmentCallable()
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();
}
public final void deleteCapacityCommitment(CapacityCommitmentName name)
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);
}
name - Required. Resource name of the capacity commitment to delete. E.g.,
`projects/myproject/locations/US/capacityCommitments/123`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteCapacityCommitment(String name)
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);
}
name - Required. Resource name of the capacity commitment to delete. E.g.,
`projects/myproject/locations/US/capacityCommitments/123`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteCapacityCommitment(DeleteCapacityCommitmentRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteCapacityCommitmentRequest,com.google.protobuf.Empty> deleteCapacityCommitmentCallable()
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();
}
public final CapacityCommitment updateCapacityCommitment(CapacityCommitment capacityCommitment, com.google.protobuf.FieldMask updateMask)
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);
}
capacityCommitment - Content of the capacity commitment to update.updateMask - Standard field mask for the set of fields to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CapacityCommitment updateCapacityCommitment(UpdateCapacityCommitmentRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateCapacityCommitmentRequest,CapacityCommitment> updateCapacityCommitmentCallable()
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();
}
public final SplitCapacityCommitmentResponse splitCapacityCommitment(CapacityCommitmentName name, long slotCount)
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);
}
name - Required. The resource name e.g.,:
`projects/myproject/locations/US/capacityCommitments/123`slotCount - Number of slots in the capacity commitment after the split.com.google.api.gax.rpc.ApiException - if the remote call failspublic final SplitCapacityCommitmentResponse splitCapacityCommitment(String name, long slotCount)
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);
}
name - Required. The resource name e.g.,:
`projects/myproject/locations/US/capacityCommitments/123`slotCount - Number of slots in the capacity commitment after the split.com.google.api.gax.rpc.ApiException - if the remote call failspublic final SplitCapacityCommitmentResponse splitCapacityCommitment(SplitCapacityCommitmentRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<SplitCapacityCommitmentRequest,SplitCapacityCommitmentResponse> splitCapacityCommitmentCallable()
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();
}
public final CapacityCommitment mergeCapacityCommitments(LocationName parent, List<String> capacityCommitmentIds)
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);
}
parent - Parent resource that identifies admin project and location e.g.,
`projects/myproject/locations/us`capacityCommitmentIds - 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/abccom.google.api.gax.rpc.ApiException - if the remote call failspublic final CapacityCommitment mergeCapacityCommitments(String parent, List<String> capacityCommitmentIds)
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);
}
parent - Parent resource that identifies admin project and location e.g.,
`projects/myproject/locations/us`capacityCommitmentIds - 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/abccom.google.api.gax.rpc.ApiException - if the remote call failspublic final CapacityCommitment mergeCapacityCommitments(MergeCapacityCommitmentsRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<MergeCapacityCommitmentsRequest,CapacityCommitment> mergeCapacityCommitmentsCallable()
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();
}
public final Assignment createAssignment(ReservationName parent, Assignment assignment)
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:
"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);
}
parent - Required. The parent resource name of the assignment E.g.
`projects/myproject/locations/US/reservations/team1-prod`assignment - Assignment resource to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Assignment createAssignment(String parent, Assignment assignment)
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:
"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);
}
parent - Required. The parent resource name of the assignment E.g.
`projects/myproject/locations/US/reservations/team1-prod`assignment - Assignment resource to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Assignment createAssignment(CreateAssignmentRequest request)
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:
"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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateAssignmentRequest,Assignment> createAssignmentCallable()
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:
"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();
}
public final ReservationServiceClient.ListAssignmentsPagedResponse listAssignments(ReservationName parent)
Only explicitly created assignments will be returned.
Example:
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);
}
}
parent - Required. The parent resource name e.g.:
`projects/myproject/locations/US/reservations/team1-prod`
Or:
`projects/myproject/locations/US/reservations/-`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.ListAssignmentsPagedResponse listAssignments(String parent)
Only explicitly created assignments will be returned.
Example:
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);
}
}
parent - Required. The parent resource name e.g.:
`projects/myproject/locations/US/reservations/team1-prod`
Or:
`projects/myproject/locations/US/reservations/-`
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.ListAssignmentsPagedResponse listAssignments(ListAssignmentsRequest request)
Only explicitly created assignments will be returned.
Example:
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListAssignmentsRequest,ReservationServiceClient.ListAssignmentsPagedResponse> listAssignmentsPagedCallable()
Only explicitly created assignments will be returned.
Example:
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListAssignmentsRequest,ListAssignmentsResponse> listAssignmentsCallable()
Only explicitly created assignments will be returned.
Example:
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;
}
}
}
public final void deleteAssignment(AssignmentName name)
Example:
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);
}
name - Required. Name of the resource, e.g.
`projects/myproject/locations/US/reservations/team1-prod/assignments/123`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteAssignment(String name)
Example:
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);
}
name - Required. Name of the resource, e.g.
`projects/myproject/locations/US/reservations/team1-prod/assignments/123`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteAssignment(DeleteAssignmentRequest request)
Example:
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteAssignmentRequest,com.google.protobuf.Empty> deleteAssignmentCallable()
Example:
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();
}
@Deprecated public final ReservationServiceClient.SearchAssignmentsPagedResponse searchAssignments(LocationName parent, String query)
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);
}
}
parent - Required. The resource name of the admin project(containing project and
location), e.g.: `projects/myproject/locations/US`.query - Please specify resource name as assignee in the query.
Examples:
com.google.api.gax.rpc.ApiException - if the remote call fails@Deprecated public final ReservationServiceClient.SearchAssignmentsPagedResponse searchAssignments(String parent, String query)
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);
}
}
parent - Required. The resource name of the admin project(containing project and
location), e.g.: `projects/myproject/locations/US`.query - Please specify resource name as assignee in the query.
Examples:
com.google.api.gax.rpc.ApiException - if the remote call fails@Deprecated public final ReservationServiceClient.SearchAssignmentsPagedResponse searchAssignments(SearchAssignmentsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call fails@Deprecated public final com.google.api.gax.rpc.UnaryCallable<SearchAssignmentsRequest,ReservationServiceClient.SearchAssignmentsPagedResponse> searchAssignmentsPagedCallable()
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);
}
}
@Deprecated public final com.google.api.gax.rpc.UnaryCallable<SearchAssignmentsRequest,SearchAssignmentsResponse> searchAssignmentsCallable()
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;
}
}
}
public final ReservationServiceClient.SearchAllAssignmentsPagedResponse searchAllAssignments(LocationName parent, String query)
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);
}
}
parent - Required. The resource name with location (project name could be the wildcard
'-'), e.g.: `projects/-/locations/US`.query - Please specify resource name as assignee in the query.
Examples:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.SearchAllAssignmentsPagedResponse searchAllAssignments(String parent, String query)
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);
}
}
parent - Required. The resource name with location (project name could be the wildcard
'-'), e.g.: `projects/-/locations/US`.query - Please specify resource name as assignee in the query.
Examples:
com.google.api.gax.rpc.ApiException - if the remote call failspublic final ReservationServiceClient.SearchAllAssignmentsPagedResponse searchAllAssignments(SearchAllAssignmentsRequest request)
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<SearchAllAssignmentsRequest,ReservationServiceClient.SearchAllAssignmentsPagedResponse> searchAllAssignmentsPagedCallable()
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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<SearchAllAssignmentsRequest,SearchAllAssignmentsResponse> searchAllAssignmentsCallable()
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;
}
}
}
public final Assignment moveAssignment(AssignmentName name, ReservationName destinationId)
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);
}
name - Required. The resource name of the assignment, e.g.
`projects/myproject/locations/US/reservations/team1-prod/assignments/123`destinationId - The new reservation ID, e.g.:
`projects/myotherproject/locations/US/reservations/team2-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Assignment moveAssignment(AssignmentName name, String destinationId)
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);
}
name - Required. The resource name of the assignment, e.g.
`projects/myproject/locations/US/reservations/team1-prod/assignments/123`destinationId - The new reservation ID, e.g.:
`projects/myotherproject/locations/US/reservations/team2-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Assignment moveAssignment(String name, ReservationName destinationId)
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);
}
name - Required. The resource name of the assignment, e.g.
`projects/myproject/locations/US/reservations/team1-prod/assignments/123`destinationId - The new reservation ID, e.g.:
`projects/myotherproject/locations/US/reservations/team2-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Assignment moveAssignment(String name, String destinationId)
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);
}
name - Required. The resource name of the assignment, e.g.
`projects/myproject/locations/US/reservations/team1-prod/assignments/123`destinationId - The new reservation ID, e.g.:
`projects/myotherproject/locations/US/reservations/team2-prod`com.google.api.gax.rpc.ApiException - if the remote call failspublic final Assignment moveAssignment(MoveAssignmentRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<MoveAssignmentRequest,Assignment> moveAssignmentCallable()
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();
}
public final Assignment updateAssignment(Assignment assignment, com.google.protobuf.FieldMask updateMask)
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);
}
assignment - Content of the assignment to update.updateMask - Standard field mask for the set of fields to be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Assignment updateAssignment(UpdateAssignmentRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateAssignmentRequest,Assignment> updateAssignmentCallable()
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();
}
public final BiReservation getBiReservation(BiReservationName name)
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);
}
name - Required. Name of the requested reservation, for example:
`projects/{project_id}/locations/{location_id}/biReservation`com.google.api.gax.rpc.ApiException - if the remote call failspublic final BiReservation getBiReservation(String name)
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);
}
name - Required. Name of the requested reservation, for example:
`projects/{project_id}/locations/{location_id}/biReservation`com.google.api.gax.rpc.ApiException - if the remote call failspublic final BiReservation getBiReservation(GetBiReservationRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetBiReservationRequest,BiReservation> getBiReservationCallable()
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();
}
public final BiReservation updateBiReservation(BiReservation biReservation, com.google.protobuf.FieldMask updateMask)
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);
}
biReservation - A reservation to update.updateMask - A list of fields to be updated in this request.com.google.api.gax.rpc.ApiException - if the remote call failspublic final BiReservation updateBiReservation(UpdateBiReservationRequest request)
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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateBiReservationRequest,BiReservation> updateBiReservationCallable()
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();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2023 Google LLC. All rights reserved.