Class EnvironmentsClient (1.8.0)

public class EnvironmentsClient implements BackgroundResource

Service Description: Managed Apache Airflow Environments.

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 (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   String name = "name3373707";
   Environment response = environmentsClient.getEnvironment(name);
 }
 

Note: close() needs to be called on the EnvironmentsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of EnvironmentsSettings 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
 EnvironmentsSettings environmentsSettings =
     EnvironmentsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
 

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
 EnvironmentsSettings environmentsSettings =
     EnvironmentsSettings.newBuilder().setEndpoint(myEndpoint).build();
 EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
 

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
 EnvironmentsSettings environmentsSettings = EnvironmentsSettings.newHttpJsonBuilder().build();
 EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
 

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

Inheritance

java.lang.Object > EnvironmentsClient

Implements

BackgroundResource

Static Methods

create()

public static final EnvironmentsClient create()

Constructs an instance of EnvironmentsClient with default settings.

Returns
Type Description
EnvironmentsClient
Exceptions
Type Description
IOException

create(EnvironmentsSettings settings)

public static final EnvironmentsClient create(EnvironmentsSettings settings)

Constructs an instance of EnvironmentsClient, 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 EnvironmentsSettings
Returns
Type Description
EnvironmentsClient
Exceptions
Type Description
IOException

create(EnvironmentsStub stub)

public static final EnvironmentsClient create(EnvironmentsStub stub)

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

Parameter
Name Description
stub EnvironmentsStub
Returns
Type Description
EnvironmentsClient

Constructors

EnvironmentsClient(EnvironmentsSettings settings)

protected EnvironmentsClient(EnvironmentsSettings settings)

Constructs an instance of EnvironmentsClient, 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 EnvironmentsSettings

EnvironmentsClient(EnvironmentsStub stub)

protected EnvironmentsClient(EnvironmentsStub stub)
Parameter
Name Description
stub EnvironmentsStub

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

checkUpgradeAsync(CheckUpgradeRequest request)

public final OperationFuture<CheckUpgradeResponse,OperationMetadata> checkUpgradeAsync(CheckUpgradeRequest request)

Check if an upgrade operation on the environment will succeed.

In case of problems detailed info can be found in the returned Operation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   CheckUpgradeRequest request =
       CheckUpgradeRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setImageVersion("imageVersion949870333")
           .build();
   CheckUpgradeResponse response = environmentsClient.checkUpgradeAsync(request).get();
 }
 
Parameter
Name Description
request CheckUpgradeRequest

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

Returns
Type Description
OperationFuture<CheckUpgradeResponse,OperationMetadata>

checkUpgradeCallable()

public final UnaryCallable<CheckUpgradeRequest,Operation> checkUpgradeCallable()

Check if an upgrade operation on the environment will succeed.

In case of problems detailed info can be found in the returned Operation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   CheckUpgradeRequest request =
       CheckUpgradeRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setImageVersion("imageVersion949870333")
           .build();
   ApiFuture<Operation> future = environmentsClient.checkUpgradeCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CheckUpgradeRequest,Operation>

checkUpgradeOperationCallable()

public final OperationCallable<CheckUpgradeRequest,CheckUpgradeResponse,OperationMetadata> checkUpgradeOperationCallable()

Check if an upgrade operation on the environment will succeed.

In case of problems detailed info can be found in the returned Operation.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   CheckUpgradeRequest request =
       CheckUpgradeRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setImageVersion("imageVersion949870333")
           .build();
   OperationFuture<CheckUpgradeResponse, OperationMetadata> future =
       environmentsClient.checkUpgradeOperationCallable().futureCall(request);
   // Do something.
   CheckUpgradeResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<CheckUpgradeRequest,CheckUpgradeResponse,OperationMetadata>

close()

public final void close()

createEnvironmentAsync(CreateEnvironmentRequest request)

public final OperationFuture<Environment,OperationMetadata> createEnvironmentAsync(CreateEnvironmentRequest request)

Create a new environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   CreateEnvironmentRequest request =
       CreateEnvironmentRequest.newBuilder()
           .setParent("parent-995424086")
           .setEnvironment(Environment.newBuilder().build())
           .build();
   Environment response = environmentsClient.createEnvironmentAsync(request).get();
 }
 
