As of January 1, 2020 this library no longer supports Python 2 on the latest released version.
Library versions released prior to that date will continue to be available. For more information please
visit Python 2 support on Google Cloud.
Source code for google.cloud.deploy_v1.services.cloud_deploy.async_client
# -*- coding: utf-8 -*-
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from collections import OrderedDict
import re
from typing import (
Callable,
Dict,
Mapping,
MutableMapping,
MutableSequence,
Optional,
Sequence,
Tuple,
Type,
Union,
)
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
from google.api_core.client_options import ClientOptions
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
from google.cloud.deploy_v1 import gapic_version as package_version
try:
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.cloud.deploy_v1.services.cloud_deploy import pagers
from google.cloud.deploy_v1.types import cloud_deploy
from .client import CloudDeployClient
from .transports.base import DEFAULT_CLIENT_INFO, CloudDeployTransport
from .transports.grpc_asyncio import CloudDeployGrpcAsyncIOTransport
[docs]class CloudDeployAsyncClient:
"""CloudDeploy service creates and manages Continuous Delivery
operations on Google Cloud Platform via Skaffold
(https://skaffold.dev).
"""
_client: CloudDeployClient
# Copy defaults from the synchronous client for use here.
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
DEFAULT_ENDPOINT = CloudDeployClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = CloudDeployClient.DEFAULT_MTLS_ENDPOINT
_DEFAULT_ENDPOINT_TEMPLATE = CloudDeployClient._DEFAULT_ENDPOINT_TEMPLATE
_DEFAULT_UNIVERSE = CloudDeployClient._DEFAULT_UNIVERSE
automation_path = staticmethod(CloudDeployClient.automation_path)
parse_automation_path = staticmethod(CloudDeployClient.parse_automation_path)
automation_run_path = staticmethod(CloudDeployClient.automation_run_path)
parse_automation_run_path = staticmethod(
CloudDeployClient.parse_automation_run_path
)
build_path = staticmethod(CloudDeployClient.build_path)
parse_build_path = staticmethod(CloudDeployClient.parse_build_path)
cluster_path = staticmethod(CloudDeployClient.cluster_path)
parse_cluster_path = staticmethod(CloudDeployClient.parse_cluster_path)
config_path = staticmethod(CloudDeployClient.config_path)
parse_config_path = staticmethod(CloudDeployClient.parse_config_path)
custom_target_type_path = staticmethod(CloudDeployClient.custom_target_type_path)
parse_custom_target_type_path = staticmethod(
CloudDeployClient.parse_custom_target_type_path
)
delivery_pipeline_path = staticmethod(CloudDeployClient.delivery_pipeline_path)
parse_delivery_pipeline_path = staticmethod(
CloudDeployClient.parse_delivery_pipeline_path
)
deploy_policy_path = staticmethod(CloudDeployClient.deploy_policy_path)
parse_deploy_policy_path = staticmethod(CloudDeployClient.parse_deploy_policy_path)
job_path = staticmethod(CloudDeployClient.job_path)
parse_job_path = staticmethod(CloudDeployClient.parse_job_path)
job_run_path = staticmethod(CloudDeployClient.job_run_path)
parse_job_run_path = staticmethod(CloudDeployClient.parse_job_run_path)
membership_path = staticmethod(CloudDeployClient.membership_path)
parse_membership_path = staticmethod(CloudDeployClient.parse_membership_path)
release_path = staticmethod(CloudDeployClient.release_path)
parse_release_path = staticmethod(CloudDeployClient.parse_release_path)
repository_path = staticmethod(CloudDeployClient.repository_path)
parse_repository_path = staticmethod(CloudDeployClient.parse_repository_path)
rollout_path = staticmethod(CloudDeployClient.rollout_path)
parse_rollout_path = staticmethod(CloudDeployClient.parse_rollout_path)
service_path = staticmethod(CloudDeployClient.service_path)
parse_service_path = staticmethod(CloudDeployClient.parse_service_path)
target_path = staticmethod(CloudDeployClient.target_path)
parse_target_path = staticmethod(CloudDeployClient.parse_target_path)
worker_pool_path = staticmethod(CloudDeployClient.worker_pool_path)
parse_worker_pool_path = staticmethod(CloudDeployClient.parse_worker_pool_path)
common_billing_account_path = staticmethod(
CloudDeployClient.common_billing_account_path
)
parse_common_billing_account_path = staticmethod(
CloudDeployClient.parse_common_billing_account_path
)
common_folder_path = staticmethod(CloudDeployClient.common_folder_path)
parse_common_folder_path = staticmethod(CloudDeployClient.parse_common_folder_path)
common_organization_path = staticmethod(CloudDeployClient.common_organization_path)
parse_common_organization_path = staticmethod(
CloudDeployClient.parse_common_organization_path
)
common_project_path = staticmethod(CloudDeployClient.common_project_path)
parse_common_project_path = staticmethod(
CloudDeployClient.parse_common_project_path
)
common_location_path = staticmethod(CloudDeployClient.common_location_path)
parse_common_location_path = staticmethod(
CloudDeployClient.parse_common_location_path
)
[docs] @classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
info.
Args:
info (dict): The service account private key info.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
CloudDeployAsyncClient: The constructed client.
"""
return CloudDeployClient.from_service_account_info.__func__(CloudDeployAsyncClient, info, *args, **kwargs) # type: ignore
[docs] @classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.
Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.
Returns:
CloudDeployAsyncClient: The constructed client.
"""
return CloudDeployClient.from_service_account_file.__func__(CloudDeployAsyncClient, filename, *args, **kwargs) # type: ignore
from_service_account_json = from_service_account_file
[docs] @classmethod
def get_mtls_endpoint_and_cert_source(
cls, client_options: Optional[ClientOptions] = None
):
"""Return the API endpoint and client cert source for mutual TLS.
The client cert source is determined in the following order:
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
client cert source is None.
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
default client cert source exists, use the default one; otherwise the client cert
source is None.
The API endpoint is determined in the following order:
(1) if `client_options.api_endpoint` if provided, use the provided one.
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
default mTLS endpoint; if the environment variable is "never", use the default API
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
use the default API endpoint.
More details can be found at https://google.aip.dev/auth/4114.
Args:
client_options (google.api_core.client_options.ClientOptions): Custom options for the
client. Only the `api_endpoint` and `client_cert_source` properties may be used
in this method.
Returns:
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
client cert source to use.
Raises:
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
"""
return CloudDeployClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
@property
def transport(self) -> CloudDeployTransport:
"""Returns the transport used by the client instance.
Returns:
CloudDeployTransport: The transport used by the client instance.
"""
return self._client.transport
@property
def api_endpoint(self):
"""Return the API endpoint used by the client instance.
Returns:
str: The API endpoint used by the client instance.
"""
return self._client._api_endpoint
@property
def universe_domain(self) -> str:
"""Return the universe domain used by the client instance.
Returns:
str: The universe domain used
by the client instance.
"""
return self._client._universe_domain
get_transport_class = CloudDeployClient.get_transport_class
def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Optional[
Union[str, CloudDeployTransport, Callable[..., CloudDeployTransport]]
] = "grpc_asyncio",
client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the cloud deploy async client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
are specified, the client will attempt to ascertain the
credentials from the environment.
transport (Optional[Union[str,CloudDeployTransport,Callable[..., CloudDeployTransport]]]):
The transport to use, or a Callable that constructs and returns a new transport to use.
If a Callable is given, it will be called with the same set of initialization
arguments as used in the CloudDeployTransport constructor.
If set to None, a transport is chosen automatically.
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
Custom options for the client.
1. The ``api_endpoint`` property can be used to override the
default endpoint provided by the client when ``transport`` is
not explicitly provided. Only if this property is not set and
``transport`` was not explicitly provided, the endpoint is
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
variable, which have one of the following values:
"always" (always use the default mTLS endpoint), "never" (always
use the default regular endpoint) and "auto" (auto-switch to the
default mTLS endpoint if client certificate is present; this is
the default value).
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
is "true", then the ``client_cert_source`` property can be used
to provide a client certificate for mTLS transport. If
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be used.
3. The ``universe_domain`` property can be used to override the
default "googleapis.com" universe. Note that ``api_endpoint``
property still takes precedence; and ``universe_domain`` is
currently not supported for mTLS.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
The client info used to send a user-agent string along with
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
creation failed for any reason.
"""
self._client = CloudDeployClient(
credentials=credentials,
transport=transport,
client_options=client_options,
client_info=client_info,
)
[docs] async def list_delivery_pipelines(
self,
request: Optional[
Union[cloud_deploy.ListDeliveryPipelinesRequest, dict]
] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDeliveryPipelinesAsyncPager:
r"""Lists DeliveryPipelines in a given project and
location.
.. 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 import deploy_v1
async def sample_list_delivery_pipelines():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListDeliveryPipelinesRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_delivery_pipelines(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListDeliveryPipelinesRequest, dict]]):
The request object. The request object for ``ListDeliveryPipelines``.
parent (:class:`str`):
Required. The parent, which owns this collection of
pipelines. Format must be
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListDeliveryPipelinesAsyncPager:
The response object from ListDeliveryPipelines.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListDeliveryPipelinesRequest):
request = cloud_deploy.ListDeliveryPipelinesRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_delivery_pipelines
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListDeliveryPipelinesAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_delivery_pipeline(
self,
request: Optional[Union[cloud_deploy.GetDeliveryPipelineRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.DeliveryPipeline:
r"""Gets details of a single DeliveryPipeline.
.. 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 import deploy_v1
async def sample_get_delivery_pipeline():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetDeliveryPipelineRequest(
name="name_value",
)
# Make the request
response = await client.get_delivery_pipeline(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetDeliveryPipelineRequest, dict]]):
The request object. The request object for ``GetDeliveryPipeline``
name (:class:`str`):
Required. Name of the ``DeliveryPipeline``. Format must
be
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.DeliveryPipeline:
A DeliveryPipeline resource in the Cloud Deploy API.
A DeliveryPipeline defines a pipeline through which a
Skaffold configuration can progress.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetDeliveryPipelineRequest):
request = cloud_deploy.GetDeliveryPipelineRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_delivery_pipeline
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def create_delivery_pipeline(
self,
request: Optional[
Union[cloud_deploy.CreateDeliveryPipelineRequest, dict]
] = None,
*,
parent: Optional[str] = None,
delivery_pipeline: Optional[cloud_deploy.DeliveryPipeline] = None,
delivery_pipeline_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new DeliveryPipeline in a given project and
location.
.. 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 import deploy_v1
async def sample_create_delivery_pipeline():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.CreateDeliveryPipelineRequest(
parent="parent_value",
delivery_pipeline_id="delivery_pipeline_id_value",
)
# Make the request
operation = client.create_delivery_pipeline(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CreateDeliveryPipelineRequest, dict]]):
The request object. The request object for ``CreateDeliveryPipeline``.
parent (:class:`str`):
Required. The parent collection in which the
``DeliveryPipeline`` must be created. The format is
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
delivery_pipeline (:class:`google.cloud.deploy_v1.types.DeliveryPipeline`):
Required. The ``DeliveryPipeline`` to create.
This corresponds to the ``delivery_pipeline`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
delivery_pipeline_id (:class:`str`):
Required. ID of the ``DeliveryPipeline``.
This corresponds to the ``delivery_pipeline_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.DeliveryPipeline` A
DeliveryPipeline resource in the Cloud Deploy API.
A DeliveryPipeline defines a pipeline through which a
Skaffold configuration can progress.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, delivery_pipeline, delivery_pipeline_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CreateDeliveryPipelineRequest):
request = cloud_deploy.CreateDeliveryPipelineRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if delivery_pipeline is not None:
request.delivery_pipeline = delivery_pipeline
if delivery_pipeline_id is not None:
request.delivery_pipeline_id = delivery_pipeline_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.create_delivery_pipeline
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.DeliveryPipeline,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def update_delivery_pipeline(
self,
request: Optional[
Union[cloud_deploy.UpdateDeliveryPipelineRequest, dict]
] = None,
*,
delivery_pipeline: Optional[cloud_deploy.DeliveryPipeline] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates the parameters of a single DeliveryPipeline.
.. 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 import deploy_v1
async def sample_update_delivery_pipeline():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.UpdateDeliveryPipelineRequest(
)
# Make the request
operation = client.update_delivery_pipeline(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.UpdateDeliveryPipelineRequest, dict]]):
The request object. The request object for ``UpdateDeliveryPipeline``.
delivery_pipeline (:class:`google.cloud.deploy_v1.types.DeliveryPipeline`):
Required. The ``DeliveryPipeline`` to update.
This corresponds to the ``delivery_pipeline`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Field mask is used to specify the fields to be
overwritten by the update in the ``DeliveryPipeline``
resource. The fields specified in the update_mask are
relative to the resource, not the full request. A field
will be overwritten if it's in the mask. If the user
doesn't provide a mask then all fields are overwritten.
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.DeliveryPipeline` A
DeliveryPipeline resource in the Cloud Deploy API.
A DeliveryPipeline defines a pipeline through which a
Skaffold configuration can progress.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([delivery_pipeline, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.UpdateDeliveryPipelineRequest):
request = cloud_deploy.UpdateDeliveryPipelineRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if delivery_pipeline is not None:
request.delivery_pipeline = delivery_pipeline
if update_mask is not None:
request.update_mask = update_mask
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.update_delivery_pipeline
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("delivery_pipeline.name", request.delivery_pipeline.name),)
),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.DeliveryPipeline,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def delete_delivery_pipeline(
self,
request: Optional[
Union[cloud_deploy.DeleteDeliveryPipelineRequest, dict]
] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a single DeliveryPipeline.
.. 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 import deploy_v1
async def sample_delete_delivery_pipeline():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.DeleteDeliveryPipelineRequest(
name="name_value",
)
# Make the request
operation = client.delete_delivery_pipeline(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.DeleteDeliveryPipelineRequest, dict]]):
The request object. The request object for ``DeleteDeliveryPipeline``.
name (:class:`str`):
Required. The name of the ``DeliveryPipeline`` to
delete. The format is
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
empty messages in your APIs. A typical example is to
use it as the request or the response type of an API
method. For instance:
service Foo {
rpc Bar(google.protobuf.Empty) returns
(google.protobuf.Empty);
}
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.DeleteDeliveryPipelineRequest):
request = cloud_deploy.DeleteDeliveryPipelineRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.delete_delivery_pipeline
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
empty_pb2.Empty,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def list_targets(
self,
request: Optional[Union[cloud_deploy.ListTargetsRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListTargetsAsyncPager:
r"""Lists Targets in a given project and location.
.. 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 import deploy_v1
async def sample_list_targets():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListTargetsRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_targets(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListTargetsRequest, dict]]):
The request object. The request object for ``ListTargets``.
parent (:class:`str`):
Required. The parent, which owns this collection of
targets. Format must be
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListTargetsAsyncPager:
The response object from ListTargets.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListTargetsRequest):
request = cloud_deploy.ListTargetsRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_targets
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListTargetsAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def rollback_target(
self,
request: Optional[Union[cloud_deploy.RollbackTargetRequest, dict]] = None,
*,
name: Optional[str] = None,
target_id: Optional[str] = None,
rollout_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.RollbackTargetResponse:
r"""Creates a ``Rollout`` to roll back the specified target.
.. 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 import deploy_v1
async def sample_rollback_target():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.RollbackTargetRequest(
name="name_value",
target_id="target_id_value",
rollout_id="rollout_id_value",
)
# Make the request
response = await client.rollback_target(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.RollbackTargetRequest, dict]]):
The request object. The request object for ``RollbackTarget``.
name (:class:`str`):
Required. The ``DeliveryPipeline`` for which the
rollback ``Rollout`` must be created. The format is
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
target_id (:class:`str`):
Required. ID of the ``Target`` that is being rolled
back.
This corresponds to the ``target_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
rollout_id (:class:`str`):
Required. ID of the rollback ``Rollout`` to create.
This corresponds to the ``rollout_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.RollbackTargetResponse:
The response object from RollbackTarget.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name, target_id, rollout_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.RollbackTargetRequest):
request = cloud_deploy.RollbackTargetRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
if target_id is not None:
request.target_id = target_id
if rollout_id is not None:
request.rollout_id = rollout_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.rollback_target
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_target(
self,
request: Optional[Union[cloud_deploy.GetTargetRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.Target:
r"""Gets details of a single Target.
.. 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 import deploy_v1
async def sample_get_target():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetTargetRequest(
name="name_value",
)
# Make the request
response = await client.get_target(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetTargetRequest, dict]]):
The request object. The request object for ``GetTarget``.
name (:class:`str`):
Required. Name of the ``Target``. Format must be
``projects/{project_id}/locations/{location_name}/targets/{target_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.Target:
A Target resource in the Cloud Deploy API.
A Target defines a location to which a Skaffold
configuration can be deployed.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetTargetRequest):
request = cloud_deploy.GetTargetRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_target
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def create_target(
self,
request: Optional[Union[cloud_deploy.CreateTargetRequest, dict]] = None,
*,
parent: Optional[str] = None,
target: Optional[cloud_deploy.Target] = None,
target_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new Target in a given project and location.
.. 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 import deploy_v1
async def sample_create_target():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.CreateTargetRequest(
parent="parent_value",
target_id="target_id_value",
)
# Make the request
operation = client.create_target(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CreateTargetRequest, dict]]):
The request object. The request object for ``CreateTarget``.
parent (:class:`str`):
Required. The parent collection in which the ``Target``
must be created. The format is
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
target (:class:`google.cloud.deploy_v1.types.Target`):
Required. The ``Target`` to create.
This corresponds to the ``target`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
target_id (:class:`str`):
Required. ID of the ``Target``.
This corresponds to the ``target_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.Target` A Target
resource in the Cloud Deploy API.
A Target defines a location to which a Skaffold
configuration can be deployed.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, target, target_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CreateTargetRequest):
request = cloud_deploy.CreateTargetRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if target is not None:
request.target = target
if target_id is not None:
request.target_id = target_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.create_target
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.Target,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def update_target(
self,
request: Optional[Union[cloud_deploy.UpdateTargetRequest, dict]] = None,
*,
target: Optional[cloud_deploy.Target] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates the parameters of a single Target.
.. 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 import deploy_v1
async def sample_update_target():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.UpdateTargetRequest(
)
# Make the request
operation = client.update_target(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.UpdateTargetRequest, dict]]):
The request object. The request object for ``UpdateTarget``.
target (:class:`google.cloud.deploy_v1.types.Target`):
Required. The ``Target`` to update.
This corresponds to the ``target`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Field mask is used to specify the fields to be
overwritten by the update in the ``Target`` resource.
The fields specified in the update_mask are relative to
the resource, not the full request. A field will be
overwritten if it's in the mask. If the user doesn't
provide a mask then all fields are overwritten.
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.Target` A Target
resource in the Cloud Deploy API.
A Target defines a location to which a Skaffold
configuration can be deployed.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([target, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.UpdateTargetRequest):
request = cloud_deploy.UpdateTargetRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if target is not None:
request.target = target
if update_mask is not None:
request.update_mask = update_mask
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.update_target
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("target.name", request.target.name),)
),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.Target,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def delete_target(
self,
request: Optional[Union[cloud_deploy.DeleteTargetRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a single Target.
.. 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 import deploy_v1
async def sample_delete_target():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.DeleteTargetRequest(
name="name_value",
)
# Make the request
operation = client.delete_target(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.DeleteTargetRequest, dict]]):
The request object. The request object for ``DeleteTarget``.
name (:class:`str`):
Required. The name of the ``Target`` to delete. The
format is
``projects/{project_id}/locations/{location_name}/targets/{target_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
empty messages in your APIs. A typical example is to
use it as the request or the response type of an API
method. For instance:
service Foo {
rpc Bar(google.protobuf.Empty) returns
(google.protobuf.Empty);
}
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.DeleteTargetRequest):
request = cloud_deploy.DeleteTargetRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.delete_target
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
empty_pb2.Empty,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def list_custom_target_types(
self,
request: Optional[
Union[cloud_deploy.ListCustomTargetTypesRequest, dict]
] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListCustomTargetTypesAsyncPager:
r"""Lists CustomTargetTypes in a given project and
location.
.. 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 import deploy_v1
async def sample_list_custom_target_types():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListCustomTargetTypesRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_custom_target_types(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListCustomTargetTypesRequest, dict]]):
The request object. The request object for ``ListCustomTargetTypes``.
parent (:class:`str`):
Required. The parent that owns this collection of custom
target types. Format must be
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListCustomTargetTypesAsyncPager:
The response object from ListCustomTargetTypes.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListCustomTargetTypesRequest):
request = cloud_deploy.ListCustomTargetTypesRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_custom_target_types
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListCustomTargetTypesAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_custom_target_type(
self,
request: Optional[Union[cloud_deploy.GetCustomTargetTypeRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.CustomTargetType:
r"""Gets details of a single CustomTargetType.
.. 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 import deploy_v1
async def sample_get_custom_target_type():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetCustomTargetTypeRequest(
name="name_value",
)
# Make the request
response = await client.get_custom_target_type(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetCustomTargetTypeRequest, dict]]):
The request object. The request object for ``GetCustomTargetType``.
name (:class:`str`):
Required. Name of the ``CustomTargetType``. Format must
be
``projects/{project_id}/locations/{location_name}/customTargetTypes/{custom_target_type}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.CustomTargetType:
A CustomTargetType resource in the Cloud Deploy API.
A CustomTargetType defines a type of custom target
that can be referenced in a Target in order to
facilitate deploying to other systems besides the
supported runtimes.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetCustomTargetTypeRequest):
request = cloud_deploy.GetCustomTargetTypeRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_custom_target_type
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def create_custom_target_type(
self,
request: Optional[
Union[cloud_deploy.CreateCustomTargetTypeRequest, dict]
] = None,
*,
parent: Optional[str] = None,
custom_target_type: Optional[cloud_deploy.CustomTargetType] = None,
custom_target_type_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new CustomTargetType in a given project and
location.
.. 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 import deploy_v1
async def sample_create_custom_target_type():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
custom_target_type = deploy_v1.CustomTargetType()
custom_target_type.custom_actions.deploy_action = "deploy_action_value"
request = deploy_v1.CreateCustomTargetTypeRequest(
parent="parent_value",
custom_target_type_id="custom_target_type_id_value",
custom_target_type=custom_target_type,
)
# Make the request
operation = client.create_custom_target_type(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CreateCustomTargetTypeRequest, dict]]):
The request object. The request object for ``CreateCustomTargetType``.
parent (:class:`str`):
Required. The parent collection in which the
``CustomTargetType`` must be created. The format is
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
custom_target_type (:class:`google.cloud.deploy_v1.types.CustomTargetType`):
Required. The ``CustomTargetType`` to create.
This corresponds to the ``custom_target_type`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
custom_target_type_id (:class:`str`):
Required. ID of the ``CustomTargetType``.
This corresponds to the ``custom_target_type_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.CustomTargetType` A
CustomTargetType resource in the Cloud Deploy API.
A CustomTargetType defines a type of custom target
that can be referenced in a Target in order to
facilitate deploying to other systems besides the
supported runtimes.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, custom_target_type, custom_target_type_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CreateCustomTargetTypeRequest):
request = cloud_deploy.CreateCustomTargetTypeRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if custom_target_type is not None:
request.custom_target_type = custom_target_type
if custom_target_type_id is not None:
request.custom_target_type_id = custom_target_type_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.create_custom_target_type
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.CustomTargetType,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def update_custom_target_type(
self,
request: Optional[
Union[cloud_deploy.UpdateCustomTargetTypeRequest, dict]
] = None,
*,
custom_target_type: Optional[cloud_deploy.CustomTargetType] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates a single CustomTargetType.
.. 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 import deploy_v1
async def sample_update_custom_target_type():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
custom_target_type = deploy_v1.CustomTargetType()
custom_target_type.custom_actions.deploy_action = "deploy_action_value"
request = deploy_v1.UpdateCustomTargetTypeRequest(
custom_target_type=custom_target_type,
)
# Make the request
operation = client.update_custom_target_type(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.UpdateCustomTargetTypeRequest, dict]]):
The request object. The request object for ``UpdateCustomTargetType``.
custom_target_type (:class:`google.cloud.deploy_v1.types.CustomTargetType`):
Required. The ``CustomTargetType`` to update.
This corresponds to the ``custom_target_type`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Field mask is used to specify the fields to be
overwritten by the update in the ``CustomTargetType``
resource. The fields specified in the update_mask are
relative to the resource, not the full request. A field
will be overwritten if it's in the mask. If the user
doesn't provide a mask then all fields are overwritten.
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.CustomTargetType` A
CustomTargetType resource in the Cloud Deploy API.
A CustomTargetType defines a type of custom target
that can be referenced in a Target in order to
facilitate deploying to other systems besides the
supported runtimes.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([custom_target_type, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.UpdateCustomTargetTypeRequest):
request = cloud_deploy.UpdateCustomTargetTypeRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if custom_target_type is not None:
request.custom_target_type = custom_target_type
if update_mask is not None:
request.update_mask = update_mask
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.update_custom_target_type
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("custom_target_type.name", request.custom_target_type.name),)
),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.CustomTargetType,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def delete_custom_target_type(
self,
request: Optional[
Union[cloud_deploy.DeleteCustomTargetTypeRequest, dict]
] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a single CustomTargetType.
.. 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 import deploy_v1
async def sample_delete_custom_target_type():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.DeleteCustomTargetTypeRequest(
name="name_value",
)
# Make the request
operation = client.delete_custom_target_type(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.DeleteCustomTargetTypeRequest, dict]]):
The request object. The request object for ``DeleteCustomTargetType``.
name (:class:`str`):
Required. The name of the ``CustomTargetType`` to
delete. Format must be
``projects/{project_id}/locations/{location_name}/customTargetTypes/{custom_target_type}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
empty messages in your APIs. A typical example is to
use it as the request or the response type of an API
method. For instance:
service Foo {
rpc Bar(google.protobuf.Empty) returns
(google.protobuf.Empty);
}
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.DeleteCustomTargetTypeRequest):
request = cloud_deploy.DeleteCustomTargetTypeRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.delete_custom_target_type
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
empty_pb2.Empty,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def list_releases(
self,
request: Optional[Union[cloud_deploy.ListReleasesRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListReleasesAsyncPager:
r"""Lists Releases in a given project and location.
.. 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 import deploy_v1
async def sample_list_releases():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListReleasesRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_releases(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListReleasesRequest, dict]]):
The request object. The request object for ``ListReleases``.
parent (:class:`str`):
Required. The ``DeliveryPipeline`` which owns this
collection of ``Release`` objects.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListReleasesAsyncPager:
The response object from ListReleases.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListReleasesRequest):
request = cloud_deploy.ListReleasesRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_releases
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListReleasesAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_release(
self,
request: Optional[Union[cloud_deploy.GetReleaseRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.Release:
r"""Gets details of a single Release.
.. 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 import deploy_v1
async def sample_get_release():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetReleaseRequest(
name="name_value",
)
# Make the request
response = await client.get_release(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetReleaseRequest, dict]]):
The request object. The request object for ``GetRelease``.
name (:class:`str`):
Required. Name of the ``Release``. Format must be
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/releases/{release_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.Release:
A Release resource in the Cloud Deploy API.
A Release defines a specific Skaffold configuration
instance that can be deployed.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetReleaseRequest):
request = cloud_deploy.GetReleaseRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_release
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def create_release(
self,
request: Optional[Union[cloud_deploy.CreateReleaseRequest, dict]] = None,
*,
parent: Optional[str] = None,
release: Optional[cloud_deploy.Release] = None,
release_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new Release in a given project and
location.
.. 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 import deploy_v1
async def sample_create_release():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.CreateReleaseRequest(
parent="parent_value",
release_id="release_id_value",
)
# Make the request
operation = client.create_release(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CreateReleaseRequest, dict]]):
The request object. The request object for ``CreateRelease``,
parent (:class:`str`):
Required. The parent collection in which the ``Release``
is created. The format is
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
release (:class:`google.cloud.deploy_v1.types.Release`):
Required. The ``Release`` to create.
This corresponds to the ``release`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
release_id (:class:`str`):
Required. ID of the ``Release``.
This corresponds to the ``release_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.Release` A Release
resource in the Cloud Deploy API.
A Release defines a specific Skaffold configuration
instance that can be deployed.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, release, release_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CreateReleaseRequest):
request = cloud_deploy.CreateReleaseRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if release is not None:
request.release = release
if release_id is not None:
request.release_id = release_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.create_release
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.Release,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def abandon_release(
self,
request: Optional[Union[cloud_deploy.AbandonReleaseRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.AbandonReleaseResponse:
r"""Abandons a Release in the Delivery Pipeline.
.. 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 import deploy_v1
async def sample_abandon_release():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.AbandonReleaseRequest(
name="name_value",
)
# Make the request
response = await client.abandon_release(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.AbandonReleaseRequest, dict]]):
The request object. The request object used by ``AbandonRelease``.
name (:class:`str`):
Required. Name of the Release. Format is
``projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.AbandonReleaseResponse:
The response object for AbandonRelease.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.AbandonReleaseRequest):
request = cloud_deploy.AbandonReleaseRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.abandon_release
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def create_deploy_policy(
self,
request: Optional[Union[cloud_deploy.CreateDeployPolicyRequest, dict]] = None,
*,
parent: Optional[str] = None,
deploy_policy: Optional[cloud_deploy.DeployPolicy] = None,
deploy_policy_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new DeployPolicy in a given project and
location.
.. 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 import deploy_v1
async def sample_create_deploy_policy():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
deploy_policy = deploy_v1.DeployPolicy()
deploy_policy.rules.rollout_restriction.id = "id_value"
deploy_policy.rules.rollout_restriction.time_windows.time_zone = "time_zone_value"
request = deploy_v1.CreateDeployPolicyRequest(
parent="parent_value",
deploy_policy_id="deploy_policy_id_value",
deploy_policy=deploy_policy,
)
# Make the request
operation = client.create_deploy_policy(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CreateDeployPolicyRequest, dict]]):
The request object. The request object for ``CreateDeployPolicy``.
parent (:class:`str`):
Required. The parent collection in which the
``DeployPolicy`` must be created. The format is
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
deploy_policy (:class:`google.cloud.deploy_v1.types.DeployPolicy`):
Required. The ``DeployPolicy`` to create.
This corresponds to the ``deploy_policy`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
deploy_policy_id (:class:`str`):
Required. ID of the ``DeployPolicy``.
This corresponds to the ``deploy_policy_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.DeployPolicy` A
DeployPolicy resource in the Cloud Deploy API.
A DeployPolicy inhibits manual or automation-driven
actions within a Delivery Pipeline or Target.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, deploy_policy, deploy_policy_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CreateDeployPolicyRequest):
request = cloud_deploy.CreateDeployPolicyRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if deploy_policy is not None:
request.deploy_policy = deploy_policy
if deploy_policy_id is not None:
request.deploy_policy_id = deploy_policy_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.create_deploy_policy
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.DeployPolicy,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def update_deploy_policy(
self,
request: Optional[Union[cloud_deploy.UpdateDeployPolicyRequest, dict]] = None,
*,
deploy_policy: Optional[cloud_deploy.DeployPolicy] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates the parameters of a single DeployPolicy.
.. 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 import deploy_v1
async def sample_update_deploy_policy():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
deploy_policy = deploy_v1.DeployPolicy()
deploy_policy.rules.rollout_restriction.id = "id_value"
deploy_policy.rules.rollout_restriction.time_windows.time_zone = "time_zone_value"
request = deploy_v1.UpdateDeployPolicyRequest(
deploy_policy=deploy_policy,
)
# Make the request
operation = client.update_deploy_policy(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.UpdateDeployPolicyRequest, dict]]):
The request object. The request object for ``UpdateDeployPolicy``.
deploy_policy (:class:`google.cloud.deploy_v1.types.DeployPolicy`):
Required. The ``DeployPolicy`` to update.
This corresponds to the ``deploy_policy`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Field mask is used to specify the fields to be
overwritten by the update in the ``DeployPolicy``
resource. The fields specified in the update_mask are
relative to the resource, not the full request. A field
will be overwritten if it's in the mask. If the user
doesn't provide a mask then all fields are overwritten.
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.DeployPolicy` A
DeployPolicy resource in the Cloud Deploy API.
A DeployPolicy inhibits manual or automation-driven
actions within a Delivery Pipeline or Target.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([deploy_policy, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.UpdateDeployPolicyRequest):
request = cloud_deploy.UpdateDeployPolicyRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if deploy_policy is not None:
request.deploy_policy = deploy_policy
if update_mask is not None:
request.update_mask = update_mask
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.update_deploy_policy
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("deploy_policy.name", request.deploy_policy.name),)
),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.DeployPolicy,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def delete_deploy_policy(
self,
request: Optional[Union[cloud_deploy.DeleteDeployPolicyRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a single DeployPolicy.
.. 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 import deploy_v1
async def sample_delete_deploy_policy():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.DeleteDeployPolicyRequest(
name="name_value",
)
# Make the request
operation = client.delete_deploy_policy(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.DeleteDeployPolicyRequest, dict]]):
The request object. The request object for ``DeleteDeployPolicy``.
name (:class:`str`):
Required. The name of the ``DeployPolicy`` to delete.
The format is
``projects/{project_id}/locations/{location_name}/deployPolicies/{deploy_policy_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
empty messages in your APIs. A typical example is to
use it as the request or the response type of an API
method. For instance:
service Foo {
rpc Bar(google.protobuf.Empty) returns
(google.protobuf.Empty);
}
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.DeleteDeployPolicyRequest):
request = cloud_deploy.DeleteDeployPolicyRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.delete_deploy_policy
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
empty_pb2.Empty,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def list_deploy_policies(
self,
request: Optional[Union[cloud_deploy.ListDeployPoliciesRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDeployPoliciesAsyncPager:
r"""Lists DeployPolicies in a given project and location.
.. 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 import deploy_v1
async def sample_list_deploy_policies():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListDeployPoliciesRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_deploy_policies(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListDeployPoliciesRequest, dict]]):
The request object. The request object for ``ListDeployPolicies``.
parent (:class:`str`):
Required. The parent, which owns this collection of
deploy policies. Format must be
``projects/{project_id}/locations/{location_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListDeployPoliciesAsyncPager:
The response object from ListDeployPolicies.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListDeployPoliciesRequest):
request = cloud_deploy.ListDeployPoliciesRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_deploy_policies
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListDeployPoliciesAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_deploy_policy(
self,
request: Optional[Union[cloud_deploy.GetDeployPolicyRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.DeployPolicy:
r"""Gets details of a single DeployPolicy.
.. 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 import deploy_v1
async def sample_get_deploy_policy():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetDeployPolicyRequest(
name="name_value",
)
# Make the request
response = await client.get_deploy_policy(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetDeployPolicyRequest, dict]]):
The request object. The request object for ``GetDeployPolicy``
name (:class:`str`):
Required. Name of the ``DeployPolicy``. Format must be
``projects/{project_id}/locations/{location_name}/deployPolicies/{deploy_policy_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.DeployPolicy:
A DeployPolicy resource in the Cloud Deploy API.
A DeployPolicy inhibits manual or automation-driven
actions within a Delivery Pipeline or Target.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetDeployPolicyRequest):
request = cloud_deploy.GetDeployPolicyRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_deploy_policy
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def approve_rollout(
self,
request: Optional[Union[cloud_deploy.ApproveRolloutRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.ApproveRolloutResponse:
r"""Approves a Rollout.
.. 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 import deploy_v1
async def sample_approve_rollout():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ApproveRolloutRequest(
name="name_value",
approved=True,
)
# Make the request
response = await client.approve_rollout(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ApproveRolloutRequest, dict]]):
The request object. The request object used by ``ApproveRollout``.
name (:class:`str`):
Required. Name of the Rollout. Format is
``projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.ApproveRolloutResponse:
The response object from ApproveRollout.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ApproveRolloutRequest):
request = cloud_deploy.ApproveRolloutRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.approve_rollout
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def advance_rollout(
self,
request: Optional[Union[cloud_deploy.AdvanceRolloutRequest, dict]] = None,
*,
name: Optional[str] = None,
phase_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.AdvanceRolloutResponse:
r"""Advances a Rollout in a given project and location.
.. 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 import deploy_v1
async def sample_advance_rollout():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.AdvanceRolloutRequest(
name="name_value",
phase_id="phase_id_value",
)
# Make the request
response = await client.advance_rollout(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.AdvanceRolloutRequest, dict]]):
The request object. The request object used by ``AdvanceRollout``.
name (:class:`str`):
Required. Name of the Rollout. Format is
``projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
phase_id (:class:`str`):
Required. The phase ID to advance the ``Rollout`` to.
This corresponds to the ``phase_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.AdvanceRolloutResponse:
The response object from AdvanceRollout.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name, phase_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.AdvanceRolloutRequest):
request = cloud_deploy.AdvanceRolloutRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
if phase_id is not None:
request.phase_id = phase_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.advance_rollout
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def cancel_rollout(
self,
request: Optional[Union[cloud_deploy.CancelRolloutRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.CancelRolloutResponse:
r"""Cancels a Rollout in a given project and location.
.. 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 import deploy_v1
async def sample_cancel_rollout():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.CancelRolloutRequest(
name="name_value",
)
# Make the request
response = await client.cancel_rollout(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CancelRolloutRequest, dict]]):
The request object. The request object used by ``CancelRollout``.
name (:class:`str`):
Required. Name of the Rollout. Format is
``projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.CancelRolloutResponse:
The response object from CancelRollout.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CancelRolloutRequest):
request = cloud_deploy.CancelRolloutRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.cancel_rollout
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def list_rollouts(
self,
request: Optional[Union[cloud_deploy.ListRolloutsRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListRolloutsAsyncPager:
r"""Lists Rollouts in a given project and location.
.. 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 import deploy_v1
async def sample_list_rollouts():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListRolloutsRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_rollouts(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListRolloutsRequest, dict]]):
The request object. ListRolloutsRequest is the request object used by
``ListRollouts``.
parent (:class:`str`):
Required. The ``Release`` which owns this collection of
``Rollout`` objects.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListRolloutsAsyncPager:
ListRolloutsResponse is the response object reutrned by
ListRollouts.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListRolloutsRequest):
request = cloud_deploy.ListRolloutsRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_rollouts
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListRolloutsAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_rollout(
self,
request: Optional[Union[cloud_deploy.GetRolloutRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.Rollout:
r"""Gets details of a single Rollout.
.. 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 import deploy_v1
async def sample_get_rollout():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetRolloutRequest(
name="name_value",
)
# Make the request
response = await client.get_rollout(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetRolloutRequest, dict]]):
The request object. GetRolloutRequest is the request object used by
``GetRollout``.
name (:class:`str`):
Required. Name of the ``Rollout``. Format must be
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/releases/{release_name}/rollouts/{rollout_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.Rollout:
A Rollout resource in the Cloud Deploy API.
A Rollout contains information around a specific
deployment to a Target.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetRolloutRequest):
request = cloud_deploy.GetRolloutRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_rollout
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def create_rollout(
self,
request: Optional[Union[cloud_deploy.CreateRolloutRequest, dict]] = None,
*,
parent: Optional[str] = None,
rollout: Optional[cloud_deploy.Rollout] = None,
rollout_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new Rollout in a given project and
location.
.. 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 import deploy_v1
async def sample_create_rollout():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
rollout = deploy_v1.Rollout()
rollout.target_id = "target_id_value"
request = deploy_v1.CreateRolloutRequest(
parent="parent_value",
rollout_id="rollout_id_value",
rollout=rollout,
)
# Make the request
operation = client.create_rollout(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CreateRolloutRequest, dict]]):
The request object. CreateRolloutRequest is the request object used by
``CreateRollout``.
parent (:class:`str`):
Required. The parent collection in which the ``Rollout``
must be created. The format is
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/releases/{release_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
rollout (:class:`google.cloud.deploy_v1.types.Rollout`):
Required. The ``Rollout`` to create.
This corresponds to the ``rollout`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
rollout_id (:class:`str`):
Required. ID of the ``Rollout``.
This corresponds to the ``rollout_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.Rollout` A Rollout
resource in the Cloud Deploy API.
A Rollout contains information around a specific
deployment to a Target.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, rollout, rollout_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CreateRolloutRequest):
request = cloud_deploy.CreateRolloutRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if rollout is not None:
request.rollout = rollout
if rollout_id is not None:
request.rollout_id = rollout_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.create_rollout
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.Rollout,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def ignore_job(
self,
request: Optional[Union[cloud_deploy.IgnoreJobRequest, dict]] = None,
*,
rollout: Optional[str] = None,
phase_id: Optional[str] = None,
job_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.IgnoreJobResponse:
r"""Ignores the specified Job in a Rollout.
.. 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 import deploy_v1
async def sample_ignore_job():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.IgnoreJobRequest(
rollout="rollout_value",
phase_id="phase_id_value",
job_id="job_id_value",
)
# Make the request
response = await client.ignore_job(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.IgnoreJobRequest, dict]]):
The request object. The request object used by ``IgnoreJob``.
rollout (:class:`str`):
Required. Name of the Rollout. Format is
``projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}``.
This corresponds to the ``rollout`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
phase_id (:class:`str`):
Required. The phase ID the Job to
ignore belongs to.
This corresponds to the ``phase_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
job_id (:class:`str`):
Required. The job ID for the Job to
ignore.
This corresponds to the ``job_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.IgnoreJobResponse:
The response object from IgnoreJob.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([rollout, phase_id, job_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.IgnoreJobRequest):
request = cloud_deploy.IgnoreJobRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if rollout is not None:
request.rollout = rollout
if phase_id is not None:
request.phase_id = phase_id
if job_id is not None:
request.job_id = job_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.ignore_job
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("rollout", request.rollout),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def retry_job(
self,
request: Optional[Union[cloud_deploy.RetryJobRequest, dict]] = None,
*,
rollout: Optional[str] = None,
phase_id: Optional[str] = None,
job_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.RetryJobResponse:
r"""Retries the specified Job in a Rollout.
.. 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 import deploy_v1
async def sample_retry_job():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.RetryJobRequest(
rollout="rollout_value",
phase_id="phase_id_value",
job_id="job_id_value",
)
# Make the request
response = await client.retry_job(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.RetryJobRequest, dict]]):
The request object. RetryJobRequest is the request object used by
``RetryJob``.
rollout (:class:`str`):
Required. Name of the Rollout. Format is
``projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}``.
This corresponds to the ``rollout`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
phase_id (:class:`str`):
Required. The phase ID the Job to
retry belongs to.
This corresponds to the ``phase_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
job_id (:class:`str`):
Required. The job ID for the Job to
retry.
This corresponds to the ``job_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.RetryJobResponse:
The response object from 'RetryJob'.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([rollout, phase_id, job_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.RetryJobRequest):
request = cloud_deploy.RetryJobRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if rollout is not None:
request.rollout = rollout
if phase_id is not None:
request.phase_id = phase_id
if job_id is not None:
request.job_id = job_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.retry_job
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("rollout", request.rollout),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def list_job_runs(
self,
request: Optional[Union[cloud_deploy.ListJobRunsRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListJobRunsAsyncPager:
r"""Lists JobRuns in a given project and location.
.. 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 import deploy_v1
async def sample_list_job_runs():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListJobRunsRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_job_runs(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListJobRunsRequest, dict]]):
The request object. ListJobRunsRequest is the request object used by
``ListJobRuns``.
parent (:class:`str`):
Required. The ``Rollout`` which owns this collection of
``JobRun`` objects.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListJobRunsAsyncPager:
ListJobRunsResponse is the response object returned by
ListJobRuns.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListJobRunsRequest):
request = cloud_deploy.ListJobRunsRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_job_runs
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListJobRunsAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_job_run(
self,
request: Optional[Union[cloud_deploy.GetJobRunRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.JobRun:
r"""Gets details of a single JobRun.
.. 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 import deploy_v1
async def sample_get_job_run():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetJobRunRequest(
name="name_value",
)
# Make the request
response = await client.get_job_run(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetJobRunRequest, dict]]):
The request object. GetJobRunRequest is the request object used by
``GetJobRun``.
name (:class:`str`):
Required. Name of the ``JobRun``. Format must be
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/releases/{release_name}/rollouts/{rollout_name}/jobRuns/{job_run_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.JobRun:
A JobRun resource in the Cloud Deploy API.
A JobRun contains information of a single Rollout job
evaluation.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetJobRunRequest):
request = cloud_deploy.GetJobRunRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_job_run
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def terminate_job_run(
self,
request: Optional[Union[cloud_deploy.TerminateJobRunRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.TerminateJobRunResponse:
r"""Terminates a Job Run in a given project and location.
.. 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 import deploy_v1
async def sample_terminate_job_run():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.TerminateJobRunRequest(
name="name_value",
)
# Make the request
response = await client.terminate_job_run(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.TerminateJobRunRequest, dict]]):
The request object. The request object used by ``TerminateJobRun``.
name (:class:`str`):
Required. Name of the ``JobRun``. Format must be
``projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}/jobRuns/{jobRun}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.TerminateJobRunResponse:
The response object from TerminateJobRun.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.TerminateJobRunRequest):
request = cloud_deploy.TerminateJobRunRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.terminate_job_run
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_config(
self,
request: Optional[Union[cloud_deploy.GetConfigRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.Config:
r"""Gets the configuration for a location.
.. 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 import deploy_v1
async def sample_get_config():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetConfigRequest(
name="name_value",
)
# Make the request
response = await client.get_config(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetConfigRequest, dict]]):
The request object. Request to get a configuration.
name (:class:`str`):
Required. Name of requested
configuration.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.Config:
Service-wide configuration.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetConfigRequest):
request = cloud_deploy.GetConfigRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_config
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def create_automation(
self,
request: Optional[Union[cloud_deploy.CreateAutomationRequest, dict]] = None,
*,
parent: Optional[str] = None,
automation: Optional[cloud_deploy.Automation] = None,
automation_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new Automation in a given project and
location.
.. 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 import deploy_v1
async def sample_create_automation():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
automation = deploy_v1.Automation()
automation.service_account = "service_account_value"
automation.rules.promote_release_rule.id = "id_value"
request = deploy_v1.CreateAutomationRequest(
parent="parent_value",
automation_id="automation_id_value",
automation=automation,
)
# Make the request
operation = client.create_automation(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CreateAutomationRequest, dict]]):
The request object. The request object for ``CreateAutomation``.
parent (:class:`str`):
Required. The parent collection in which the
``Automation`` must be created. The format is
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
automation (:class:`google.cloud.deploy_v1.types.Automation`):
Required. The ``Automation`` to create.
This corresponds to the ``automation`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
automation_id (:class:`str`):
Required. ID of the ``Automation``.
This corresponds to the ``automation_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.Automation` An
Automation resource in the Cloud Deploy API.
An Automation enables the automation of manually
driven actions for a Delivery Pipeline, which
includes Release promotion among Targets, Rollout
repair and Rollout deployment strategy advancement.
The intention of Automation is to reduce manual
intervention in the continuous delivery process.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, automation, automation_id])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CreateAutomationRequest):
request = cloud_deploy.CreateAutomationRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if automation is not None:
request.automation = automation
if automation_id is not None:
request.automation_id = automation_id
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.create_automation
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.Automation,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def update_automation(
self,
request: Optional[Union[cloud_deploy.UpdateAutomationRequest, dict]] = None,
*,
automation: Optional[cloud_deploy.Automation] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates the parameters of a single Automation
resource.
.. 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 import deploy_v1
async def sample_update_automation():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
automation = deploy_v1.Automation()
automation.service_account = "service_account_value"
automation.rules.promote_release_rule.id = "id_value"
request = deploy_v1.UpdateAutomationRequest(
automation=automation,
)
# Make the request
operation = client.update_automation(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.UpdateAutomationRequest, dict]]):
The request object. The request object for ``UpdateAutomation``.
automation (:class:`google.cloud.deploy_v1.types.Automation`):
Required. The ``Automation`` to update.
This corresponds to the ``automation`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. Field mask is used to specify the fields to be
overwritten by the update in the ``Automation``
resource. The fields specified in the update_mask are
relative to the resource, not the full request. A field
will be overwritten if it's in the mask. If the user
doesn't provide a mask then all fields are overwritten.
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.deploy_v1.types.Automation` An
Automation resource in the Cloud Deploy API.
An Automation enables the automation of manually
driven actions for a Delivery Pipeline, which
includes Release promotion among Targets, Rollout
repair and Rollout deployment strategy advancement.
The intention of Automation is to reduce manual
intervention in the continuous delivery process.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([automation, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.UpdateAutomationRequest):
request = cloud_deploy.UpdateAutomationRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if automation is not None:
request.automation = automation
if update_mask is not None:
request.update_mask = update_mask
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.update_automation
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("automation.name", request.automation.name),)
),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
cloud_deploy.Automation,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def delete_automation(
self,
request: Optional[Union[cloud_deploy.DeleteAutomationRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a single Automation resource.
.. 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 import deploy_v1
async def sample_delete_automation():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.DeleteAutomationRequest(
name="name_value",
)
# Make the request
operation = client.delete_automation(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.DeleteAutomationRequest, dict]]):
The request object. The request object for ``DeleteAutomation``.
name (:class:`str`):
Required. The name of the ``Automation`` to delete. The
format is
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/automations/{automation_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated
empty messages in your APIs. A typical example is to
use it as the request or the response type of an API
method. For instance:
service Foo {
rpc Bar(google.protobuf.Empty) returns
(google.protobuf.Empty);
}
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.DeleteAutomationRequest):
request = cloud_deploy.DeleteAutomationRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.delete_automation
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# 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,
empty_pb2.Empty,
metadata_type=cloud_deploy.OperationMetadata,
)
# Done; return the response.
return response
[docs] async def get_automation(
self,
request: Optional[Union[cloud_deploy.GetAutomationRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.Automation:
r"""Gets details of a single Automation.
.. 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 import deploy_v1
async def sample_get_automation():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetAutomationRequest(
name="name_value",
)
# Make the request
response = await client.get_automation(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetAutomationRequest, dict]]):
The request object. The request object for ``GetAutomation``
name (:class:`str`):
Required. Name of the ``Automation``. Format must be
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/automations/{automation_name}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.Automation:
An Automation resource in the Cloud Deploy API.
An Automation enables the automation of manually
driven actions for a Delivery Pipeline, which
includes Release promotion among Targets, Rollout
repair and Rollout deployment strategy advancement.
The intention of Automation is to reduce manual
intervention in the continuous delivery process.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetAutomationRequest):
request = cloud_deploy.GetAutomationRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_automation
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def list_automations(
self,
request: Optional[Union[cloud_deploy.ListAutomationsRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListAutomationsAsyncPager:
r"""Lists Automations in a given project and location.
.. 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 import deploy_v1
async def sample_list_automations():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListAutomationsRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_automations(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListAutomationsRequest, dict]]):
The request object. The request object for ``ListAutomations``.
parent (:class:`str`):
Required. The parent ``Delivery Pipeline``, which owns
this collection of automations. Format must be
``projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListAutomationsAsyncPager:
The response object from ListAutomations.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListAutomationsRequest):
request = cloud_deploy.ListAutomationsRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_automations
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListAutomationsAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_automation_run(
self,
request: Optional[Union[cloud_deploy.GetAutomationRunRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.AutomationRun:
r"""Gets details of a single AutomationRun.
.. 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 import deploy_v1
async def sample_get_automation_run():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.GetAutomationRunRequest(
name="name_value",
)
# Make the request
response = await client.get_automation_run(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.GetAutomationRunRequest, dict]]):
The request object. The request object for ``GetAutomationRun``
name (:class:`str`):
Required. Name of the ``AutomationRun``. Format must be
``projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/automationRuns/{automation_run}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.AutomationRun:
An AutomationRun resource in the Cloud Deploy API.
An AutomationRun represents an execution instance of
an automation rule.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.GetAutomationRunRequest):
request = cloud_deploy.GetAutomationRunRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.get_automation_run
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def list_automation_runs(
self,
request: Optional[Union[cloud_deploy.ListAutomationRunsRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListAutomationRunsAsyncPager:
r"""Lists AutomationRuns in a given project and location.
.. 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 import deploy_v1
async def sample_list_automation_runs():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.ListAutomationRunsRequest(
parent="parent_value",
)
# Make the request
page_result = client.list_automation_runs(request=request)
# Handle the response
async for response in page_result:
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.ListAutomationRunsRequest, dict]]):
The request object. The request object for ``ListAutomationRuns``.
parent (:class:`str`):
Required. The parent ``Delivery Pipeline``, which owns
this collection of automationRuns. Format must be
``projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}``.
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.services.cloud_deploy.pagers.ListAutomationRunsAsyncPager:
The response object from ListAutomationRuns.
Iterating over this object will yield results and
resolve additional pages automatically.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.ListAutomationRunsRequest):
request = cloud_deploy.ListAutomationRunsRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.list_automation_runs
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListAutomationRunsAsyncPager(
method=rpc,
request=request,
response=response,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def cancel_automation_run(
self,
request: Optional[Union[cloud_deploy.CancelAutomationRunRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_deploy.CancelAutomationRunResponse:
r"""Cancels an AutomationRun. The ``state`` of the ``AutomationRun``
after cancelling is ``CANCELLED``. ``CancelAutomationRun`` can
be called on AutomationRun in the state ``IN_PROGRESS`` and
``PENDING``; AutomationRun in a different state returns an
``FAILED_PRECONDITION`` error.
.. 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 import deploy_v1
async def sample_cancel_automation_run():
# Create a client
client = deploy_v1.CloudDeployAsyncClient()
# Initialize request argument(s)
request = deploy_v1.CancelAutomationRunRequest(
name="name_value",
)
# Make the request
response = await client.cancel_automation_run(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.deploy_v1.types.CancelAutomationRunRequest, dict]]):
The request object. The request object used by ``CancelAutomationRun``.
name (:class:`str`):
Required. Name of the ``AutomationRun``. Format is
``projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/automationRuns/{automation_run}``.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.cloud.deploy_v1.types.CancelAutomationRunResponse:
The response object from CancelAutomationRun.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, cloud_deploy.CancelAutomationRunRequest):
request = cloud_deploy.CancelAutomationRunRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.cancel_automation_run
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def list_operations(
self,
request: Optional[operations_pb2.ListOperationsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.ListOperationsResponse:
r"""Lists operations that match the specified filter in the request.
Args:
request (:class:`~.operations_pb2.ListOperationsRequest`):
The request object. Request message for
`ListOperations` method.
retry (google.api_core.retry_async.AsyncRetry): 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:
~.operations_pb2.ListOperationsResponse:
Response message for ``ListOperations`` method.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.ListOperationsRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.list_operations]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_operation(
self,
request: Optional[operations_pb2.GetOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.
Args:
request (:class:`~.operations_pb2.GetOperationRequest`):
The request object. Request message for
`GetOperation` method.
retry (google.api_core.retry_async.AsyncRetry): 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:
~.operations_pb2.Operation:
An ``Operation`` object.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.GetOperationRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def delete_operation(
self,
request: Optional[operations_pb2.DeleteOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes a long-running operation.
This method indicates that the client is no longer interested
in the operation result. It does not cancel the operation.
If the server doesn't support this method, it returns
`google.rpc.Code.UNIMPLEMENTED`.
Args:
request (:class:`~.operations_pb2.DeleteOperationRequest`):
The request object. Request message for
`DeleteOperation` method.
retry (google.api_core.retry_async.AsyncRetry): 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:
None
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.DeleteOperationRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.delete_operation]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
[docs] async def cancel_operation(
self,
request: Optional[operations_pb2.CancelOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Starts asynchronous cancellation on a long-running operation.
The server makes a best effort to cancel the operation, but success
is not guaranteed. If the server doesn't support this method, it returns
`google.rpc.Code.UNIMPLEMENTED`.
Args:
request (:class:`~.operations_pb2.CancelOperationRequest`):
The request object. Request message for
`CancelOperation` method.
retry (google.api_core.retry_async.AsyncRetry): 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:
None
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.CancelOperationRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
[docs] async def set_iam_policy(
self,
request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Sets the IAM access control policy on the specified function.
Replaces any existing policy.
Args:
request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
The request object. Request message for `SetIamPolicy`
method.
retry (google.api_core.retry_async.AsyncRetry): 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:
~.policy_pb2.Policy:
Defines an Identity and Access Management (IAM) policy.
It is used to specify access control policies for Cloud
Platform resources.
A ``Policy`` is a collection of ``bindings``. A
``binding`` binds one or more ``members`` to a single
``role``. Members can be user accounts, service
accounts, Google groups, and domains (such as G Suite).
A ``role`` is a named list of permissions (defined by
IAM or configured by users). A ``binding`` can
optionally specify a ``condition``, which is a logic
expression that further constrains the role binding
based on attributes about the request and/or target
resource.
**JSON Example**
::
{
"bindings": [
{
"role": "roles/resourcemanager.organizationAdmin",
"members": [
"user:mike@example.com",
"group:admins@example.com",
"domain:google.com",
"serviceAccount:my-project-id@appspot.gserviceaccount.com"
]
},
{
"role": "roles/resourcemanager.organizationViewer",
"members": ["user:eve@example.com"],
"condition": {
"title": "expirable access",
"description": "Does not grant access after Sep 2020",
"expression": "request.time <
timestamp('2020-10-01T00:00:00.000Z')",
}
}
]
}
**YAML Example**
::
bindings:
- members:
- user:mike@example.com
- group:admins@example.com
- domain:google.com
- serviceAccount:my-project-id@appspot.gserviceaccount.com
role: roles/resourcemanager.organizationAdmin
- members:
- user:eve@example.com
role: roles/resourcemanager.organizationViewer
condition:
title: expirable access
description: Does not grant access after Sep 2020
expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
For a description of IAM and its features, see the `IAM
developer's
guide <https://cloud.google.com/iam/docs>`__.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = iam_policy_pb2.SetIamPolicyRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.set_iam_policy]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_iam_policy(
self,
request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Gets the IAM access control policy for a function.
Returns an empty policy if the function exists and does not have a
policy set.
Args:
request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
The request object. Request message for `GetIamPolicy`
method.
retry (google.api_core.retry_async.AsyncRetry): 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:
~.policy_pb2.Policy:
Defines an Identity and Access Management (IAM) policy.
It is used to specify access control policies for Cloud
Platform resources.
A ``Policy`` is a collection of ``bindings``. A
``binding`` binds one or more ``members`` to a single
``role``. Members can be user accounts, service
accounts, Google groups, and domains (such as G Suite).
A ``role`` is a named list of permissions (defined by
IAM or configured by users). A ``binding`` can
optionally specify a ``condition``, which is a logic
expression that further constrains the role binding
based on attributes about the request and/or target
resource.
**JSON Example**
::
{
"bindings": [
{
"role": "roles/resourcemanager.organizationAdmin",
"members": [
"user:mike@example.com",
"group:admins@example.com",
"domain:google.com",
"serviceAccount:my-project-id@appspot.gserviceaccount.com"
]
},
{
"role": "roles/resourcemanager.organizationViewer",
"members": ["user:eve@example.com"],
"condition": {
"title": "expirable access",
"description": "Does not grant access after Sep 2020",
"expression": "request.time <
timestamp('2020-10-01T00:00:00.000Z')",
}
}
]
}
**YAML Example**
::
bindings:
- members:
- user:mike@example.com
- group:admins@example.com
- domain:google.com
- serviceAccount:my-project-id@appspot.gserviceaccount.com
role: roles/resourcemanager.organizationAdmin
- members:
- user:eve@example.com
role: roles/resourcemanager.organizationViewer
condition:
title: expirable access
description: Does not grant access after Sep 2020
expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
For a description of IAM and its features, see the `IAM
developer's
guide <https://cloud.google.com/iam/docs>`__.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = iam_policy_pb2.GetIamPolicyRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.get_iam_policy]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def test_iam_permissions(
self,
request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> iam_policy_pb2.TestIamPermissionsResponse:
r"""Tests the specified IAM permissions against the IAM access control
policy for a function.
If the function does not exist, this will return an empty set
of permissions, not a NOT_FOUND error.
Args:
request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
The request object. Request message for
`TestIamPermissions` method.
retry (google.api_core.retry_async.AsyncRetry): 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:
~.iam_policy_pb2.TestIamPermissionsResponse:
Response message for ``TestIamPermissions`` method.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = iam_policy_pb2.TestIamPermissionsRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[
self._client._transport.test_iam_permissions
]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def get_location(
self,
request: Optional[locations_pb2.GetLocationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> locations_pb2.Location:
r"""Gets information about a location.
Args:
request (:class:`~.location_pb2.GetLocationRequest`):
The request object. Request message for
`GetLocation` method.
retry (google.api_core.retry_async.AsyncRetry): 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:
~.location_pb2.Location:
Location object.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = locations_pb2.GetLocationRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.get_location]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
[docs] async def list_locations(
self,
request: Optional[locations_pb2.ListLocationsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> locations_pb2.ListLocationsResponse:
r"""Lists information about the supported locations for this service.
Args:
request (:class:`~.location_pb2.ListLocationsRequest`):
The request object. Request message for
`ListLocations` method.
retry (google.api_core.retry_async.AsyncRetry): 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:
~.location_pb2.ListLocationsResponse:
Response message for ``ListLocations`` method.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = locations_pb2.ListLocationsRequest(**request)
# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self.transport._wrapped_methods[self._client._transport.list_locations]
# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)
# Validate the universe domain.
self._client._validate_universe_domain()
# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)
# Done; return the response.
return response
async def __aenter__(self) -> "CloudDeployAsyncClient":
return self
async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)
__all__ = ("CloudDeployAsyncClient",)