public class CloudBuildClient implements BackgroundResource
Service Description: Creates and manages builds on Google Cloud Platform.
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().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of 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.
Implements
BackgroundResourceStatic Methods
create()
public static final CloudBuildClient create()
Constructs an instance of CloudBuildClient with default settings.
Type | Description |
CloudBuildClient |
Type | Description |
IOException |
create(CloudBuildSettings settings)
public static final CloudBuildClient create(CloudBuildSettings settings)
Constructs an instance of CloudBuildClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | CloudBuildSettings |
Type | Description |
CloudBuildClient |
Type | Description |
IOException |
create(CloudBuildStub stub)
public static final CloudBuildClient create(CloudBuildStub stub)
Constructs an instance of CloudBuildClient, using the given stub for making calls. This is for advanced usage - prefer using create(CloudBuildSettings).
Name | Description |
stub | CloudBuildStub |
Type | Description |
CloudBuildClient |
Constructors
CloudBuildClient(CloudBuildSettings settings)
protected CloudBuildClient(CloudBuildSettings settings)
Constructs an instance of CloudBuildClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | CloudBuildSettings |
CloudBuildClient(CloudBuildStub stub)
protected CloudBuildClient(CloudBuildStub stub)
Name | Description |
stub | CloudBuildStub |
Methods
approveBuildAsync(ApproveBuildRequest request)
public final OperationFuture<Build,BuildOperationMetadata> approveBuildAsync(ApproveBuildRequest request)
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.
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();
}
Name | Description |
request | ApproveBuildRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Build,BuildOperationMetadata> |
approveBuildAsync(String name, ApprovalResult approvalResult)
public final OperationFuture<Build,BuildOperationMetadata> approveBuildAsync(String name, ApprovalResult approvalResult)
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.
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 | Description |
name | String Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}" |
approvalResult | ApprovalResult Approval decision and metadata. |
Type | Description |
OperationFuture<Build,BuildOperationMetadata> |
approveBuildCallable()
public final UnaryCallable<ApproveBuildRequest,Operation> approveBuildCallable()
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.
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();
}
Type | Description |
UnaryCallable<ApproveBuildRequest,Operation> |
approveBuildOperationCallable()
public final OperationCallable<ApproveBuildRequest,Build,BuildOperationMetadata> approveBuildOperationCallable()
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.
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();
}
Type | Description |
OperationCallable<ApproveBuildRequest,Build,BuildOperationMetadata> |
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
cancelBuild(CancelBuildRequest request)
public final Build cancelBuild(CancelBuildRequest request)
Cancels a build in progress.
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);
}
Name | Description |
request | CancelBuildRequest The request object containing all of the parameters for the API call. |
Type | Description |
Build |
cancelBuild(String projectId, String id)
public final Build cancelBuild(String projectId, String id)
Cancels a build in progress.
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);
}
Name | Description |
projectId | String Required. ID of the project. |
id | String Required. ID of the build. |
Type | Description |
Build |
cancelBuildCallable()
public final UnaryCallable<CancelBuildRequest,Build> cancelBuildCallable()
Cancels a build in progress.
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();
}
Type | Description |
UnaryCallable<CancelBuildRequest,Build> |
close()
public final void close()
createBuildAsync(CreateBuildRequest request)
public final OperationFuture<Build,BuildOperationMetadata> createBuildAsync(CreateBuildRequest request)
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
).
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();
}
Name | Description |
request | CreateBuildRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Build,BuildOperationMetadata> |
createBuildAsync(String projectId, Build build)
public final OperationFuture<Build,BuildOperationMetadata> createBuildAsync(String projectId, Build build)
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
).
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();
}
Name | Description |
projectId | String Required. ID of the project. |
build | Build Required. Build resource to create. |
Type | Description |
OperationFuture<Build,BuildOperationMetadata> |
createBuildCallable()
public final UnaryCallable<CreateBuildRequest,Operation> createBuildCallable()
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
).
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();
}
Type | Description |
UnaryCallable<CreateBuildRequest,Operation> |
createBuildOperationCallable()
public final OperationCallable<CreateBuildRequest,Build,BuildOperationMetadata> createBuildOperationCallable()
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
).
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();
}
Type | Description |
OperationCallable<CreateBuildRequest,Build,BuildOperationMetadata> |
createBuildTrigger(CreateBuildTriggerRequest request)
public final BuildTrigger createBuildTrigger(CreateBuildTriggerRequest request)
Creates a new BuildTrigger
.
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);
}
Name | Description |
request | CreateBuildTriggerRequest The request object containing all of the parameters for the API call. |
Type | Description |
BuildTrigger |
createBuildTrigger(String projectId, BuildTrigger trigger)
public final BuildTrigger createBuildTrigger(String projectId, BuildTrigger trigger)
Creates a new BuildTrigger
.
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);
}
Name | Description |
projectId | String Required. ID of the project for which to configure automatic builds. |
trigger | BuildTrigger Required. |
Type | Description |
BuildTrigger |
createBuildTriggerCallable()
public final UnaryCallable<CreateBuildTriggerRequest,BuildTrigger> createBuildTriggerCallable()
Creates a new BuildTrigger
.
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();
}
Type | Description |
UnaryCallable<CreateBuildTriggerRequest,BuildTrigger> |
createWorkerPoolAsync(CreateWorkerPoolRequest request)
public final OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolAsync(CreateWorkerPoolRequest request)
Creates a WorkerPool
.
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();
}
Name | Description |
request | CreateWorkerPoolRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> |
createWorkerPoolAsync(LocationName parent, WorkerPool workerPool, String workerPoolId)
public final OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolAsync(LocationName parent, WorkerPool workerPool, String workerPoolId)
Creates a WorkerPool
.
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();
}
Name | Description |
parent | LocationName Required. The parent resource where this worker pool will be created. Format:
|
workerPool | WorkerPool Required. |
workerPoolId | String Required. Immutable. The ID to use for the This value should be 1-63 characters, and valid characters are /a-z-/. |
Type | Description |
OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> |
createWorkerPoolAsync(String parent, WorkerPool workerPool, String workerPoolId)
public final OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolAsync(String parent, WorkerPool workerPool, String workerPoolId)
Creates a WorkerPool
.
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();
}
Name | Description |
parent | String Required. The parent resource where this worker pool will be created. Format:
|
workerPool | WorkerPool Required. |
workerPoolId | String Required. Immutable. The ID to use for the This value should be 1-63 characters, and valid characters are /a-z-/. |
Type | Description |
OperationFuture<WorkerPool,CreateWorkerPoolOperationMetadata> |
createWorkerPoolCallable()
public final UnaryCallable<CreateWorkerPoolRequest,Operation> createWorkerPoolCallable()
Creates a WorkerPool
.
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();
}
Type | Description |
UnaryCallable<CreateWorkerPoolRequest,Operation> |
createWorkerPoolOperationCallable()
public final OperationCallable<CreateWorkerPoolRequest,WorkerPool,CreateWorkerPoolOperationMetadata> createWorkerPoolOperationCallable()
Creates a WorkerPool
.
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();
}
Type | Description |
OperationCallable<CreateWorkerPoolRequest,WorkerPool,CreateWorkerPoolOperationMetadata> |
deleteBuildTrigger(DeleteBuildTriggerRequest request)
public final void deleteBuildTrigger(DeleteBuildTriggerRequest request)
Deletes a BuildTrigger
by its project ID and trigger ID.
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);
}
Name | Description |
request | DeleteBuildTriggerRequest The request object containing all of the parameters for the API call. |
deleteBuildTrigger(String projectId, String triggerId)
public final void deleteBuildTrigger(String projectId, String triggerId)
Deletes a BuildTrigger
by its project ID and trigger ID.
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);
}
Name | Description |
projectId | String Required. ID of the project that owns the trigger. |
triggerId | String Required. ID of the |
deleteBuildTriggerCallable()
public final UnaryCallable<DeleteBuildTriggerRequest,Empty> deleteBuildTriggerCallable()
Deletes a BuildTrigger
by its project ID and trigger ID.
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();
}
Type | Description |
UnaryCallable<DeleteBuildTriggerRequest,Empty> |
deleteWorkerPoolAsync(DeleteWorkerPoolRequest request)
public final OperationFuture<Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync(DeleteWorkerPoolRequest request)
Deletes a WorkerPool
.
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();
}
Name | Description |
request | DeleteWorkerPoolRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Empty,DeleteWorkerPoolOperationMetadata> |
deleteWorkerPoolAsync(WorkerPoolName name)
public final OperationFuture<Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync(WorkerPoolName name)
Deletes a WorkerPool
.
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 | Description |
name | WorkerPoolName Required. The name of the |
Type | Description |
OperationFuture<Empty,DeleteWorkerPoolOperationMetadata> |
deleteWorkerPoolAsync(String name)
public final OperationFuture<Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolAsync(String name)
Deletes a WorkerPool
.
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 | Description |
name | String Required. The name of the |
Type | Description |
OperationFuture<Empty,DeleteWorkerPoolOperationMetadata> |
deleteWorkerPoolCallable()
public final UnaryCallable<DeleteWorkerPoolRequest,Operation> deleteWorkerPoolCallable()
Deletes a WorkerPool
.
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();
}
Type | Description |
UnaryCallable<DeleteWorkerPoolRequest,Operation> |
deleteWorkerPoolOperationCallable()
public final OperationCallable<DeleteWorkerPoolRequest,Empty,DeleteWorkerPoolOperationMetadata> deleteWorkerPoolOperationCallable()
Deletes a WorkerPool
.
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();
}
Type | Description |
OperationCallable<DeleteWorkerPoolRequest,Empty,DeleteWorkerPoolOperationMetadata> |
getBuild(GetBuildRequest request)
public final Build getBuild(GetBuildRequest request)
Returns information about a previously requested build.
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);
}
Name | Description |
request | GetBuildRequest The request object containing all of the parameters for the API call. |
Type | Description |
Build |
getBuild(String projectId, String id)
public final Build getBuild(String projectId, String id)
Returns information about a previously requested build.
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);
}
Name | Description |
projectId | String Required. ID of the project. |
id | String Required. ID of the build. |
Type | Description |
Build |
getBuildCallable()
public final UnaryCallable<GetBuildRequest,Build> getBuildCallable()
Returns information about a previously requested build.
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();
}
Type | Description |
UnaryCallable<GetBuildRequest,Build> |
getBuildTrigger(GetBuildTriggerRequest request)
public final BuildTrigger getBuildTrigger(GetBuildTriggerRequest request)
Returns information about a BuildTrigger
.
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);
}
Name | Description |
request | GetBuildTriggerRequest The request object containing all of the parameters for the API call. |
Type | Description |
BuildTrigger |
getBuildTrigger(String projectId, String triggerId)
public final BuildTrigger getBuildTrigger(String projectId, String triggerId)
Returns information about a BuildTrigger
.
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);
}
Name | Description |
projectId | String Required. ID of the project that owns the trigger. |
triggerId | String Required. Identifier ( |
Type | Description |
BuildTrigger |
getBuildTriggerCallable()
public final UnaryCallable<GetBuildTriggerRequest,BuildTrigger> getBuildTriggerCallable()
Returns information about a BuildTrigger
.
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();
}
Type | Description |
UnaryCallable<GetBuildTriggerRequest,BuildTrigger> |
getHttpJsonOperationsClient()
public final OperationsClient getHttpJsonOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getSettings()
public final CloudBuildSettings getSettings()
Type | Description |
CloudBuildSettings |
getStub()
public CloudBuildStub getStub()
Type | Description |
CloudBuildStub |
getWorkerPool(GetWorkerPoolRequest request)
public final WorkerPool getWorkerPool(GetWorkerPoolRequest request)
Returns details of a WorkerPool
.
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);
}
Name | Description |
request | GetWorkerPoolRequest The request object containing all of the parameters for the API call. |
Type | Description |
WorkerPool |
getWorkerPool(WorkerPoolName name)
public final WorkerPool getWorkerPool(WorkerPoolName name)
Returns details of a WorkerPool
.
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 | Description |
name | WorkerPoolName Required. The name of the |
Type | Description |
WorkerPool |