Parameter
Name Description
request CreateEnvironmentRequest

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

Returns
Type Description
OperationFuture<Environment,OperationMetadata>

createEnvironmentAsync(String parent, Environment environment)

public final OperationFuture<Environment,OperationMetadata> createEnvironmentAsync(String parent, Environment environment)

Create a new environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   String parent = "parent-995424086";
   Environment environment = Environment.newBuilder().build();
   Environment response = environmentsClient.createEnvironmentAsync(parent, environment).get();
 }
 
Parameters
Name Description
parent String

The parent must be of the form "projects/{projectId}/locations/{locationId}".

environment Environment

The environment to create.

Returns
Type Description
OperationFuture<Environment,OperationMetadata>

createEnvironmentCallable()

public final UnaryCallable<CreateEnvironmentRequest,Operation> createEnvironmentCallable()

Create a new environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   CreateEnvironmentRequest request =
       CreateEnvironmentRequest.newBuilder()
           .setParent("parent-995424086")
           .setEnvironment(Environment.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       environmentsClient.createEnvironmentCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateEnvironmentRequest,Operation>

createEnvironmentOperationCallable()

public final OperationCallable<CreateEnvironmentRequest,Environment,OperationMetadata> createEnvironmentOperationCallable()

Create a new environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   CreateEnvironmentRequest request =
       CreateEnvironmentRequest.newBuilder()
           .setParent("parent-995424086")
           .setEnvironment(Environment.newBuilder().build())
           .build();
   OperationFuture<Environment, OperationMetadata> future =
       environmentsClient.createEnvironmentOperationCallable().futureCall(request);
   // Do something.
   Environment response = future.get();
 }
 
Returns
Type Description
OperationCallable<CreateEnvironmentRequest,Environment,OperationMetadata>

deleteEnvironmentAsync(DeleteEnvironmentRequest request)

public final OperationFuture<Empty,OperationMetadata> deleteEnvironmentAsync(DeleteEnvironmentRequest request)

Delete an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   DeleteEnvironmentRequest request =
       DeleteEnvironmentRequest.newBuilder().setName("name3373707").build();
   environmentsClient.deleteEnvironmentAsync(request).get();
 }
 
Parameter
Name Description
request DeleteEnvironmentRequest

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

Returns
Type Description
OperationFuture<Empty,OperationMetadata>

deleteEnvironmentAsync(String name)

public final OperationFuture<Empty,OperationMetadata> deleteEnvironmentAsync(String name)

Delete an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   String name = "name3373707";
   environmentsClient.deleteEnvironmentAsync(name).get();
 }
 
Parameter
Name Description
name String

The environment to delete, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}"

Returns
Type Description
OperationFuture<Empty,OperationMetadata>

deleteEnvironmentCallable()

public final UnaryCallable<DeleteEnvironmentRequest,Operation> deleteEnvironmentCallable()

Delete an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   DeleteEnvironmentRequest request =
       DeleteEnvironmentRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Operation> future =
       environmentsClient.deleteEnvironmentCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteEnvironmentRequest,Operation>

deleteEnvironmentOperationCallable()

public final OperationCallable<DeleteEnvironmentRequest,Empty,OperationMetadata> deleteEnvironmentOperationCallable()

Delete an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   DeleteEnvironmentRequest request =
       DeleteEnvironmentRequest.newBuilder().setName("name3373707").build();
   OperationFuture<Empty, OperationMetadata> future =
       environmentsClient.deleteEnvironmentOperationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
OperationCallable<DeleteEnvironmentRequest,Empty,OperationMetadata>

getEnvironment(GetEnvironmentRequest request)

public final Environment getEnvironment(GetEnvironmentRequest request)

Get an existing environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   GetEnvironmentRequest request =
       GetEnvironmentRequest.newBuilder().setName("name3373707").build();
   Environment response = environmentsClient.getEnvironment(request);
 }
 
Parameter
Name Description
request GetEnvironmentRequest

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

