@Generated(value="by gapic-generator-java") public class CloudBuildClient extends Object implements com.google.api.gax.core.BackgroundResource
The main concept used by this API is a `Build`, which describes the location of the source to build, how to build the source, and where to store the built artifacts, if any.
A user can list previously-requested builds or get builds by their ID to determine the status of the build.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String id = "id3355";
Build response = cloudBuildClient.getBuild(projectId, id);
}
Note: close() needs to be called on the CloudBuildClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
CreateBuild |
Starts a build with the specified configuration. This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`). |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetBuild |
Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListBuilds |
Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CancelBuild |
Cancels a build in progress. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RetryBuild |
Creates a new build based on the specified build. This method creates a new build using the original build request, which may or may not result in an identical build. For triggered builds:
For non-triggered builds that specify `RepoSource`:
For builds that specify `StorageSource`:
|
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ApproveBuild |
Approves or rejects a pending build. If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateBuildTrigger |
Creates a new `BuildTrigger`. This API is experimental. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetBuildTrigger |
Returns information about a `BuildTrigger`. This API is experimental. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListBuildTriggers |
Lists existing `BuildTrigger`s. This API is experimental. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteBuildTrigger |
Deletes a `BuildTrigger` by its project ID and trigger ID. This API is experimental. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateBuildTrigger |
Updates a `BuildTrigger` by its project ID and trigger ID. This API is experimental. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
RunBuildTrigger |
Runs a `BuildTrigger` at a particular source revision. To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ReceiveTriggerWebhook |
ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateWorkerPool |
Creates a `WorkerPool`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetWorkerPool |
Returns details of a `WorkerPool`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteWorkerPool |
Deletes a `WorkerPool`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateWorkerPool |
Updates a `WorkerPool`. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListWorkerPools |
Lists `WorkerPool`s. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of CloudBuildSettings 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
CloudBuildSettings cloudBuildSettings =
CloudBuildSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudBuildClient cloudBuildClient = CloudBuildClient.create(cloudBuildSettings);
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
CloudBuildSettings cloudBuildSettings =
CloudBuildSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudBuildClient cloudBuildClient = CloudBuildClient.create(cloudBuildSettings);
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
CloudBuildSettings cloudBuildSettings = CloudBuildSettings.newHttpJsonBuilder().build();
CloudBuildClient cloudBuildClient = CloudBuildClient.create(cloudBuildSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
CloudBuildClient.ListBuildsFixedSizeCollection |
static class |
CloudBuildClient.ListBuildsPage |
static class |
CloudBuildClient.ListBuildsPagedResponse |
static class |
CloudBuildClient.ListBuildTriggersFixedSizeCollection |
static class |
CloudBuildClient.ListBuildTriggersPage |
static class |
CloudBuildClient.ListBuildTriggersPagedResponse |
static class |
CloudBuildClient.ListWorkerPoolsFixedSizeCollection |
static class |
CloudBuildClient.ListWorkerPoolsPage |
static class |
CloudBuildClient.ListWorkerPoolsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
CloudBuildClient(CloudBuildSettings settings)
Constructs an instance of CloudBuildClient, using the given settings.
|
protected |
CloudBuildClient(CloudBuildStub stub) |
| Modifier and Type | Method and Description |
|---|---|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
approveBuildAsync(ApproveBuildRequest request)
Approves or rejects a pending build.
|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
approveBuildAsync(String name,
ApprovalResult approvalResult)
Approves or rejects a pending build.
|
com.google.api.gax.rpc.UnaryCallable<ApproveBuildRequest,com.google.longrunning.Operation> |
approveBuildCallable()
Approves or rejects a pending build.
|
com.google.api.gax.rpc.OperationCallable<ApproveBuildRequest,Build,BuildOperationMetadata> |
approveBuildOperationCallable()
Approves or rejects a pending build.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
Build |
cancelBuild(CancelBuildRequest request)
Cancels a build in progress.
|
Build |
cancelBuild(String projectId,
String id)
Cancels a build in progress.
|
com.google.api.gax.rpc.UnaryCallable<CancelBuildRequest,Build> |
cancelBuildCallable()
Cancels a build in progress.
|
void |
close() |
static CloudBuildClient |
create()
Constructs an instance of CloudBuildClient with default settings.
|
static CloudBuildClient |
create(CloudBuildSettings settings)
Constructs an instance of CloudBuildClient, using the given settings.
|
static CloudBuildClient |
create(CloudBuildStub stub)
Constructs an instance of CloudBuildClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
createBuildAsync(CreateBuildRequest request)
Starts a build with the specified configuration.
|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
createBuildAsync(String projectId,
Build build)
Starts a build with the specified configuration.
|
com.google.api.gax.rpc.UnaryCallable<CreateBuildRequest,com.google.longrunning.Operation> |
createBuildCallable()
Starts a build with the specified configuration.
|
com.google.api.gax.rpc.OperationCallable<CreateBuildRequest,Build,BuildOperationMetadata> |
createBuildOperationCallable()
Starts a build with the specified configuration.
|
BuildTrigger |
createBuildTrigger(CreateBuildTriggerRequest request)
Creates a new `BuildTrigger`.
|
BuildTrigger |
createBuildTrigger(String projectId,
BuildTrigger trigger)
Creates a new `BuildTrigger`.
|
com.google.api.gax.rpc.UnaryCallable<CreateBuildTriggerRequest,BuildTrigger> |
createBuildTriggerCallable()
Creates a new `BuildTrigger`.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> |
createWorkerPoolAsync(CreateWorkerPoolRequest request)
Creates a `WorkerPool`.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> |
createWorkerPoolAsync(LocationName parent,
WorkerPool workerPool,
String workerPoolId)
Creates a `WorkerPool`.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> |
createWorkerPoolAsync(String parent,
WorkerPool workerPool,
String workerPoolId)
Creates a `WorkerPool`.
|
com.google.api.gax.rpc.UnaryCallable<CreateWorkerPoolRequest,com.google.longrunning.Operation> |
createWorkerPoolCallable()
Creates a `WorkerPool`.
|
com.google.api.gax.rpc.OperationCallable<CreateWorkerPoolRequest,WorkerPool,CreateWorkerPoolOperationMetadata> |
createWorkerPoolOperationCallable()
Creates a `WorkerPool`.
|
void |
deleteBuildTrigger(DeleteBuildTriggerRequest request)
Deletes a `BuildTrigger` by its project ID and trigger ID.
|
void |
deleteBuildTrigger(String projectId,
String triggerId)
Deletes a `BuildTrigger` by its project ID and trigger ID.
|
com.google.api.gax.rpc.UnaryCallable<DeleteBuildTriggerRequest,com.google.protobuf.Empty> |
deleteBuildTriggerCallable()
Deletes a `BuildTrigger` by its project ID and trigger ID.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> |
deleteWorkerPoolAsync(DeleteWorkerPoolRequest request)
Deletes a `WorkerPool`.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> |
deleteWorkerPoolAsync(String name)
Deletes a `WorkerPool`.
|
com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> |
deleteWorkerPoolAsync(WorkerPoolName name)
Deletes a `WorkerPool`.
|
com.google.api.gax.rpc.UnaryCallable<DeleteWorkerPoolRequest,com.google.longrunning.Operation> |
deleteWorkerPoolCallable()
Deletes a `WorkerPool`.
|
com.google.api.gax.rpc.OperationCallable<DeleteWorkerPoolRequest,com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> |
deleteWorkerPoolOperationCallable()
Deletes a `WorkerPool`.
|
Build |
getBuild(GetBuildRequest request)
Returns information about a previously requested build.
|
Build |
getBuild(String projectId,
String id)
Returns information about a previously requested build.
|
com.google.api.gax.rpc.UnaryCallable<GetBuildRequest,Build> |
getBuildCallable()
Returns information about a previously requested build.
|
BuildTrigger |
getBuildTrigger(GetBuildTriggerRequest request)
Returns information about a `BuildTrigger`.
|
BuildTrigger |
getBuildTrigger(String projectId,
String triggerId)
Returns information about a `BuildTrigger`.
|
com.google.api.gax.rpc.UnaryCallable<GetBuildTriggerRequest,BuildTrigger> |
getBuildTriggerCallable()
Returns information about a `BuildTrigger`.
|
com.google.api.gax.httpjson.longrunning.OperationsClient |
getHttpJsonOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
CloudBuildSettings |
getSettings() |
CloudBuildStub |
getStub() |
WorkerPool |
getWorkerPool(GetWorkerPoolRequest request)
Returns details of a `WorkerPool`.
|
WorkerPool |
getWorkerPool(String name)
Returns details of a `WorkerPool`.
|
WorkerPool |
getWorkerPool(WorkerPoolName name)
Returns details of a `WorkerPool`.
|
com.google.api.gax.rpc.UnaryCallable<GetWorkerPoolRequest,WorkerPool> |
getWorkerPoolCallable()
Returns details of a `WorkerPool`.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
CloudBuildClient.ListBuildsPagedResponse |
listBuilds(ListBuildsRequest request)
Lists previously requested builds.
|
CloudBuildClient.ListBuildsPagedResponse |
listBuilds(String projectId,
String filter)
Lists previously requested builds.
|
com.google.api.gax.rpc.UnaryCallable<ListBuildsRequest,ListBuildsResponse> |
listBuildsCallable()
Lists previously requested builds.
|
com.google.api.gax.rpc.UnaryCallable<ListBuildsRequest,CloudBuildClient.ListBuildsPagedResponse> |
listBuildsPagedCallable()
Lists previously requested builds.
|
CloudBuildClient.ListBuildTriggersPagedResponse |
listBuildTriggers(ListBuildTriggersRequest request)
Lists existing `BuildTrigger`s.
|
CloudBuildClient.ListBuildTriggersPagedResponse |
listBuildTriggers(String projectId)
Lists existing `BuildTrigger`s.
|
com.google.api.gax.rpc.UnaryCallable<ListBuildTriggersRequest,ListBuildTriggersResponse> |
listBuildTriggersCallable()
Lists existing `BuildTrigger`s.
|
com.google.api.gax.rpc.UnaryCallable<ListBuildTriggersRequest,CloudBuildClient.ListBuildTriggersPagedResponse> |
listBuildTriggersPagedCallable()
Lists existing `BuildTrigger`s.
|
CloudBuildClient.ListWorkerPoolsPagedResponse |
listWorkerPools(ListWorkerPoolsRequest request)
Lists `WorkerPool`s.
|
CloudBuildClient.ListWorkerPoolsPagedResponse |
listWorkerPools(LocationName parent)
Lists `WorkerPool`s.
|
CloudBuildClient.ListWorkerPoolsPagedResponse |
listWorkerPools(String parent)
Lists `WorkerPool`s.
|
com.google.api.gax.rpc.UnaryCallable<ListWorkerPoolsRequest,ListWorkerPoolsResponse> |
listWorkerPoolsCallable()
Lists `WorkerPool`s.
|
com.google.api.gax.rpc.UnaryCallable<ListWorkerPoolsRequest,CloudBuildClient.ListWorkerPoolsPagedResponse> |
listWorkerPoolsPagedCallable()
Lists `WorkerPool`s.
|
ReceiveTriggerWebhookResponse |
receiveTriggerWebhook(ReceiveTriggerWebhookRequest request)
ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted
at a specific trigger.
|
com.google.api.gax.rpc.UnaryCallable<ReceiveTriggerWebhookRequest,ReceiveTriggerWebhookResponse> |
receiveTriggerWebhookCallable()
ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted
at a specific trigger.
|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
retryBuildAsync(RetryBuildRequest request)
Creates a new build based on the specified build.
|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
retryBuildAsync(String projectId,
String id)
Creates a new build based on the specified build.
|
com.google.api.gax.rpc.UnaryCallable<RetryBuildRequest,com.google.longrunning.Operation> |
retryBuildCallable()
Creates a new build based on the specified build.
|
com.google.api.gax.rpc.OperationCallable<RetryBuildRequest,Build,BuildOperationMetadata> |
retryBuildOperationCallable()
Creates a new build based on the specified build.
|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
runBuildTriggerAsync(RunBuildTriggerRequest request)
Runs a `BuildTrigger` at a particular source revision.
|
com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> |
runBuildTriggerAsync(String projectId,
String triggerId,
RepoSource source)
Runs a `BuildTrigger` at a particular source revision.
|
com.google.api.gax.rpc.UnaryCallable<RunBuildTriggerRequest,com.google.longrunning.Operation> |
runBuildTriggerCallable()
Runs a `BuildTrigger` at a particular source revision.
|
com.google.api.gax.rpc.OperationCallable<RunBuildTriggerRequest,Build,BuildOperationMetadata> |
runBuildTriggerOperationCallable()
Runs a `BuildTrigger` at a particular source revision.
|
void |
shutdown() |
void |
shutdownNow() |
BuildTrigger |
updateBuildTrigger(String projectId,
String triggerId,
BuildTrigger trigger)
Updates a `BuildTrigger` by its project ID and trigger ID.
|
BuildTrigger |
updateBuildTrigger(UpdateBuildTriggerRequest request)
Updates a `BuildTrigger` by its project ID and trigger ID.
|
com.google.api.gax.rpc.UnaryCallable<UpdateBuildTriggerRequest,BuildTrigger> |
updateBuildTriggerCallable()
Updates a `BuildTrigger` by its project ID and trigger ID.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,UpdateWorkerPoolOperationMetadata> |
updateWorkerPoolAsync(UpdateWorkerPoolRequest request)
Updates a `WorkerPool`.
|
com.google.api.gax.longrunning.OperationFuture<WorkerPool,UpdateWorkerPoolOperationMetadata> |
updateWorkerPoolAsync(WorkerPool workerPool,
com.google.protobuf.FieldMask updateMask)
Updates a `WorkerPool`.
|
com.google.api.gax.rpc.UnaryCallable<UpdateWorkerPoolRequest,com.google.longrunning.Operation> |
updateWorkerPoolCallable()
Updates a `WorkerPool`.
|
com.google.api.gax.rpc.OperationCallable<UpdateWorkerPoolRequest,WorkerPool,UpdateWorkerPoolOperationMetadata> |
updateWorkerPoolOperationCallable()
Updates a `WorkerPool`.
|
protected CloudBuildClient(CloudBuildSettings settings) throws IOException
IOExceptionprotected CloudBuildClient(CloudBuildStub stub)
public static final CloudBuildClient create() throws IOException
IOExceptionpublic static final CloudBuildClient create(CloudBuildSettings settings) throws IOException
IOExceptionpublic static final CloudBuildClient create(CloudBuildStub stub)
public final CloudBuildSettings getSettings()
public CloudBuildStub getStub()
public final com.google.longrunning.OperationsClient getOperationsClient()
@BetaApi public final com.google.api.gax.httpjson.longrunning.OperationsClient getHttpJsonOperationsClient()
public final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> createBuildAsync(String projectId, Build build)
This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
Build build = Build.newBuilder().build();
Build response = cloudBuildClient.createBuildAsync(projectId, build).get();
}
projectId - Required. ID of the project.build - Required. Build resource to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> createBuildAsync(CreateBuildRequest request)
This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateBuildRequest request =
CreateBuildRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setBuild(Build.newBuilder().build())
.build();
Build response = cloudBuildClient.createBuildAsync(request).get();
}
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.OperationCallable<CreateBuildRequest,Build,BuildOperationMetadata> createBuildOperationCallable()
This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateBuildRequest request =
CreateBuildRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setBuild(Build.newBuilder().build())
.build();
OperationFuture<Build, BuildOperationMetadata> future =
cloudBuildClient.createBuildOperationCallable().futureCall(request);
// Do something.
Build response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<CreateBuildRequest,com.google.longrunning.Operation> createBuildCallable()
This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateBuildRequest request =
CreateBuildRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setBuild(Build.newBuilder().build())
.build();
ApiFuture<Operation> future = cloudBuildClient.createBuildCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final Build getBuild(String projectId, String id)
The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String id = "id3355";
Build response = cloudBuildClient.getBuild(projectId, id);
}
projectId - Required. ID of the project.id - Required. ID of the build.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Build getBuild(GetBuildRequest request)
The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
GetBuildRequest request =
GetBuildRequest.newBuilder()
.setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString())
.setProjectId("projectId-894832108")
.setId("id3355")
.build();
Build response = cloudBuildClient.getBuild(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<GetBuildRequest,Build> getBuildCallable()
The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
GetBuildRequest request =
GetBuildRequest.newBuilder()
.setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString())
.setProjectId("projectId-894832108")
.setId("id3355")
.build();
ApiFuture<Build> future = cloudBuildClient.getBuildCallable().futureCall(request);
// Do something.
Build response = future.get();
}
public final CloudBuildClient.ListBuildsPagedResponse listBuilds(String projectId, String filter)
Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String filter = "filter-1274492040";
for (Build element : cloudBuildClient.listBuilds(projectId, filter).iterateAll()) {
// doThingsWith(element);
}
}
projectId - Required. ID of the project.filter - The raw filter text to constrain the results.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudBuildClient.ListBuildsPagedResponse listBuilds(ListBuildsRequest request)
Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListBuildsRequest request =
ListBuildsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
for (Build element : cloudBuildClient.listBuilds(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<ListBuildsRequest,CloudBuildClient.ListBuildsPagedResponse> listBuildsPagedCallable()
Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListBuildsRequest request =
ListBuildsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
ApiFuture<Build> future = cloudBuildClient.listBuildsPagedCallable().futureCall(request);
// Do something.
for (Build element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListBuildsRequest,ListBuildsResponse> listBuildsCallable()
Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListBuildsRequest request =
ListBuildsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
while (true) {
ListBuildsResponse response = cloudBuildClient.listBuildsCallable().call(request);
for (Build element : response.getBuildsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Build cancelBuild(String projectId, String id)
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String id = "id3355";
Build response = cloudBuildClient.cancelBuild(projectId, id);
}
projectId - Required. ID of the project.id - Required. ID of the build.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Build cancelBuild(CancelBuildRequest 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CancelBuildRequest request =
CancelBuildRequest.newBuilder()
.setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString())
.setProjectId("projectId-894832108")
.setId("id3355")
.build();
Build response = cloudBuildClient.cancelBuild(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<CancelBuildRequest,Build> cancelBuildCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CancelBuildRequest request =
CancelBuildRequest.newBuilder()
.setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString())
.setProjectId("projectId-894832108")
.setId("id3355")
.build();
ApiFuture<Build> future = cloudBuildClient.cancelBuildCallable().futureCall(request);
// Do something.
Build response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> retryBuildAsync(String projectId, String id)
This method creates a new build using the original build request, which may or may not result in an identical build.
For triggered builds:
For non-triggered builds that specify `RepoSource`:
For builds that specify `StorageSource`:
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String id = "id3355";
Build response = cloudBuildClient.retryBuildAsync(projectId, id).get();
}
projectId - Required. ID of the project.id - Required. Build ID of the original build.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> retryBuildAsync(RetryBuildRequest request)
This method creates a new build using the original build request, which may or may not result in an identical build.
For triggered builds:
For non-triggered builds that specify `RepoSource`:
For builds that specify `StorageSource`:
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
RetryBuildRequest request =
RetryBuildRequest.newBuilder()
.setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString())
.setProjectId("projectId-894832108")
.setId("id3355")
.build();
Build response = cloudBuildClient.retryBuildAsync(request).get();
}
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.OperationCallable<RetryBuildRequest,Build,BuildOperationMetadata> retryBuildOperationCallable()
This method creates a new build using the original build request, which may or may not result in an identical build.
For triggered builds:
For non-triggered builds that specify `RepoSource`:
For builds that specify `StorageSource`:
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
RetryBuildRequest request =
RetryBuildRequest.newBuilder()
.setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString())
.setProjectId("projectId-894832108")
.setId("id3355")
.build();
OperationFuture<Build, BuildOperationMetadata> future =
cloudBuildClient.retryBuildOperationCallable().futureCall(request);
// Do something.
Build response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<RetryBuildRequest,com.google.longrunning.Operation> retryBuildCallable()
This method creates a new build using the original build request, which may or may not result in an identical build.
For triggered builds:
For non-triggered builds that specify `RepoSource`:
For builds that specify `StorageSource`:
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
RetryBuildRequest request =
RetryBuildRequest.newBuilder()
.setName(BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]").toString())
.setProjectId("projectId-894832108")
.setId("id3355")
.build();
ApiFuture<Operation> future = cloudBuildClient.retryBuildCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> approveBuildAsync(String name, ApprovalResult approvalResult)
If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call.
If rejected, the returned LRO will be immediately done.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String name = "name3373707";
ApprovalResult approvalResult = ApprovalResult.newBuilder().build();
Build response = cloudBuildClient.approveBuildAsync(name, approvalResult).get();
}
name - Required. Name of the target build. For example:
"projects/{$project_id}/builds/{$build_id}"approvalResult - Approval decision and metadata.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> approveBuildAsync(ApproveBuildRequest request)
If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call.
If rejected, the returned LRO will be immediately done.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ApproveBuildRequest request =
ApproveBuildRequest.newBuilder()
.setName("name3373707")
.setApprovalResult(ApprovalResult.newBuilder().build())
.build();
Build response = cloudBuildClient.approveBuildAsync(request).get();
}
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.OperationCallable<ApproveBuildRequest,Build,BuildOperationMetadata> approveBuildOperationCallable()
If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call.
If rejected, the returned LRO will be immediately done.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ApproveBuildRequest request =
ApproveBuildRequest.newBuilder()
.setName("name3373707")
.setApprovalResult(ApprovalResult.newBuilder().build())
.build();
OperationFuture<Build, BuildOperationMetadata> future =
cloudBuildClient.approveBuildOperationCallable().futureCall(request);
// Do something.
Build response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ApproveBuildRequest,com.google.longrunning.Operation> approveBuildCallable()
If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call.
If rejected, the returned LRO will be immediately done.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ApproveBuildRequest request =
ApproveBuildRequest.newBuilder()
.setName("name3373707")
.setApprovalResult(ApprovalResult.newBuilder().build())
.build();
ApiFuture<Operation> future = cloudBuildClient.approveBuildCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final BuildTrigger createBuildTrigger(String projectId, BuildTrigger trigger)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
BuildTrigger trigger = BuildTrigger.newBuilder().build();
BuildTrigger response = cloudBuildClient.createBuildTrigger(projectId, trigger);
}
projectId - Required. ID of the project for which to configure automatic builds.trigger - Required. `BuildTrigger` to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final BuildTrigger createBuildTrigger(CreateBuildTriggerRequest request)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateBuildTriggerRequest request =
CreateBuildTriggerRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setTrigger(BuildTrigger.newBuilder().build())
.build();
BuildTrigger response = cloudBuildClient.createBuildTrigger(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<CreateBuildTriggerRequest,BuildTrigger> createBuildTriggerCallable()
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateBuildTriggerRequest request =
CreateBuildTriggerRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setTrigger(BuildTrigger.newBuilder().build())
.build();
ApiFuture<BuildTrigger> future =
cloudBuildClient.createBuildTriggerCallable().futureCall(request);
// Do something.
BuildTrigger response = future.get();
}
public final BuildTrigger getBuildTrigger(String projectId, String triggerId)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String triggerId = "triggerId-648752909";
BuildTrigger response = cloudBuildClient.getBuildTrigger(projectId, triggerId);
}
projectId - Required. ID of the project that owns the trigger.triggerId - Required. Identifier (`id` or `name`) of the `BuildTrigger` to get.com.google.api.gax.rpc.ApiException - if the remote call failspublic final BuildTrigger getBuildTrigger(GetBuildTriggerRequest request)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
GetBuildTriggerRequest request =
GetBuildTriggerRequest.newBuilder()
.setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString())
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.build();
BuildTrigger response = cloudBuildClient.getBuildTrigger(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<GetBuildTriggerRequest,BuildTrigger> getBuildTriggerCallable()
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
GetBuildTriggerRequest request =
GetBuildTriggerRequest.newBuilder()
.setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString())
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.build();
ApiFuture<BuildTrigger> future =
cloudBuildClient.getBuildTriggerCallable().futureCall(request);
// Do something.
BuildTrigger response = future.get();
}
public final CloudBuildClient.ListBuildTriggersPagedResponse listBuildTriggers(String projectId)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
for (BuildTrigger element : cloudBuildClient.listBuildTriggers(projectId).iterateAll()) {
// doThingsWith(element);
}
}
projectId - Required. ID of the project for which to list BuildTriggers.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudBuildClient.ListBuildTriggersPagedResponse listBuildTriggers(ListBuildTriggersRequest request)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListBuildTriggersRequest request =
ListBuildTriggersRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (BuildTrigger element : cloudBuildClient.listBuildTriggers(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<ListBuildTriggersRequest,CloudBuildClient.ListBuildTriggersPagedResponse> listBuildTriggersPagedCallable()
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListBuildTriggersRequest request =
ListBuildTriggersRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<BuildTrigger> future =
cloudBuildClient.listBuildTriggersPagedCallable().futureCall(request);
// Do something.
for (BuildTrigger element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListBuildTriggersRequest,ListBuildTriggersResponse> listBuildTriggersCallable()
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListBuildTriggersRequest request =
ListBuildTriggersRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setProjectId("projectId-894832108")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListBuildTriggersResponse response =
cloudBuildClient.listBuildTriggersCallable().call(request);
for (BuildTrigger element : response.getTriggersList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void deleteBuildTrigger(String projectId, String triggerId)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String triggerId = "triggerId-648752909";
cloudBuildClient.deleteBuildTrigger(projectId, triggerId);
}
projectId - Required. ID of the project that owns the trigger.triggerId - Required. ID of the `BuildTrigger` to delete.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteBuildTrigger(DeleteBuildTriggerRequest request)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
DeleteBuildTriggerRequest request =
DeleteBuildTriggerRequest.newBuilder()
.setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString())
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.build();
cloudBuildClient.deleteBuildTrigger(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<DeleteBuildTriggerRequest,com.google.protobuf.Empty> deleteBuildTriggerCallable()
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
DeleteBuildTriggerRequest request =
DeleteBuildTriggerRequest.newBuilder()
.setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString())
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.build();
ApiFuture<Empty> future = cloudBuildClient.deleteBuildTriggerCallable().futureCall(request);
// Do something.
future.get();
}
public final BuildTrigger updateBuildTrigger(String projectId, String triggerId, BuildTrigger trigger)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String triggerId = "triggerId-648752909";
BuildTrigger trigger = BuildTrigger.newBuilder().build();
BuildTrigger response = cloudBuildClient.updateBuildTrigger(projectId, triggerId, trigger);
}
projectId - Required. ID of the project that owns the trigger.triggerId - Required. ID of the `BuildTrigger` to update.trigger - Required. `BuildTrigger` to update.com.google.api.gax.rpc.ApiException - if the remote call failspublic final BuildTrigger updateBuildTrigger(UpdateBuildTriggerRequest request)
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
UpdateBuildTriggerRequest request =
UpdateBuildTriggerRequest.newBuilder()
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.setTrigger(BuildTrigger.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
BuildTrigger response = cloudBuildClient.updateBuildTrigger(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<UpdateBuildTriggerRequest,BuildTrigger> updateBuildTriggerCallable()
This API is experimental.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
UpdateBuildTriggerRequest request =
UpdateBuildTriggerRequest.newBuilder()
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.setTrigger(BuildTrigger.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<BuildTrigger> future =
cloudBuildClient.updateBuildTriggerCallable().futureCall(request);
// Do something.
BuildTrigger response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> runBuildTriggerAsync(String projectId, String triggerId, RepoSource source)
To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String projectId = "projectId-894832108";
String triggerId = "triggerId-648752909";
RepoSource source = RepoSource.newBuilder().build();
Build response = cloudBuildClient.runBuildTriggerAsync(projectId, triggerId, source).get();
}
projectId - Required. ID of the project.triggerId - Required. ID of the trigger.source - Source to build against this trigger. Branch and tag names cannot consist of
regular expressions.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Build,BuildOperationMetadata> runBuildTriggerAsync(RunBuildTriggerRequest request)
To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
RunBuildTriggerRequest request =
RunBuildTriggerRequest.newBuilder()
.setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString())
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.setSource(RepoSource.newBuilder().build())
.build();
Build response = cloudBuildClient.runBuildTriggerAsync(request).get();
}
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.OperationCallable<RunBuildTriggerRequest,Build,BuildOperationMetadata> runBuildTriggerOperationCallable()
To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
RunBuildTriggerRequest request =
RunBuildTriggerRequest.newBuilder()
.setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString())
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.setSource(RepoSource.newBuilder().build())
.build();
OperationFuture<Build, BuildOperationMetadata> future =
cloudBuildClient.runBuildTriggerOperationCallable().futureCall(request);
// Do something.
Build response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<RunBuildTriggerRequest,com.google.longrunning.Operation> runBuildTriggerCallable()
To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
RunBuildTriggerRequest request =
RunBuildTriggerRequest.newBuilder()
.setName(BuildTriggerName.ofProjectTriggerName("[PROJECT]", "[TRIGGER]").toString())
.setProjectId("projectId-894832108")
.setTriggerId("triggerId-648752909")
.setSource(RepoSource.newBuilder().build())
.build();
ApiFuture<Operation> future = cloudBuildClient.runBuildTriggerCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final ReceiveTriggerWebhookResponse receiveTriggerWebhook(ReceiveTriggerWebhookRequest 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ReceiveTriggerWebhookRequest request =
ReceiveTriggerWebhookRequest.newBuilder()
.setName("name3373707")
.setBody(HttpBody.newBuilder().build())
.setProjectId("projectId-894832108")
.setTrigger("trigger-1059891784")
.setSecret("secret-906277200")
.build();
ReceiveTriggerWebhookResponse response = cloudBuildClient.receiveTriggerWebhook(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<ReceiveTriggerWebhookRequest,ReceiveTriggerWebhookResponse> receiveTriggerWebhookCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ReceiveTriggerWebhookRequest request =
ReceiveTriggerWebhookRequest.newBuilder()
.setName("name3373707")
.setBody(HttpBody.newBuilder().build())
.setProjectId("projectId-894832108")
.setTrigger("trigger-1059891784")
.setSecret("secret-906277200")
.build();
ApiFuture<ReceiveTriggerWebhookResponse> future =
cloudBuildClient.receiveTriggerWebhookCallable().futureCall(request);
// Do something.
ReceiveTriggerWebhookResponse response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolAsync(LocationName parent, WorkerPool workerPool, String workerPoolId)
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
WorkerPool workerPool = WorkerPool.newBuilder().build();
String workerPoolId = "workerPoolId-46320779";
WorkerPool response =
cloudBuildClient.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
}
parent - Required. The parent resource where this worker pool will be created. Format:
`projects/{project}/locations/{location}`.workerPool - Required. `WorkerPool` resource to create.workerPoolId - Required. Immutable. The ID to use for the `WorkerPool`, which will become
the final component of the resource name.
This value should be 1-63 characters, and valid characters are /[a-z][0-9]-/.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolAsync(String parent, WorkerPool workerPool, String workerPoolId)
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
WorkerPool workerPool = WorkerPool.newBuilder().build();
String workerPoolId = "workerPoolId-46320779";
WorkerPool response =
cloudBuildClient.createWorkerPoolAsync(parent, workerPool, workerPoolId).get();
}
parent - Required. The parent resource where this worker pool will be created. Format:
`projects/{project}/locations/{location}`.workerPool - Required. `WorkerPool` resource to create.workerPoolId - Required. Immutable. The ID to use for the `WorkerPool`, which will become
the final component of the resource name.
This value should be 1-63 characters, and valid characters are /[a-z][0-9]-/.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolAsync(CreateWorkerPoolRequest 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateWorkerPoolRequest request =
CreateWorkerPoolRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setWorkerPool(WorkerPool.newBuilder().build())
.setWorkerPoolId("workerPoolId-46320779")
.setValidateOnly(true)
.build();
WorkerPool response = cloudBuildClient.createWorkerPoolAsync(request).get();
}
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.OperationCallable<CreateWorkerPoolRequest,WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolOperationCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateWorkerPoolRequest request =
CreateWorkerPoolRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setWorkerPool(WorkerPool.newBuilder().build())
.setWorkerPoolId("workerPoolId-46320779")
.setValidateOnly(true)
.build();
OperationFuture<WorkerPool, CreateWorkerPoolOperationMetadata> future =
cloudBuildClient.createWorkerPoolOperationCallable().futureCall(request);
// Do something.
WorkerPool response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<CreateWorkerPoolRequest,com.google.longrunning.Operation> createWorkerPoolCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
CreateWorkerPoolRequest request =
CreateWorkerPoolRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setWorkerPool(WorkerPool.newBuilder().build())
.setWorkerPoolId("workerPoolId-46320779")
.setValidateOnly(true)
.build();
ApiFuture<Operation> future = cloudBuildClient.createWorkerPoolCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final WorkerPool getWorkerPool(WorkerPoolName 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
WorkerPool response = cloudBuildClient.getWorkerPool(name);
}
name - Required. The name of the `WorkerPool` to retrieve. Format:
`projects/{project}/locations/{location}/workerPools/{workerPool}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WorkerPool getWorkerPool(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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString();
WorkerPool response = cloudBuildClient.getWorkerPool(name);
}
name - Required. The name of the `WorkerPool` to retrieve. Format:
`projects/{project}/locations/{location}/workerPools/{workerPool}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WorkerPool getWorkerPool(GetWorkerPoolRequest 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
GetWorkerPoolRequest request =
GetWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.build();
WorkerPool response = cloudBuildClient.getWorkerPool(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<GetWorkerPoolRequest,WorkerPool> getWorkerPoolCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
GetWorkerPoolRequest request =
GetWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.build();
ApiFuture<WorkerPool> future = cloudBuildClient.getWorkerPoolCallable().futureCall(request);
// Do something.
WorkerPool response = future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync(WorkerPoolName 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
WorkerPoolName name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]");
cloudBuildClient.deleteWorkerPoolAsync(name).get();
}
name - Required. The name of the `WorkerPool` to delete. Format:
`projects/{project}/locations/{location}/workerPools/{workerPool}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync(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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String name = WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString();
cloudBuildClient.deleteWorkerPoolAsync(name).get();
}
name - Required. The name of the `WorkerPool` to delete. Format:
`projects/{project}/locations/{location}/workerPools/{workerPool}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync(DeleteWorkerPoolRequest 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
DeleteWorkerPoolRequest request =
DeleteWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setEtag("etag3123477")
.setAllowMissing(true)
.setValidateOnly(true)
.build();
cloudBuildClient.deleteWorkerPoolAsync(request).get();
}
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.OperationCallable<DeleteWorkerPoolRequest,com.google.protobuf.Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolOperationCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
DeleteWorkerPoolRequest request =
DeleteWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setEtag("etag3123477")
.setAllowMissing(true)
.setValidateOnly(true)
.build();
OperationFuture<Empty, DeleteWorkerPoolOperationMetadata> future =
cloudBuildClient.deleteWorkerPoolOperationCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteWorkerPoolRequest,com.google.longrunning.Operation> deleteWorkerPoolCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
DeleteWorkerPoolRequest request =
DeleteWorkerPoolRequest.newBuilder()
.setName(WorkerPoolName.of("[PROJECT]", "[LOCATION]", "[WORKER_POOL]").toString())
.setEtag("etag3123477")
.setAllowMissing(true)
.setValidateOnly(true)
.build();
ApiFuture<Operation> future = cloudBuildClient.deleteWorkerPoolCallable().futureCall(request);
// Do something.
future.get();
}
public final com.google.api.gax.longrunning.OperationFuture<WorkerPool,UpdateWorkerPoolOperationMetadata> updateWorkerPoolAsync(WorkerPool workerPool, 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
WorkerPool workerPool = WorkerPool.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
WorkerPool response = cloudBuildClient.updateWorkerPoolAsync(workerPool, updateMask).get();
}
workerPool - Required. The `WorkerPool` to update.
The `name` field is used to identify the `WorkerPool` to update. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
updateMask - A mask specifying which fields in `worker_pool` to update.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<WorkerPool,UpdateWorkerPoolOperationMetadata> updateWorkerPoolAsync(UpdateWorkerPoolRequest 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
UpdateWorkerPoolRequest request =
UpdateWorkerPoolRequest.newBuilder()
.setWorkerPool(WorkerPool.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setValidateOnly(true)
.build();
WorkerPool response = cloudBuildClient.updateWorkerPoolAsync(request).get();
}
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.OperationCallable<UpdateWorkerPoolRequest,WorkerPool,UpdateWorkerPoolOperationMetadata> updateWorkerPoolOperationCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
UpdateWorkerPoolRequest request =
UpdateWorkerPoolRequest.newBuilder()
.setWorkerPool(WorkerPool.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setValidateOnly(true)
.build();
OperationFuture<WorkerPool, UpdateWorkerPoolOperationMetadata> future =
cloudBuildClient.updateWorkerPoolOperationCallable().futureCall(request);
// Do something.
WorkerPool response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<UpdateWorkerPoolRequest,com.google.longrunning.Operation> updateWorkerPoolCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
UpdateWorkerPoolRequest request =
UpdateWorkerPoolRequest.newBuilder()
.setWorkerPool(WorkerPool.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setValidateOnly(true)
.build();
ApiFuture<Operation> future = cloudBuildClient.updateWorkerPoolCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final CloudBuildClient.ListWorkerPoolsPagedResponse listWorkerPools(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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (WorkerPool element : cloudBuildClient.listWorkerPools(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent of the collection of `WorkerPools`. Format:
`projects/{project}/locations/{location}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudBuildClient.ListWorkerPoolsPagedResponse listWorkerPools(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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (WorkerPool element : cloudBuildClient.listWorkerPools(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent of the collection of `WorkerPools`. Format:
`projects/{project}/locations/{location}`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final CloudBuildClient.ListWorkerPoolsPagedResponse listWorkerPools(ListWorkerPoolsRequest 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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListWorkerPoolsRequest request =
ListWorkerPoolsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (WorkerPool element : cloudBuildClient.listWorkerPools(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<ListWorkerPoolsRequest,CloudBuildClient.ListWorkerPoolsPagedResponse> listWorkerPoolsPagedCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListWorkerPoolsRequest request =
ListWorkerPoolsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<WorkerPool> future =
cloudBuildClient.listWorkerPoolsPagedCallable().futureCall(request);
// Do something.
for (WorkerPool element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListWorkerPoolsRequest,ListWorkerPoolsResponse> listWorkerPoolsCallable()
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 (CloudBuildClient cloudBuildClient = CloudBuildClient.create()) {
ListWorkerPoolsRequest request =
ListWorkerPoolsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListWorkerPoolsResponse response = cloudBuildClient.listWorkerPoolsCallable().call(request);
for (WorkerPool element : response.getWorkerPoolsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
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 © 2024 Google LLC. All rights reserved.