| GitHub Repository | Product Reference | REST Documentation | RPC Documentation |
Service Description: The Cloud Run Source Upload API allows you to upload source code to deploy Cloud Run resources.
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 (SourceUploadClient sourceUploadClient = SourceUploadClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
UploadSourceResponse response = sourceUploadClient.uploadSource(parent);
}
Note: close() needs to be called on the SourceUploadClient 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 |
|---|---|---|
UploadSource |
Uploads a source archive to a Google Cloud Storage bucket through Cloud Run. The uploaded source object should be used for Cloud Run resource deployments. User is responsible for managing the lifecycle of the uploaded object. If uploading through the Cloud Run API to Cloud Storage is not desired, you can use the IAM Deny Policy to deny the |
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 SourceUploadSettings 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
SourceUploadSettings sourceUploadSettings =
SourceUploadSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SourceUploadClient sourceUploadClient = SourceUploadClient.create(sourceUploadSettings);
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
SourceUploadSettings sourceUploadSettings =
SourceUploadSettings.newBuilder().setEndpoint(myEndpoint).build();
SourceUploadClient sourceUploadClient = SourceUploadClient.create(sourceUploadSettings);
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
SourceUploadSettings sourceUploadSettings = SourceUploadSettings.newHttpJsonBuilder().build();
SourceUploadClient sourceUploadClient = SourceUploadClient.create(sourceUploadSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final SourceUploadClient create()Constructs an instance of SourceUploadClient with default settings.
| Returns | |
|---|---|
| Type | Description |
SourceUploadClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SourceUploadSettings settings)
public static final SourceUploadClient create(SourceUploadSettings settings)Constructs an instance of SourceUploadClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
| Parameter | |
|---|---|
| Name | Description |
settings |
SourceUploadSettings |
| Returns | |
|---|---|
| Type | Description |
SourceUploadClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SourceUploadStub stub)
public static final SourceUploadClient create(SourceUploadStub stub)Constructs an instance of SourceUploadClient, using the given stub for making calls. This is for advanced usage - prefer using create(SourceUploadSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
SourceUploadStub |
| Returns | |
|---|---|
| Type | Description |
SourceUploadClient |
|
Constructors
SourceUploadClient(SourceUploadSettings settings)
protected SourceUploadClient(SourceUploadSettings settings)Constructs an instance of SourceUploadClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
| Parameter | |
|---|---|
| Name | Description |
settings |
SourceUploadSettings |
SourceUploadClient(SourceUploadStub stub)
protected SourceUploadClient(SourceUploadStub stub)| Parameter | |
|---|---|
| Name | Description |
stub |
SourceUploadStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)| Parameters | |
|---|---|
| Name | Description |
duration |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
InterruptedException |
|
close()
public final void close()getSettings()
public final @Nullable SourceUploadSettings getSettings()| Returns | |
|---|---|
| Type | Description |
@org.jspecify.annotations.Nullable com.google.cloud.run.v2.SourceUploadSettings |
|
getStub()
public SourceUploadStub getStub()| Returns | |
|---|---|
| Type | Description |
SourceUploadStub |
|
isShutdown()
public boolean isShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
public boolean isTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
shutdown()
public void shutdown()shutdownNow()
public void shutdownNow()uploadSource(@Nullable LocationName parent)
public final UploadSourceResponse uploadSource(@Nullable LocationName parent)Uploads a source archive to a Google Cloud Storage bucket through Cloud Run. The uploaded
source object should be used for Cloud Run resource deployments. User is responsible for
managing the lifecycle of the uploaded object. If uploading through the Cloud Run API to Cloud
Storage is not desired, you can use the IAM Deny Policy to deny the
run.locations.uploadSource permission for all principals.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SourceUploadClient sourceUploadClient = SourceUploadClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
UploadSourceResponse response = sourceUploadClient.uploadSource(parent);
}
| Parameter | |
|---|---|
| Name | Description |
parent |
@org.jspecify.annotations.Nullable com.google.cloud.run.v2.LocationNameRequired. The project and location in which the source archive should be uploaded
to, specified in the format |
| Returns | |
|---|---|
| Type | Description |
UploadSourceResponse |
|
uploadSource(UploadSourceRequest request)
public final UploadSourceResponse uploadSource(UploadSourceRequest request)Uploads a source archive to a Google Cloud Storage bucket through Cloud Run. The uploaded
source object should be used for Cloud Run resource deployments. User is responsible for
managing the lifecycle of the uploaded object. If uploading through the Cloud Run API to Cloud
Storage is not desired, you can use the IAM Deny Policy to deny the
run.locations.uploadSource permission for all principals.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SourceUploadClient sourceUploadClient = SourceUploadClient.create()) {
UploadSourceRequest request =
UploadSourceRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.build();
UploadSourceResponse response = sourceUploadClient.uploadSource(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
UploadSourceRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
UploadSourceResponse |
|
uploadSource(String parent)
public final UploadSourceResponse uploadSource(String parent)Uploads a source archive to a Google Cloud Storage bucket through Cloud Run. The uploaded
source object should be used for Cloud Run resource deployments. User is responsible for
managing the lifecycle of the uploaded object. If uploading through the Cloud Run API to Cloud
Storage is not desired, you can use the IAM Deny Policy to deny the
run.locations.uploadSource permission for all principals.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SourceUploadClient sourceUploadClient = SourceUploadClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
UploadSourceResponse response = sourceUploadClient.uploadSource(parent);
}
| Parameter | |
|---|---|
| Name | Description |
parent |
StringRequired. The project and location in which the source archive should be uploaded
to, specified in the format |
| Returns | |
|---|---|
| Type | Description |
UploadSourceResponse |
|
uploadSourceCallable()
public final UnaryCallable<UploadSourceRequest,UploadSourceResponse> uploadSourceCallable()Uploads a source archive to a Google Cloud Storage bucket through Cloud Run. The uploaded
source object should be used for Cloud Run resource deployments. User is responsible for
managing the lifecycle of the uploaded object. If uploading through the Cloud Run API to Cloud
Storage is not desired, you can use the IAM Deny Policy to deny the
run.locations.uploadSource permission for all principals.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SourceUploadClient sourceUploadClient = SourceUploadClient.create()) {
UploadSourceRequest request =
UploadSourceRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.build();
ApiFuture<UploadSourceResponse> future =
sourceUploadClient.uploadSourceCallable().futureCall(request);
// Do something.
UploadSourceResponse response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<UploadSourceRequest,UploadSourceResponse> |
|