Returns
Type Description
Environment

getEnvironment(String name)

public final Environment getEnvironment(String name)

Get an existing environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   String name = "name3373707";
   Environment response = environmentsClient.getEnvironment(name);
 }
 
Parameter
Name Description
name String

The resource name of the environment to get, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}"

Returns
Type Description
Environment

getEnvironmentCallable()

public final UnaryCallable<GetEnvironmentRequest,Environment> getEnvironmentCallable()

Get an existing environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   GetEnvironmentRequest request =
       GetEnvironmentRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Environment> future =
       environmentsClient.getEnvironmentCallable().futureCall(request);
   // Do something.
   Environment response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetEnvironmentRequest,Environment>

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.

Returns
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.

Returns
Type Description
OperationsClient

getSettings()

public final EnvironmentsSettings getSettings()
Returns
Type Description
EnvironmentsSettings

getStub()

public EnvironmentsStub getStub()
Returns
Type Description
EnvironmentsStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listEnvironments(ListEnvironmentsRequest request)

public final EnvironmentsClient.ListEnvironmentsPagedResponse listEnvironments(ListEnvironmentsRequest request)

List environments.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   ListEnvironmentsRequest request =
       ListEnvironmentsRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (Environment element : environmentsClient.listEnvironments(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListEnvironmentsRequest

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

Returns
Type Description
EnvironmentsClient.ListEnvironmentsPagedResponse

listEnvironments(String parent)

public final EnvironmentsClient.ListEnvironmentsPagedResponse listEnvironments(String parent)

List environments.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   String parent = "parent-995424086";
   for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

List environments in the given project and location, in the form: "projects/{projectId}/locations/{locationId}"

Returns
Type Description
EnvironmentsClient.ListEnvironmentsPagedResponse

listEnvironmentsCallable()

public final UnaryCallable<ListEnvironmentsRequest,ListEnvironmentsResponse> listEnvironmentsCallable()

List environments.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   ListEnvironmentsRequest request =
       ListEnvironmentsRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListEnvironmentsResponse response =
         environmentsClient.listEnvironmentsCallable().call(request);
     for (Environment element : response.getEnvironmentsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListEnvironmentsRequest,ListEnvironmentsResponse>

listEnvironmentsPagedCallable()

public final UnaryCallable<ListEnvironmentsRequest,EnvironmentsClient.ListEnvironmentsPagedResponse> listEnvironmentsPagedCallable()

List environments.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   ListEnvironmentsRequest request =
       ListEnvironmentsRequest.newBuilder()
           .setParent("parent-995424086")
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<Environment> future =
       environmentsClient.listEnvironmentsPagedCallable().futureCall(request);
   // Do something.
   for (Environment element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListEnvironmentsRequest,ListEnvironmentsPagedResponse>

loadSnapshotAsync(LoadSnapshotRequest request)

public final OperationFuture<LoadSnapshotResponse,OperationMetadata> loadSnapshotAsync(LoadSnapshotRequest request)

Loads a snapshot of a Cloud Composer environment.

As a result of this operation, a snapshot of environment's specified in LoadSnapshotRequest is loaded into the environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   LoadSnapshotRequest request =
       LoadSnapshotRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setSnapshotPath("snapshotPath-931648503")
           .setSkipPypiPackagesInstallation(true)
           .setSkipEnvironmentVariablesSetting(true)
           .setSkipAirflowOverridesSetting(true)
           .setSkipGcsDataCopying(true)
           .build();
   LoadSnapshotResponse response = environmentsClient.loadSnapshotAsync(request).get();
 }
 
Parameter
Name Description
request LoadSnapshotRequest

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

Returns
Type Description
OperationFuture<LoadSnapshotResponse,OperationMetadata>

loadSnapshotCallable()

public final UnaryCallable<LoadSnapshotRequest,Operation> loadSnapshotCallable()

Loads a snapshot of a Cloud Composer environment.

As a result of this operation, a snapshot of environment's specified in LoadSnapshotRequest is loaded into the environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   LoadSnapshotRequest request =
       LoadSnapshotRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setSnapshotPath("snapshotPath-931648503")
           .setSkipPypiPackagesInstallation(true)
           .setSkipEnvironmentVariablesSetting(true)
           .setSkipAirflowOverridesSetting(true)
           .setSkipGcsDataCopying(true)
           .build();
   ApiFuture<Operation> future = environmentsClient.loadSnapshotCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<LoadSnapshotRequest,Operation>

loadSnapshotOperationCallable()

public final OperationCallable<LoadSnapshotRequest,LoadSnapshotResponse,OperationMetadata> loadSnapshotOperationCallable()

Loads a snapshot of a Cloud Composer environment.

As a result of this operation, a snapshot of environment's specified in LoadSnapshotRequest is loaded into the environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   LoadSnapshotRequest request =
       LoadSnapshotRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setSnapshotPath("snapshotPath-931648503")
           .setSkipPypiPackagesInstallation(true)
           .setSkipEnvironmentVariablesSetting(true)
           .setSkipAirflowOverridesSetting(true)
           .setSkipGcsDataCopying(true)
           .build();
   OperationFuture<LoadSnapshotResponse, OperationMetadata> future =
       environmentsClient.loadSnapshotOperationCallable().futureCall(request);
   // Do something.
   LoadSnapshotResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<LoadSnapshotRequest,LoadSnapshotResponse,OperationMetadata>

restartWebServerAsync(RestartWebServerRequest request)

public final OperationFuture<Environment,OperationMetadata> restartWebServerAsync(RestartWebServerRequest request)

Restart Airflow web server.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   RestartWebServerRequest request =
       RestartWebServerRequest.newBuilder().setName("name3373707").build();
   Environment response = environmentsClient.restartWebServerAsync(request).get();
 }
 
Parameter
Name Description
request RestartWebServerRequest

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

Returns
Type Description
OperationFuture<Environment,OperationMetadata>

restartWebServerCallable()

public final UnaryCallable<RestartWebServerRequest,Operation> restartWebServerCallable()

Restart Airflow web server.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   RestartWebServerRequest request =
       RestartWebServerRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Operation> future =
       environmentsClient.restartWebServerCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<RestartWebServerRequest,Operation>

restartWebServerOperationCallable()

public final OperationCallable<RestartWebServerRequest,Environment,OperationMetadata> restartWebServerOperationCallable()

Restart Airflow web server.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   RestartWebServerRequest request =
       RestartWebServerRequest.newBuilder().setName("name3373707").build();
   OperationFuture<Environment, OperationMetadata> future =
       environmentsClient.restartWebServerOperationCallable().futureCall(request);
   // Do something.
   Environment response = future.get();
 }
 
Returns
Type Description
OperationCallable<RestartWebServerRequest,Environment,OperationMetadata>

saveSnapshotAsync(SaveSnapshotRequest request)

public final OperationFuture<SaveSnapshotResponse,OperationMetadata> saveSnapshotAsync(SaveSnapshotRequest request)

Creates a snapshots of a Cloud Composer environment.

As a result of this operation, snapshot of environment's state is stored in a location specified in the SaveSnapshotRequest.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   SaveSnapshotRequest request =
       SaveSnapshotRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setSnapshotLocation("snapshotLocation1625609625")
           .build();
   SaveSnapshotResponse response = environmentsClient.saveSnapshotAsync(request).get();
 }
 
