Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

feat: added LoadSnapshot, SaveSnapshot RPCs #150

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions 20 google/cloud/orchestration/airflow/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@
IPAllocationPolicy,
ListEnvironmentsRequest,
ListEnvironmentsResponse,
LoadSnapshotRequest,
LoadSnapshotResponse,
MaintenanceWindow,
MasterAuthorizedNetworksConfig,
NetworkingConfig,
NodeConfig,
PrivateClusterConfig,
PrivateEnvironmentConfig,
RecoveryConfig,
SaveSnapshotRequest,
SaveSnapshotResponse,
ScheduledSnapshotsConfig,
SoftwareConfig,
UpdateEnvironmentRequest,
WebServerConfig,
WebServerNetworkAccessControl,
WorkloadsConfig,
)
from google.cloud.orchestration.airflow.service_v1.types.image_versions import (
ImageVersion,
Expand All @@ -75,13 +85,23 @@
"IPAllocationPolicy",
"ListEnvironmentsRequest",
"ListEnvironmentsResponse",
"LoadSnapshotRequest",
"LoadSnapshotResponse",
"MaintenanceWindow",
"MasterAuthorizedNetworksConfig",
"NetworkingConfig",
"NodeConfig",
"PrivateClusterConfig",
"PrivateEnvironmentConfig",
"RecoveryConfig",
"SaveSnapshotRequest",
"SaveSnapshotResponse",
"ScheduledSnapshotsConfig",
"SoftwareConfig",
"UpdateEnvironmentRequest",
"WebServerConfig",
"WebServerNetworkAccessControl",
"WorkloadsConfig",
"ImageVersion",
"ListImageVersionsRequest",
"ListImageVersionsResponse",
Expand Down
20 changes: 20 additions & 0 deletions 20 google/cloud/orchestration/airflow/service_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@
IPAllocationPolicy,
ListEnvironmentsRequest,
ListEnvironmentsResponse,
LoadSnapshotRequest,
LoadSnapshotResponse,
MaintenanceWindow,
MasterAuthorizedNetworksConfig,
NetworkingConfig,
NodeConfig,
PrivateClusterConfig,
PrivateEnvironmentConfig,
RecoveryConfig,
SaveSnapshotRequest,
SaveSnapshotResponse,
ScheduledSnapshotsConfig,
SoftwareConfig,
UpdateEnvironmentRequest,
WebServerConfig,
WebServerNetworkAccessControl,
WorkloadsConfig,
)
from .types.image_versions import (
ImageVersion,
Expand Down Expand Up @@ -66,12 +76,22 @@
"ListEnvironmentsResponse",
"ListImageVersionsRequest",
"ListImageVersionsResponse",
"LoadSnapshotRequest",
"LoadSnapshotResponse",
"MaintenanceWindow",
"MasterAuthorizedNetworksConfig",
"NetworkingConfig",
"NodeConfig",
"OperationMetadata",
"PrivateClusterConfig",
"PrivateEnvironmentConfig",
"RecoveryConfig",
"SaveSnapshotRequest",
"SaveSnapshotResponse",
"ScheduledSnapshotsConfig",
"SoftwareConfig",
"UpdateEnvironmentRequest",
"WebServerConfig",
"WebServerNetworkAccessControl",
"WorkloadsConfig",
)
20 changes: 20 additions & 0 deletions 20 google/cloud/orchestration/airflow/service_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
"list_environments"
]
},
"LoadSnapshot": {
"methods": [
"load_snapshot"
]
},
"SaveSnapshot": {
"methods": [
"save_snapshot"
]
},
"UpdateEnvironment": {
"methods": [
"update_environment"
Expand Down Expand Up @@ -60,6 +70,16 @@
"list_environments"
]
},
"LoadSnapshot": {
"methods": [
"load_snapshot"
]
},
"SaveSnapshot": {
"methods": [
"save_snapshot"
]
},
"UpdateEnvironment": {
"methods": [
"update_environment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,23 +731,14 @@ async def sample_update_environment():
- 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.
field. Supported for Cloud Composer environments
in versions composer-1.\ *.*-airflow-*.*.*.

- ``config.webServerNetworkAccessControl``

- Replace the environment's current
``WebServerNetworkAccessControl``.

- ``config.databaseConfig``

- Replace the environment's current
``DatabaseConfig``.

- ``config.webServerConfig``

- Replace the environment's current
``WebServerConfig``.

- ``config.softwareConfig.airflowConfigOverrides``

- Replace all Apache Airflow config overrides. If a
Expand Down Expand Up @@ -775,9 +766,34 @@ async def sample_update_environment():
- Replace all environment variables. If a
replacement environment variable map is not
included in ``environment``, all custom
environment variables are cleared. It is an error
to provide both this mask and a mask specifying
one or more individual environment variables.
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 the
``config.softwareConfig.schedulerCount`` field.
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-*.*.*.

This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down Expand Up @@ -974,6 +990,204 @@ async def sample_delete_environment():
# Done; return the response.
return response

async def save_snapshot(
self,
request: Optional[Union[environments.SaveSnapshotRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""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.

.. code-block:: python

# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud.orchestration.airflow import service_v1

async def sample_save_snapshot():
# Create a client
client = service_v1.EnvironmentsAsyncClient()

# Initialize request argument(s)
request = service_v1.SaveSnapshotRequest(
)

# Make the request
operation = client.save_snapshot(request=request)

print("Waiting for operation to complete...")

response = await operation.result()

# Handle the response
print(response)

Args:
request (Optional[Union[google.cloud.orchestration.airflow.service_v1.types.SaveSnapshotRequest, dict]]):
The request object. Request to create a snapshot of a
Cloud Composer environment.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.orchestration.airflow.service_v1.types.SaveSnapshotResponse`
Response to SaveSnapshotRequest.

"""
# Create or coerce a protobuf request object.
request = environments.SaveSnapshotRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.save_snapshot,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("environment", request.environment),)
),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
environments.SaveSnapshotResponse,
metadata_type=operations.OperationMetadata,
)

# Done; return the response.
return response

async def load_snapshot(
self,
request: Optional[Union[environments.LoadSnapshotRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""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.

.. code-block:: python

# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud.orchestration.airflow import service_v1

async def sample_load_snapshot():
# Create a client
client = service_v1.EnvironmentsAsyncClient()

# Initialize request argument(s)
request = service_v1.LoadSnapshotRequest(
)

# Make the request
operation = client.load_snapshot(request=request)

print("Waiting for operation to complete...")

response = await operation.result()

# Handle the response
print(response)

Args:
request (Optional[Union[google.cloud.orchestration.airflow.service_v1.types.LoadSnapshotRequest, dict]]):
The request object. Request to load a snapshot into a
Cloud Composer environment.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.orchestration.airflow.service_v1.types.LoadSnapshotResponse`
Response to LoadSnapshotRequest.

"""
# Create or coerce a protobuf request object.
request = environments.LoadSnapshotRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.load_snapshot,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("environment", request.environment),)
),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
environments.LoadSnapshotResponse,
metadata_type=operations.OperationMetadata,
)

# Done; return the response.
return response

async def __aenter__(self):
return self

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.