Class EnvironmentsClient (1.7.0)
Stay organized with collections
Save and categorize content based on your preferences.
- 1.78.0 (latest)
- 1.76.0
- 1.75.0
- 1.74.0
- 1.73.0
- 1.72.0
- 1.70.0
- 1.68.0
- 1.67.0
- 1.64.0
- 1.63.0
- 1.62.0
- 1.60.0
- 1.59.0
- 1.58.0
- 1.57.0
- 1.56.0
- 1.55.0
- 1.54.0
- 1.53.0
- 1.52.0
- 1.51.0
- 1.49.0
- 1.48.0
- 1.47.0
- 1.46.0
- 1.45.0
- 1.44.0
- 1.43.0
- 1.42.0
- 1.41.0
- 1.40.0
- 1.39.0
- 1.37.0
- 1.36.0
- 1.35.0
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.0
- 1.29.0
- 1.28.0
- 1.27.0
- 1.24.0
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.0
- 1.11.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
publicclass EnvironmentsClientimplementsBackgroundResourceService 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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
Stringname="name3373707";
Environmentresponse=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:
- 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 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
EnvironmentsSettingsenvironmentsSettings=
EnvironmentsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
EnvironmentsClientenvironmentsClient=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
EnvironmentsSettingsenvironmentsSettings=
EnvironmentsSettings.newBuilder().setEndpoint(myEndpoint).build();
EnvironmentsClientenvironmentsClient=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
EnvironmentsSettingsenvironmentsSettings=EnvironmentsSettings.newHttpJsonBuilder().build();
EnvironmentsClientenvironmentsClient=EnvironmentsClient.create(environmentsSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceInherited Members
Static Methods
create()
publicstaticfinalEnvironmentsClientcreate()Constructs an instance of EnvironmentsClient with default settings.
create(EnvironmentsSettings settings)
publicstaticfinalEnvironmentsClientcreate(EnvironmentsSettingssettings)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.
create(EnvironmentsStub stub)
publicstaticfinalEnvironmentsClientcreate(EnvironmentsStubstub)Constructs an instance of EnvironmentsClient, using the given stub for making calls. This is for advanced usage - prefer using create(EnvironmentsSettings).
Constructors
EnvironmentsClient(EnvironmentsSettings settings)
protectedEnvironmentsClient(EnvironmentsSettingssettings)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.
EnvironmentsClient(EnvironmentsStub stub)
protectedEnvironmentsClient(EnvironmentsStubstub)Methods
awaitTermination(long duration, TimeUnit unit)
publicbooleanawaitTermination(longduration,TimeUnitunit)close()
publicfinalvoidclose()createEnvironmentAsync(CreateEnvironmentRequest request)
publicfinalOperationFuture<Environment,OperationMetadata>createEnvironmentAsync(CreateEnvironmentRequestrequest)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
CreateEnvironmentRequestrequest=
CreateEnvironmentRequest.newBuilder()
.setParent("parent-995424086")
.setEnvironment(Environment.newBuilder().build())
.build();
Environmentresponse=environmentsClient.createEnvironmentAsync(request).get();
}
CreateEnvironmentRequest The request object containing all of the parameters for the API call.
createEnvironmentAsync(String parent, Environment environment)
publicfinalOperationFuture<Environment,OperationMetadata>createEnvironmentAsync(Stringparent,Environmentenvironment)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
Stringparent="parent-995424086";
Environmentenvironment=Environment.newBuilder().build();
Environmentresponse=environmentsClient.createEnvironmentAsync(parent,environment).get();
}
createEnvironmentCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
CreateEnvironmentRequestrequest=
CreateEnvironmentRequest.newBuilder()
.setParent("parent-995424086")
.setEnvironment(Environment.newBuilder().build())
.build();
ApiFuture<Operation>future=
environmentsClient.createEnvironmentCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
createEnvironmentOperationCallable()
publicfinalOperationCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
CreateEnvironmentRequestrequest=
CreateEnvironmentRequest.newBuilder()
.setParent("parent-995424086")
.setEnvironment(Environment.newBuilder().build())
.build();
OperationFuture<Environment,OperationMetadata>future=
environmentsClient.createEnvironmentOperationCallable().futureCall(request);
// Do something.
Environmentresponse=future.get();
}
deleteEnvironmentAsync(DeleteEnvironmentRequest request)
publicfinalOperationFuture<Empty,OperationMetadata>deleteEnvironmentAsync(DeleteEnvironmentRequestrequest)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
DeleteEnvironmentRequestrequest=
DeleteEnvironmentRequest.newBuilder().setName("name3373707").build();
environmentsClient.deleteEnvironmentAsync(request).get();
}
DeleteEnvironmentRequest The request object containing all of the parameters for the API call.
deleteEnvironmentAsync(String name)
publicfinalOperationFuture<Empty,OperationMetadata>deleteEnvironmentAsync(Stringname)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
Stringname="name3373707";
environmentsClient.deleteEnvironmentAsync(name).get();
}
String The environment to delete, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
deleteEnvironmentCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
DeleteEnvironmentRequestrequest=
DeleteEnvironmentRequest.newBuilder().setName("name3373707").build();
ApiFuture<Operation>future=
environmentsClient.deleteEnvironmentCallable().futureCall(request);
// Do something.
future.get();
}
deleteEnvironmentOperationCallable()
publicfinalOperationCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
DeleteEnvironmentRequestrequest=
DeleteEnvironmentRequest.newBuilder().setName("name3373707").build();
OperationFuture<Empty,OperationMetadata>future=
environmentsClient.deleteEnvironmentOperationCallable().futureCall(request);
// Do something.
future.get();
}
getEnvironment(GetEnvironmentRequest request)
publicfinalEnvironmentgetEnvironment(GetEnvironmentRequestrequest)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
GetEnvironmentRequestrequest=
GetEnvironmentRequest.newBuilder().setName("name3373707").build();
Environmentresponse=environmentsClient.getEnvironment(request);
}
getEnvironment(String name)
publicfinalEnvironmentgetEnvironment(Stringname)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
Stringname="name3373707";
Environmentresponse=environmentsClient.getEnvironment(name);
}
String The resource name of the environment to get, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
getEnvironmentCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
GetEnvironmentRequestrequest=
GetEnvironmentRequest.newBuilder().setName("name3373707").build();
ApiFuture<Environment>future=
environmentsClient.getEnvironmentCallable().futureCall(request);
// Do something.
Environmentresponse=future.get();
}
getHttpJsonOperationsClient()
publicfinalOperationsClientgetHttpJsonOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
getOperationsClient()
publicfinalOperationsClientgetOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
getSettings()
publicfinalEnvironmentsSettingsgetSettings()getStub()
publicEnvironmentsStubgetStub()isShutdown()
publicbooleanisShutdown()isTerminated()
publicbooleanisTerminated()listEnvironments(ListEnvironmentsRequest request)
publicfinalEnvironmentsClient.ListEnvironmentsPagedResponselistEnvironments(ListEnvironmentsRequestrequest)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
ListEnvironmentsRequestrequest=
ListEnvironmentsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Environmentelement:environmentsClient.listEnvironments(request).iterateAll()){
// doThingsWith(element);
}
}
ListEnvironmentsRequest The request object containing all of the parameters for the API call.
listEnvironments(String parent)
publicfinalEnvironmentsClient.ListEnvironmentsPagedResponselistEnvironments(Stringparent)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
Stringparent="parent-995424086";
for(Environmentelement:environmentsClient.listEnvironments(parent).iterateAll()){
// doThingsWith(element);
}
}
String List environments in the given project and location, in the form: "projects/{projectId}/locations/{locationId}"
listEnvironmentsCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
ListEnvironmentsRequestrequest=
ListEnvironmentsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListEnvironmentsResponseresponse=
environmentsClient.listEnvironmentsCallable().call(request);
for(Environmentelement:response.getEnvironmentsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
listEnvironmentsPagedCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
ListEnvironmentsRequestrequest=
ListEnvironmentsRequest.newBuilder()
.setParent("parent-995424086")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Environment>future=
environmentsClient.listEnvironmentsPagedCallable().futureCall(request);
// Do something.
for(Environmentelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
loadSnapshotAsync(LoadSnapshotRequest request)
publicfinalOperationFuture<LoadSnapshotResponse,OperationMetadata>loadSnapshotAsync(LoadSnapshotRequestrequest)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
LoadSnapshotRequestrequest=
LoadSnapshotRequest.newBuilder()
.setEnvironment("environment-85904877")
.setSnapshotPath("snapshotPath-931648503")
.setSkipPypiPackagesInstallation(true)
.setSkipEnvironmentVariablesSetting(true)
.setSkipAirflowOverridesSetting(true)
.setSkipGcsDataCopying(true)
.build();
LoadSnapshotResponseresponse=environmentsClient.loadSnapshotAsync(request).get();
}
loadSnapshotCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
LoadSnapshotRequestrequest=
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.
Operationresponse=future.get();
}
loadSnapshotOperationCallable()
publicfinalOperationCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
LoadSnapshotRequestrequest=
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.
LoadSnapshotResponseresponse=future.get();
}
saveSnapshotAsync(SaveSnapshotRequest request)
publicfinalOperationFuture<SaveSnapshotResponse,OperationMetadata>saveSnapshotAsync(SaveSnapshotRequestrequest)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
SaveSnapshotRequestrequest=
SaveSnapshotRequest.newBuilder()
.setEnvironment("environment-85904877")
.setSnapshotLocation("snapshotLocation1625609625")
.build();
SaveSnapshotResponseresponse=environmentsClient.saveSnapshotAsync(request).get();
}
saveSnapshotCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
SaveSnapshotRequestrequest=
SaveSnapshotRequest.newBuilder()
.setEnvironment("environment-85904877")
.setSnapshotLocation("snapshotLocation1625609625")
.build();
ApiFuture<Operation>future=environmentsClient.saveSnapshotCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
saveSnapshotOperationCallable()
publicfinalOperationCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
SaveSnapshotRequestrequest=
SaveSnapshotRequest.newBuilder()
.setEnvironment("environment-85904877")
.setSnapshotLocation("snapshotLocation1625609625")
.build();
OperationFuture<SaveSnapshotResponse,OperationMetadata>future=
environmentsClient.saveSnapshotOperationCallable().futureCall(request);
// Do something.
SaveSnapshotResponseresponse=future.get();
}
shutdown()
publicvoidshutdown()shutdownNow()
publicvoidshutdownNow()updateEnvironmentAsync(UpdateEnvironmentRequest request)
publicfinalOperationFuture<Environment,OperationMetadata>updateEnvironmentAsync(UpdateEnvironmentRequestrequest)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
UpdateEnvironmentRequestrequest=
UpdateEnvironmentRequest.newBuilder()
.setName("name3373707")
.setEnvironment(Environment.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Environmentresponse=environmentsClient.updateEnvironmentAsync(request).get();
}
UpdateEnvironmentRequest The request object containing all of the parameters for the API call.
updateEnvironmentAsync(String name, Environment environment, FieldMask updateMask)
publicfinalOperationFuture<Environment,OperationMetadata>updateEnvironmentAsync(Stringname,Environmentenvironment,FieldMaskupdateMask)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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
Stringname="name3373707";
Environmentenvironment=Environment.newBuilder().build();
FieldMaskupdateMask=FieldMask.newBuilder().build();
Environmentresponse=
environmentsClient.updateEnvironmentAsync(name,environment,updateMask).get();
}
String The relative resource name of the environment to update, in the form: "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
Environment A patch environment. Fields specified by the updateMask will be copied
from the patch environment into the environment under update.
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 numpy, the updateMask
parameter would include the following two paths values:
"config.softwareConfig.pypiPackages.scikit-learn" and
"config.softwareConfig.pypiPackages.numpy". 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 numpy 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 inenvironment, 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 inupdateMask, and omit the mapping for it inenvironment.config.softwareConfig.pypiPackages. It is an error to provide both a mask of this form and theconfig.softwareConfig.pypiPackagesmask.labels* Replace all environment labels. If a replacement labels map is not included inenvironment, 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 inupdateMaskand omit its mapping inenvironment.labels. It is an error to provide both a mask of this form and thelabelsmask.config.nodeCount* Horizontally scale the number of nodes in the environment. An integer greater than or equal to 3 must be provided in theconfig.nodeCountfield. Supported for Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*.config.webServerNetworkAccessControl* Replace the environment's currentWebServerNetworkAccessControl.config.softwareConfig.airflowConfigOverrides* Replace all Apache Airflow config overrides. If a replacement config overrides map is not included inenvironment, 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 inupdateMaskand omit its mapping inenvironment.config.softwareConfig.airflowConfigOverrides. It is an error to provide both a mask of this form and theconfig.softwareConfig.airflowConfigOverridesmask.config.softwareConfig.envVariables* Replace all environment variables. If a replacement environment variable map is not included inenvironment, all custom environment variables are cleared.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 theconfig.softwareConfig.schedulerCountfield. Supported for Cloud Composer environments in versions composer-1.*.*-airflow-2.*.*.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-*.*.*.
updateEnvironmentCallable()
publicfinalUnaryCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
UpdateEnvironmentRequestrequest=
UpdateEnvironmentRequest.newBuilder()
.setName("name3373707")
.setEnvironment(Environment.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Operation>future=
environmentsClient.updateEnvironmentCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
updateEnvironmentOperationCallable()
publicfinalOperationCallable<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(EnvironmentsClientenvironmentsClient=EnvironmentsClient.create()){
UpdateEnvironmentRequestrequest=
UpdateEnvironmentRequest.newBuilder()
.setName("name3373707")
.setEnvironment(Environment.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
OperationFuture<Environment,OperationMetadata>future=
environmentsClient.updateEnvironmentOperationCallable().futureCall(request);
// Do something.
Environmentresponse=future.get();
}