Parameter
Name Description
request SaveSnapshotRequest

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

Returns
Type Description
OperationFuture<SaveSnapshotResponse,OperationMetadata>

saveSnapshotCallable()

public final UnaryCallable<SaveSnapshotRequest,Operation> saveSnapshotCallable()

Creates a snapshots of a Cloud Composer environment.

As a result of this operation, snapshot of environment's state is stored in a location specified in the SaveSnapshotRequest.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   SaveSnapshotRequest request =
       SaveSnapshotRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setSnapshotLocation("snapshotLocation1625609625")
           .build();
   ApiFuture<Operation> future = environmentsClient.saveSnapshotCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<SaveSnapshotRequest,Operation>

saveSnapshotOperationCallable()

public final OperationCallable<SaveSnapshotRequest,SaveSnapshotResponse,OperationMetadata> saveSnapshotOperationCallable()

Creates a snapshots of a Cloud Composer environment.

As a result of this operation, snapshot of environment's state is stored in a location specified in the SaveSnapshotRequest.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   SaveSnapshotRequest request =
       SaveSnapshotRequest.newBuilder()
           .setEnvironment("environment-85904877")
           .setSnapshotLocation("snapshotLocation1625609625")
           .build();
   OperationFuture<SaveSnapshotResponse, OperationMetadata> future =
       environmentsClient.saveSnapshotOperationCallable().futureCall(request);
   // Do something.
   SaveSnapshotResponse response = future.get();
 }
 
Returns
Type Description
OperationCallable<SaveSnapshotRequest,SaveSnapshotResponse,OperationMetadata>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateEnvironmentAsync(UpdateEnvironmentRequest request)

public final OperationFuture<Environment,OperationMetadata> updateEnvironmentAsync(UpdateEnvironmentRequest request)

Update an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   UpdateEnvironmentRequest request =
       UpdateEnvironmentRequest.newBuilder()
           .setName("name3373707")
           .setEnvironment(Environment.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Environment response = environmentsClient.updateEnvironmentAsync(request).get();
 }
 
Parameter
Name Description
request UpdateEnvironmentRequest

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

Returns
Type Description
OperationFuture<Environment,OperationMetadata>

updateEnvironmentAsync(String name, Environment environment, FieldMask updateMask)

public final OperationFuture<Environment,OperationMetadata> updateEnvironmentAsync(String name, Environment environment, FieldMask updateMask)

Update an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   String name = "name3373707";
   Environment environment = Environment.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Environment response =
       environmentsClient.updateEnvironmentAsync(name, environment, updateMask).get();
 }
 
Parameters
Name Description
name String

The relative resource name of the environment to update, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}"

environment Environment

A patch environment. Fields specified by the updateMask will be copied from the patch environment into the environment under update.

updateMask FieldMask

Required. A comma-separated list of paths, relative to Environment, of fields to update. For example, to set the version of scikit-learn to install in the environment to 0.19.0 and to remove an existing installation of argparse, the updateMask parameter would include the following two paths values: "config.softwareConfig.pypiPackages.scikit-learn" and "config.softwareConfig.pypiPackages.argparse". The included patch environment would specify the scikit-learn version as follows:

{ "config":{ "softwareConfig":{ "pypiPackages":{ "scikit-learn":"==0.19.0" } } } }

Note that in the above example, any existing PyPI packages other than scikit-learn and argparse will be unaffected.

Only one update type may be included in a single request's updateMask. For example, one cannot update both the PyPI packages and labels in the same request. However, it is possible to update multiple members of a map field simultaneously in the same request. For example, to set the labels "label1" and "label2" while clearing "label3" (assuming it already exists), one can provide the paths "labels.label1", "labels.label2", and "labels.label3" and populate the patch environment as follows:

{ "labels":{ "label1":"new-label1-value" "label2":"new-label2-value" } }

Note that in the above example, any existing labels that are not included in the updateMask will be unaffected.

It is also possible to replace an entire map field by providing the map field's path in the updateMask. The new value of the field will be that which is provided in the patch environment. For example, to delete all pre-existing user-specified PyPI packages and install botocore at version 1.7.14, the updateMask would contain the path "config.softwareConfig.pypiPackages", and the patch environment would be the following:

{ "config":{ "softwareConfig":{ "pypiPackages":{ "botocore":"==1.7.14" } } } }

**Note:** Only the following fields can be updated:

  • config.softwareConfig.pypiPackages * Replace all custom custom PyPI packages. If a replacement package map is not included in environment, all custom PyPI packages are cleared. It is an error to provide both this mask and a mask specifying an individual package.
  • config.softwareConfig.pypiPackages.packagename * Update the custom PyPI package *packagename*, preserving other packages. To delete the package, include it in updateMask, and omit the mapping for it in environment.config.softwareConfig.pypiPackages. It is an error to provide both a mask of this form and the config.softwareConfig.pypiPackages mask.
  • labels * Replace all environment labels. If a replacement labels map is not included in environment, all labels are cleared. It is an error to provide both this mask and a mask specifying one or more individual labels.
  • labels.labelName * Set the label named *labelName*, while preserving other labels. To delete the label, include it in updateMask and omit its mapping in environment.labels. It is an error to provide both a mask of this form and the labels mask.
  • config.nodeCount * Horizontally scale the number of nodes in the environment. An integer greater than or equal to 3 must be provided in the config.nodeCount field. Supported for Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*.
  • config.webServerNetworkAccessControl * Replace the environment's current WebServerNetworkAccessControl.
  • config.softwareConfig.airflowConfigOverrides * Replace all Apache Airflow config overrides. If a replacement config overrides map is not included in environment, all config overrides are cleared. It is an error to provide both this mask and a mask specifying one or more individual config overrides.
  • config.softwareConfig.airflowConfigOverrides.section-name * Override the Apache Airflow config property *name* in the section named *section*, preserving other properties. To delete the property override, include it in updateMask and omit its mapping in environment.config.softwareConfig.airflowConfigOverrides. It is an error to provide both a mask of this form and the config.softwareConfig.airflowConfigOverrides mask.
  • config.softwareConfig.envVariables * Replace all environment variables. If a replacement environment variable map is not included in environment, all custom environment variables are cleared.
  • config.softwareConfig.imageVersion * Upgrade the version of the environment in-place. Refer to SoftwareConfig.image_version for information on how to format the new image version. Additionally, the new image version cannot effect a version downgrade, and must match the current image version's Composer and Airflow major versions. Consult the Cloud Composer version list for valid values.
  • config.softwareConfig.schedulerCount * Horizontally scale the number of schedulers in Airflow. A positive integer not greater than the number of nodes must be provided in the config.softwareConfig.schedulerCount field. Supported for Cloud Composer environments in versions composer-1.*.*-airflow-2.*.*.
  • config.softwareConfig.cloudDataLineageIntegration * Configuration for Cloud Data Lineage integration.
  • config.databaseConfig.machineType * Cloud SQL machine type used by Airflow database. It has to be one of: db-n1-standard-2, db-n1-standard-4, db-n1-standard-8 or db-n1-standard-16. Supported for Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*.
  • config.webServerConfig.machineType * Machine type on which Airflow web server is running. It has to be one of: composer-n1-webserver-2, composer-n1-webserver-4 or composer-n1-webserver-8. Supported for Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*.
  • config.maintenanceWindow * Maintenance window during which Cloud Composer components may be under maintenance.
  • config.workloadsConfig * The workloads configuration settings for the GKE cluster associated with the Cloud Composer environment. Supported for Cloud Composer environments in versions composer-2.*.*-airflow-*.*.* and newer.
  • config.environmentSize * The size of the Cloud Composer environment. Supported for Cloud Composer environments in versions composer-2.*.*-airflow-*.*.* and newer.

Returns
Type Description
OperationFuture<Environment,OperationMetadata>

updateEnvironmentCallable()

public final UnaryCallable<UpdateEnvironmentRequest,Operation> updateEnvironmentCallable()

Update an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   UpdateEnvironmentRequest request =
       UpdateEnvironmentRequest.newBuilder()
           .setName("name3373707")
           .setEnvironment(Environment.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       environmentsClient.updateEnvironmentCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateEnvironmentRequest,Operation>

updateEnvironmentOperationCallable()

public final OperationCallable<UpdateEnvironmentRequest,Environment,OperationMetadata> updateEnvironmentOperationCallable()

Update an environment.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) {
   UpdateEnvironmentRequest request =
       UpdateEnvironmentRequest.newBuilder()
           .setName("name3373707")
           .setEnvironment(Environment.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   OperationFuture<Environment, OperationMetadata> future =
       environmentsClient.updateEnvironmentOperationCallable().futureCall(request);
   // Do something.
   Environment response = future.get();
 }
 
Returns
Type Description
OperationCallable<UpdateEnvironmentRequest,Environment,OperationMetadata>