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.clouddms_v1.services.data_migration_service.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 os
import re
from typing import (
    Callable,
    Dict,
    Mapping,
    MutableMapping,
    MutableSequence,
    Optional,
    Sequence,
    Tuple,
    Type,
    Union,
    cast,
)
import warnings

from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.auth import credentials as ga_credentials  # type: ignore
from google.auth.exceptions import MutualTLSChannelError  # type: ignore
from google.auth.transport import mtls  # type: ignore
from google.auth.transport.grpc import SslCredentials  # type: ignore
from google.oauth2 import service_account  # type: ignore

from google.cloud.clouddms_v1 import gapic_version as package_version

try:
    OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
except AttributeError:  # pragma: NO COVER
    OptionalRetry = Union[retries.Retry, 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 duration_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.rpc import status_pb2  # type: ignore

from google.cloud.clouddms_v1.services.data_migration_service import pagers
from google.cloud.clouddms_v1.types import (
    clouddms,
    clouddms_resources,
    conversionworkspace_resources,
)

from .transports.base import DEFAULT_CLIENT_INFO, DataMigrationServiceTransport
from .transports.grpc import DataMigrationServiceGrpcTransport
from .transports.grpc_asyncio import DataMigrationServiceGrpcAsyncIOTransport


class DataMigrationServiceClientMeta(type):
    """Metaclass for the DataMigrationService client.

    This provides class-level methods for building and retrieving
    support objects (e.g. transport) without polluting the client instance
    objects.
    """

    _transport_registry = (
        OrderedDict()
    )  # type: Dict[str, Type[DataMigrationServiceTransport]]
    _transport_registry["grpc"] = DataMigrationServiceGrpcTransport
    _transport_registry["grpc_asyncio"] = DataMigrationServiceGrpcAsyncIOTransport

    def get_transport_class(
        cls,
        label: Optional[str] = None,
    ) -> Type[DataMigrationServiceTransport]:
        """Returns an appropriate transport class.

        Args:
            label: The name of the desired transport. If none is
                provided, then the first transport in the registry is used.

        Returns:
            The transport class to use.
        """
        # If a specific transport is requested, return that one.
        if label:
            return cls._transport_registry[label]

        # No transport is requested; return the default (that is, the first one
        # in the dictionary).
        return next(iter(cls._transport_registry.values()))


[docs]class DataMigrationServiceClient(metaclass=DataMigrationServiceClientMeta): """Database Migration service""" @staticmethod def _get_default_mtls_endpoint(api_endpoint): """Converts api endpoint to mTLS endpoint. Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: api_endpoint (Optional[str]): the api endpoint to convert. Returns: str: converted mTLS api endpoint. """ if not api_endpoint: return api_endpoint mtls_endpoint_re = re.compile( r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?" ) m = mtls_endpoint_re.match(api_endpoint) name, mtls, sandbox, googledomain = m.groups() if mtls or not googledomain: return api_endpoint if sandbox: return api_endpoint.replace( "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" ) return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. DEFAULT_ENDPOINT = "datamigration.googleapis.com" DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore DEFAULT_ENDPOINT ) _DEFAULT_ENDPOINT_TEMPLATE = "datamigration.{UNIVERSE_DOMAIN}" _DEFAULT_UNIVERSE = "googleapis.com"
[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: DataMigrationServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_info(info) kwargs["credentials"] = credentials return cls(*args, **kwargs)
[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: DataMigrationServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials return cls(*args, **kwargs)
from_service_account_json = from_service_account_file @property def transport(self) -> DataMigrationServiceTransport: """Returns the transport used by the client instance. Returns: DataMigrationServiceTransport: The transport used by the client instance. """ return self._transport
[docs] @staticmethod def connection_profile_path( project: str, location: str, connection_profile: str, ) -> str: """Returns a fully-qualified connection_profile string.""" return "projects/{project}/locations/{location}/connectionProfiles/{connection_profile}".format( project=project, location=location, connection_profile=connection_profile, )
[docs] @staticmethod def parse_connection_profile_path(path: str) -> Dict[str, str]: """Parses a connection_profile path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/connectionProfiles/(?P<connection_profile>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def conversion_workspace_path( project: str, location: str, conversion_workspace: str, ) -> str: """Returns a fully-qualified conversion_workspace string.""" return "projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}".format( project=project, location=location, conversion_workspace=conversion_workspace, )
[docs] @staticmethod def parse_conversion_workspace_path(path: str) -> Dict[str, str]: """Parses a conversion_workspace path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/conversionWorkspaces/(?P<conversion_workspace>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def mapping_rule_path( project: str, location: str, conversion_workspace: str, mapping_rule: str, ) -> str: """Returns a fully-qualified mapping_rule string.""" return "projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}/mappingRules/{mapping_rule}".format( project=project, location=location, conversion_workspace=conversion_workspace, mapping_rule=mapping_rule, )
[docs] @staticmethod def parse_mapping_rule_path(path: str) -> Dict[str, str]: """Parses a mapping_rule path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/conversionWorkspaces/(?P<conversion_workspace>.+?)/mappingRules/(?P<mapping_rule>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def migration_job_path( project: str, location: str, migration_job: str, ) -> str: """Returns a fully-qualified migration_job string.""" return "projects/{project}/locations/{location}/migrationJobs/{migration_job}".format( project=project, location=location, migration_job=migration_job, )
[docs] @staticmethod def parse_migration_job_path(path: str) -> Dict[str, str]: """Parses a migration_job path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/migrationJobs/(?P<migration_job>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def networks_path( project: str, network: str, ) -> str: """Returns a fully-qualified networks string.""" return "projects/{project}/global/networks/{network}".format( project=project, network=network, )
[docs] @staticmethod def parse_networks_path(path: str) -> Dict[str, str]: """Parses a networks path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/global/networks/(?P<network>.+?)$", path ) return m.groupdict() if m else {}
[docs] @staticmethod def private_connection_path( project: str, location: str, private_connection: str, ) -> str: """Returns a fully-qualified private_connection string.""" return "projects/{project}/locations/{location}/privateConnections/{private_connection}".format( project=project, location=location, private_connection=private_connection, )
[docs] @staticmethod def parse_private_connection_path(path: str) -> Dict[str, str]: """Parses a private_connection path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/privateConnections/(?P<private_connection>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def common_billing_account_path( billing_account: str, ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, )
[docs] @staticmethod def parse_common_billing_account_path(path: str) -> Dict[str, str]: """Parse a billing_account path into its component segments.""" m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path) return m.groupdict() if m else {}
[docs] @staticmethod def common_folder_path( folder: str, ) -> str: """Returns a fully-qualified folder string.""" return "folders/{folder}".format( folder=folder, )
[docs] @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: """Parse a folder path into its component segments.""" m = re.match(r"^folders/(?P<folder>.+?)$", path) return m.groupdict() if m else {}
[docs] @staticmethod def common_organization_path( organization: str, ) -> str: """Returns a fully-qualified organization string.""" return "organizations/{organization}".format( organization=organization, )
[docs] @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: """Parse a organization path into its component segments.""" m = re.match(r"^organizations/(?P<organization>.+?)$", path) return m.groupdict() if m else {}
[docs] @staticmethod def common_project_path( project: str, ) -> str: """Returns a fully-qualified project string.""" return "projects/{project}".format( project=project, )
[docs] @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: """Parse a project path into its component segments.""" m = re.match(r"^projects/(?P<project>.+?)$", path) return m.groupdict() if m else {}
[docs] @staticmethod def common_location_path( project: str, location: str, ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, )
[docs] @staticmethod def parse_common_location_path(path: str) -> Dict[str, str]: """Parse a location path into its component segments.""" m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path) return m.groupdict() if m else {}
[docs] @classmethod def get_mtls_endpoint_and_cert_source( cls, client_options: Optional[client_options_lib.ClientOptions] = None ): """Deprecated. 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. """ warnings.warn( "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", DeprecationWarning, ) if client_options is None: client_options = client_options_lib.ClientOptions() use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") if use_client_cert not in ("true", "false"): raise ValueError( "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" ) if use_mtls_endpoint not in ("auto", "never", "always"): raise MutualTLSChannelError( "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" ) # Figure out the client cert source to use. client_cert_source = None if use_client_cert == "true": if client_options.client_cert_source: client_cert_source = client_options.client_cert_source elif mtls.has_default_client_cert_source(): client_cert_source = mtls.default_client_cert_source() # Figure out which api endpoint to use. if client_options.api_endpoint is not None: api_endpoint = client_options.api_endpoint elif use_mtls_endpoint == "always" or ( use_mtls_endpoint == "auto" and client_cert_source ): api_endpoint = cls.DEFAULT_MTLS_ENDPOINT else: api_endpoint = cls.DEFAULT_ENDPOINT return api_endpoint, client_cert_source
@staticmethod def _read_environment_variables(): """Returns the environment variables used by the client. Returns: Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. Raises: ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not any of ["true", "false"]. google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT is not any of ["auto", "never", "always"]. """ use_client_cert = os.getenv( "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false" ).lower() use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") if use_client_cert not in ("true", "false"): raise ValueError( "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" ) if use_mtls_endpoint not in ("auto", "never", "always"): raise MutualTLSChannelError( "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" ) return use_client_cert == "true", use_mtls_endpoint, universe_domain_env @staticmethod def _get_client_cert_source(provided_cert_source, use_cert_flag): """Return the client cert source to be used by the client. Args: provided_cert_source (bytes): The client certificate source provided. use_cert_flag (bool): A flag indicating whether to use the client certificate. Returns: bytes or None: The client cert source to be used by the client. """ client_cert_source = None if use_cert_flag: if provided_cert_source: client_cert_source = provided_cert_source elif mtls.has_default_client_cert_source(): client_cert_source = mtls.default_client_cert_source() return client_cert_source @staticmethod def _get_api_endpoint( api_override, client_cert_source, universe_domain, use_mtls_endpoint ): """Return the API endpoint used by the client. Args: api_override (str): The API endpoint override. If specified, this is always the return value of this function and the other arguments are not used. client_cert_source (bytes): The client certificate source used by the client. universe_domain (str): The universe domain used by the client. use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. Possible values are "always", "auto", or "never". Returns: str: The API endpoint to be used by the client. """ if api_override is not None: api_endpoint = api_override elif use_mtls_endpoint == "always" or ( use_mtls_endpoint == "auto" and client_cert_source ): _default_universe = DataMigrationServiceClient._DEFAULT_UNIVERSE if universe_domain != _default_universe: raise MutualTLSChannelError( f"mTLS is not supported in any universe other than {_default_universe}." ) api_endpoint = DataMigrationServiceClient.DEFAULT_MTLS_ENDPOINT else: api_endpoint = DataMigrationServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format( UNIVERSE_DOMAIN=universe_domain ) return api_endpoint @staticmethod def _get_universe_domain( client_universe_domain: Optional[str], universe_domain_env: Optional[str] ) -> str: """Return the universe domain used by the client. Args: client_universe_domain (Optional[str]): The universe domain configured via the client options. universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. Returns: str: The universe domain to be used by the client. Raises: ValueError: If the universe domain is an empty string. """ universe_domain = DataMigrationServiceClient._DEFAULT_UNIVERSE if client_universe_domain is not None: universe_domain = client_universe_domain elif universe_domain_env is not None: universe_domain = universe_domain_env if len(universe_domain.strip()) == 0: raise ValueError("Universe Domain cannot be an empty string.") return universe_domain def _validate_universe_domain(self): """Validates client's and credentials' universe domains are consistent. Returns: bool: True iff the configured universe domain is valid. Raises: ValueError: If the configured universe domain is not valid. """ # NOTE (b/349488459): universe validation is disabled until further notice. return True @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._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._universe_domain def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, transport: Optional[ Union[ str, DataMigrationServiceTransport, Callable[..., DataMigrationServiceTransport], ] ] = None, client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the data migration service 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,DataMigrationServiceTransport,Callable[..., DataMigrationServiceTransport]]]): The transport to use, or a Callable that constructs and returns a new transport. If a Callable is given, it will be called with the same set of initialization arguments as used in the DataMigrationServiceTransport 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 the ``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_options = client_options if isinstance(self._client_options, dict): self._client_options = client_options_lib.from_dict(self._client_options) if self._client_options is None: self._client_options = client_options_lib.ClientOptions() self._client_options = cast( client_options_lib.ClientOptions, self._client_options ) universe_domain_opt = getattr(self._client_options, "universe_domain", None) ( self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env, ) = DataMigrationServiceClient._read_environment_variables() self._client_cert_source = DataMigrationServiceClient._get_client_cert_source( self._client_options.client_cert_source, self._use_client_cert ) self._universe_domain = DataMigrationServiceClient._get_universe_domain( universe_domain_opt, self._universe_domain_env ) self._api_endpoint = None # updated below, depending on `transport` # Initialize the universe domain validation. self._is_universe_domain_valid = False api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( "client_options.api_key and credentials are mutually exclusive" ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. transport_provided = isinstance(transport, DataMigrationServiceTransport) if transport_provided: # transport is a DataMigrationServiceTransport instance. if credentials or self._client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." ) if self._client_options.scopes: raise ValueError( "When providing a transport instance, provide its scopes " "directly." ) self._transport = cast(DataMigrationServiceTransport, transport) self._api_endpoint = self._transport.host self._api_endpoint = ( self._api_endpoint or DataMigrationServiceClient._get_api_endpoint( self._client_options.api_endpoint, self._client_cert_source, self._universe_domain, self._use_mtls_endpoint, ) ) if not transport_provided: import google.auth._default # type: ignore if api_key_value and hasattr( google.auth._default, "get_api_key_credentials" ): credentials = google.auth._default.get_api_key_credentials( api_key_value ) transport_init: Union[ Type[DataMigrationServiceTransport], Callable[..., DataMigrationServiceTransport], ] = ( DataMigrationServiceClient.get_transport_class(transport) if isinstance(transport, str) or transport is None else cast(Callable[..., DataMigrationServiceTransport], transport) ) # initialize with the provided callable or the passed in class self._transport = transport_init( credentials=credentials, credentials_file=self._client_options.credentials_file, host=self._api_endpoint, scopes=self._client_options.scopes, client_cert_source_for_mtls=self._client_cert_source, quota_project_id=self._client_options.quota_project_id, client_info=client_info, always_use_jwt_access=True, api_audience=self._client_options.api_audience, )
[docs] def list_migration_jobs( self, request: Optional[Union[clouddms.ListMigrationJobsRequest, 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.ListMigrationJobsPager: r"""Lists migration jobs 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 clouddms_v1 def sample_list_migration_jobs(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ListMigrationJobsRequest( parent="parent_value", ) # Make the request page_result = client.list_migration_jobs(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.clouddms_v1.types.ListMigrationJobsRequest, dict]): The request object. Retrieves a list of all migration jobs in a given project and location. parent (str): Required. The parent which owns this collection of migrationJobs. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.services.data_migration_service.pagers.ListMigrationJobsPager: Response message for 'ListMigrationJobs' request. 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, clouddms.ListMigrationJobsRequest): request = clouddms.ListMigrationJobsRequest(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._transport._wrapped_methods[self._transport.list_migration_jobs] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListMigrationJobsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_migration_job( self, request: Optional[Union[clouddms.GetMigrationJobRequest, 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]] = (), ) -> clouddms_resources.MigrationJob: r"""Gets details of a single migration job. .. 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 clouddms_v1 def sample_get_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.GetMigrationJobRequest( name="name_value", ) # Make the request response = client.get_migration_job(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.GetMigrationJobRequest, dict]): The request object. Request message for 'GetMigrationJob' request. name (str): Required. Name of the migration job resource to get. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.MigrationJob: Represents a Database Migration Service migration job object. """ # 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, clouddms.GetMigrationJobRequest): request = clouddms.GetMigrationJobRequest(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._transport._wrapped_methods[self._transport.get_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def create_migration_job( self, request: Optional[Union[clouddms.CreateMigrationJobRequest, dict]] = None, *, parent: Optional[str] = None, migration_job: Optional[clouddms_resources.MigrationJob] = None, migration_job_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a new migration job 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 clouddms_v1 def sample_create_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) migration_job = clouddms_v1.MigrationJob() migration_job.reverse_ssh_connectivity.vm_ip = "vm_ip_value" migration_job.reverse_ssh_connectivity.vm_port = 775 migration_job.type_ = "CONTINUOUS" migration_job.source = "source_value" migration_job.destination = "destination_value" request = clouddms_v1.CreateMigrationJobRequest( parent="parent_value", migration_job_id="migration_job_id_value", migration_job=migration_job, ) # Make the request operation = client.create_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.CreateMigrationJobRequest, dict]): The request object. Request message to create a new Database Migration Service migration job in the specified project and region. parent (str): Required. The parent which owns this collection of migration jobs. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. migration_job (google.cloud.clouddms_v1.types.MigrationJob): Required. Represents a `migration job <https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.migrationJobs>`__ object. This corresponds to the ``migration_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. migration_job_id (str): Required. The ID of the instance to create. This corresponds to the ``migration_job_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # 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, migration_job, migration_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, clouddms.CreateMigrationJobRequest): request = clouddms.CreateMigrationJobRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if migration_job is not None: request.migration_job = migration_job if migration_job_id is not None: request.migration_job_id = migration_job_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def update_migration_job( self, request: Optional[Union[clouddms.UpdateMigrationJobRequest, dict]] = None, *, migration_job: Optional[clouddms_resources.MigrationJob] = 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.Operation: r"""Updates the parameters of a single migration job. .. 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 clouddms_v1 def sample_update_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) migration_job = clouddms_v1.MigrationJob() migration_job.reverse_ssh_connectivity.vm_ip = "vm_ip_value" migration_job.reverse_ssh_connectivity.vm_port = 775 migration_job.type_ = "CONTINUOUS" migration_job.source = "source_value" migration_job.destination = "destination_value" request = clouddms_v1.UpdateMigrationJobRequest( migration_job=migration_job, ) # Make the request operation = client.update_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.UpdateMigrationJobRequest, dict]): The request object. Request message for 'UpdateMigrationJob' request. migration_job (google.cloud.clouddms_v1.types.MigrationJob): Required. The migration job parameters to update. This corresponds to the ``migration_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): Required. Field mask is used to specify the fields to be overwritten by the update in the conversion workspace resource. 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # 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([migration_job, 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, clouddms.UpdateMigrationJobRequest): request = clouddms.UpdateMigrationJobRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if migration_job is not None: request.migration_job = migration_job 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._transport._wrapped_methods[self._transport.update_migration_job] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migration_job.name", request.migration_job.name),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_migration_job( self, request: Optional[Union[clouddms.DeleteMigrationJobRequest, 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.Operation: r"""Deletes a single migration job. .. 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 clouddms_v1 def sample_delete_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.DeleteMigrationJobRequest( name="name_value", ) # Make the request operation = client.delete_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.DeleteMigrationJobRequest, dict]): The request object. Request message for 'DeleteMigrationJob' request. name (str): Required. Name of the migration job resource to delete. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: 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, clouddms.DeleteMigrationJobRequest): request = clouddms.DeleteMigrationJobRequest(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._transport._wrapped_methods[self._transport.delete_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, empty_pb2.Empty, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def start_migration_job( self, request: Optional[Union[clouddms.StartMigrationJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Start an already created migration job. .. 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 clouddms_v1 def sample_start_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.StartMigrationJobRequest( ) # Make the request operation = client.start_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.StartMigrationJobRequest, dict]): The request object. Request message for 'StartMigrationJob' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # Create or coerce a protobuf request object. # - 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, clouddms.StartMigrationJobRequest): request = clouddms.StartMigrationJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.start_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def stop_migration_job( self, request: Optional[Union[clouddms.StopMigrationJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Stops a running migration job. .. 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 clouddms_v1 def sample_stop_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.StopMigrationJobRequest( ) # Make the request operation = client.stop_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.StopMigrationJobRequest, dict]): The request object. Request message for 'StopMigrationJob' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # Create or coerce a protobuf request object. # - 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, clouddms.StopMigrationJobRequest): request = clouddms.StopMigrationJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.stop_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def resume_migration_job( self, request: Optional[Union[clouddms.ResumeMigrationJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Resume a migration job that is currently stopped and is resumable (was stopped during CDC phase). .. 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 clouddms_v1 def sample_resume_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ResumeMigrationJobRequest( ) # Make the request operation = client.resume_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.ResumeMigrationJobRequest, dict]): The request object. Request message for 'ResumeMigrationJob' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # Create or coerce a protobuf request object. # - 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, clouddms.ResumeMigrationJobRequest): request = clouddms.ResumeMigrationJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.resume_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def promote_migration_job( self, request: Optional[Union[clouddms.PromoteMigrationJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Promote a migration job, stopping replication to the destination and promoting the destination to be a standalone database. .. 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 clouddms_v1 def sample_promote_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.PromoteMigrationJobRequest( ) # Make the request operation = client.promote_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.PromoteMigrationJobRequest, dict]): The request object. Request message for 'PromoteMigrationJob' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # Create or coerce a protobuf request object. # - 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, clouddms.PromoteMigrationJobRequest): request = clouddms.PromoteMigrationJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.promote_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def verify_migration_job( self, request: Optional[Union[clouddms.VerifyMigrationJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Verify a migration job, making sure the destination can reach the source and that all configuration and prerequisites are met. .. 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 clouddms_v1 def sample_verify_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.VerifyMigrationJobRequest( ) # Make the request operation = client.verify_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.VerifyMigrationJobRequest, dict]): The request object. Request message for 'VerifyMigrationJob' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # Create or coerce a protobuf request object. # - 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, clouddms.VerifyMigrationJobRequest): request = clouddms.VerifyMigrationJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.verify_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def restart_migration_job( self, request: Optional[Union[clouddms.RestartMigrationJobRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Restart a stopped or failed migration job, resetting the destination instance to its original state and starting the migration process from scratch. .. 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 clouddms_v1 def sample_restart_migration_job(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.RestartMigrationJobRequest( ) # Make the request operation = client.restart_migration_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.RestartMigrationJobRequest, dict]): The request object. Request message for 'RestartMigrationJob' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.MigrationJob` Represents a Database Migration Service migration job object. """ # Create or coerce a protobuf request object. # - 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, clouddms.RestartMigrationJobRequest): request = clouddms.RestartMigrationJobRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.restart_migration_job] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.MigrationJob, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def generate_ssh_script( self, request: Optional[Union[clouddms.GenerateSshScriptRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> clouddms.SshScript: r"""Generate a SSH configuration script to configure the reverse SSH connectivity. .. 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 clouddms_v1 def sample_generate_ssh_script(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) vm_creation_config = clouddms_v1.VmCreationConfig() vm_creation_config.vm_machine_type = "vm_machine_type_value" request = clouddms_v1.GenerateSshScriptRequest( vm_creation_config=vm_creation_config, vm="vm_value", ) # Make the request response = client.generate_ssh_script(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.GenerateSshScriptRequest, dict]): The request object. Request message for 'GenerateSshScript' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.SshScript: Response message for 'GenerateSshScript' request. """ # Create or coerce a protobuf request object. # - 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, clouddms.GenerateSshScriptRequest): request = clouddms.GenerateSshScriptRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.generate_ssh_script] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migration_job", request.migration_job),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def generate_tcp_proxy_script( self, request: Optional[Union[clouddms.GenerateTcpProxyScriptRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> clouddms.TcpProxyScript: r"""Generate a TCP Proxy configuration script to configure a cloud-hosted VM running a TCP Proxy. .. 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 clouddms_v1 def sample_generate_tcp_proxy_script(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.GenerateTcpProxyScriptRequest( vm_name="vm_name_value", vm_machine_type="vm_machine_type_value", vm_subnet="vm_subnet_value", ) # Make the request response = client.generate_tcp_proxy_script(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.GenerateTcpProxyScriptRequest, dict]): The request object. Request message for 'GenerateTcpProxyScript' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.TcpProxyScript: Response message for 'GenerateTcpProxyScript' request. """ # Create or coerce a protobuf request object. # - 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, clouddms.GenerateTcpProxyScriptRequest): request = clouddms.GenerateTcpProxyScriptRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.generate_tcp_proxy_script ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migration_job", request.migration_job),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def list_connection_profiles( self, request: Optional[Union[clouddms.ListConnectionProfilesRequest, 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.ListConnectionProfilesPager: r"""Retrieves a list of all connection profiles 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 clouddms_v1 def sample_list_connection_profiles(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ListConnectionProfilesRequest( parent="parent_value", ) # Make the request page_result = client.list_connection_profiles(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.clouddms_v1.types.ListConnectionProfilesRequest, dict]): The request object. Request message for 'ListConnectionProfiles' request. parent (str): Required. The parent which owns this collection of connection profiles. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.services.data_migration_service.pagers.ListConnectionProfilesPager: Response message for 'ListConnectionProfiles' request. 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, clouddms.ListConnectionProfilesRequest): request = clouddms.ListConnectionProfilesRequest(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._transport._wrapped_methods[self._transport.list_connection_profiles] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListConnectionProfilesPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_connection_profile( self, request: Optional[Union[clouddms.GetConnectionProfileRequest, 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]] = (), ) -> clouddms_resources.ConnectionProfile: r"""Gets details of a single connection profile. .. 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 clouddms_v1 def sample_get_connection_profile(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.GetConnectionProfileRequest( name="name_value", ) # Make the request response = client.get_connection_profile(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.GetConnectionProfileRequest, dict]): The request object. Request message for 'GetConnectionProfile' request. name (str): Required. Name of the connection profile resource to get. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.ConnectionProfile: A connection profile definition. """ # 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, clouddms.GetConnectionProfileRequest): request = clouddms.GetConnectionProfileRequest(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._transport._wrapped_methods[self._transport.get_connection_profile] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def create_connection_profile( self, request: Optional[Union[clouddms.CreateConnectionProfileRequest, dict]] = None, *, parent: Optional[str] = None, connection_profile: Optional[clouddms_resources.ConnectionProfile] = None, connection_profile_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a new connection profile 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 clouddms_v1 def sample_create_connection_profile(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) connection_profile = clouddms_v1.ConnectionProfile() connection_profile.mysql.host = "host_value" connection_profile.mysql.port = 453 connection_profile.mysql.username = "username_value" connection_profile.mysql.password = "password_value" request = clouddms_v1.CreateConnectionProfileRequest( parent="parent_value", connection_profile_id="connection_profile_id_value", connection_profile=connection_profile, ) # Make the request operation = client.create_connection_profile(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.CreateConnectionProfileRequest, dict]): The request object. Request message for 'CreateConnectionProfile' request. parent (str): Required. The parent which owns this collection of connection profiles. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. connection_profile (google.cloud.clouddms_v1.types.ConnectionProfile): Required. The create request body including the connection profile data This corresponds to the ``connection_profile`` field on the ``request`` instance; if ``request`` is provided, this should not be set. connection_profile_id (str): Required. The connection profile identifier. This corresponds to the ``connection_profile_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConnectionProfile` A connection profile definition. """ # 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, connection_profile, connection_profile_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, clouddms.CreateConnectionProfileRequest): request = clouddms.CreateConnectionProfileRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if connection_profile is not None: request.connection_profile = connection_profile if connection_profile_id is not None: request.connection_profile_id = connection_profile_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.create_connection_profile ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.ConnectionProfile, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def update_connection_profile( self, request: Optional[Union[clouddms.UpdateConnectionProfileRequest, dict]] = None, *, connection_profile: Optional[clouddms_resources.ConnectionProfile] = 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.Operation: r"""Update the configuration of a single connection profile. .. 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 clouddms_v1 def sample_update_connection_profile(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) connection_profile = clouddms_v1.ConnectionProfile() connection_profile.mysql.host = "host_value" connection_profile.mysql.port = 453 connection_profile.mysql.username = "username_value" connection_profile.mysql.password = "password_value" request = clouddms_v1.UpdateConnectionProfileRequest( connection_profile=connection_profile, ) # Make the request operation = client.update_connection_profile(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.UpdateConnectionProfileRequest, dict]): The request object. Request message for 'UpdateConnectionProfile' request. connection_profile (google.cloud.clouddms_v1.types.ConnectionProfile): Required. The connection profile parameters to update. This corresponds to the ``connection_profile`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): Required. Field mask is used to specify the fields to be overwritten by the update in the conversion workspace resource. 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConnectionProfile` A connection profile definition. """ # 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([connection_profile, 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, clouddms.UpdateConnectionProfileRequest): request = clouddms.UpdateConnectionProfileRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if connection_profile is not None: request.connection_profile = connection_profile 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._transport._wrapped_methods[ self._transport.update_connection_profile ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("connection_profile.name", request.connection_profile.name),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.ConnectionProfile, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_connection_profile( self, request: Optional[Union[clouddms.DeleteConnectionProfileRequest, 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.Operation: r"""Deletes a single Database Migration Service connection profile. A connection profile can only be deleted if it is not in use by any active migration jobs. .. 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 clouddms_v1 def sample_delete_connection_profile(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.DeleteConnectionProfileRequest( name="name_value", ) # Make the request operation = client.delete_connection_profile(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.DeleteConnectionProfileRequest, dict]): The request object. Request message for 'DeleteConnectionProfile' request. name (str): Required. Name of the connection profile resource to delete. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: 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, clouddms.DeleteConnectionProfileRequest): request = clouddms.DeleteConnectionProfileRequest(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._transport._wrapped_methods[ self._transport.delete_connection_profile ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, empty_pb2.Empty, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def create_private_connection( self, request: Optional[Union[clouddms.CreatePrivateConnectionRequest, dict]] = None, *, parent: Optional[str] = None, private_connection: Optional[clouddms_resources.PrivateConnection] = None, private_connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a new private connection 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 clouddms_v1 def sample_create_private_connection(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) private_connection = clouddms_v1.PrivateConnection() private_connection.vpc_peering_config.vpc_name = "vpc_name_value" private_connection.vpc_peering_config.subnet = "subnet_value" request = clouddms_v1.CreatePrivateConnectionRequest( parent="parent_value", private_connection_id="private_connection_id_value", private_connection=private_connection, ) # Make the request operation = client.create_private_connection(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.CreatePrivateConnectionRequest, dict]): The request object. Request message to create a new private connection in the specified project and region. parent (str): Required. The parent that owns the collection of PrivateConnections. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. private_connection (google.cloud.clouddms_v1.types.PrivateConnection): Required. The private connection resource to create. This corresponds to the ``private_connection`` field on the ``request`` instance; if ``request`` is provided, this should not be set. private_connection_id (str): Required. The private connection identifier. This corresponds to the ``private_connection_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.PrivateConnection` The PrivateConnection resource is used to establish private connectivity with the customer's network. """ # 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, private_connection, private_connection_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, clouddms.CreatePrivateConnectionRequest): request = clouddms.CreatePrivateConnectionRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if private_connection is not None: request.private_connection = private_connection if private_connection_id is not None: request.private_connection_id = private_connection_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.create_private_connection ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, clouddms_resources.PrivateConnection, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def get_private_connection( self, request: Optional[Union[clouddms.GetPrivateConnectionRequest, 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]] = (), ) -> clouddms_resources.PrivateConnection: r"""Gets details of a single private connection. .. 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 clouddms_v1 def sample_get_private_connection(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.GetPrivateConnectionRequest( name="name_value", ) # Make the request response = client.get_private_connection(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.GetPrivateConnectionRequest, dict]): The request object. Request message to get a private connection resource. name (str): Required. The name of the private connection to get. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.PrivateConnection: The PrivateConnection resource is used to establish private connectivity with the customer's network. """ # 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, clouddms.GetPrivateConnectionRequest): request = clouddms.GetPrivateConnectionRequest(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._transport._wrapped_methods[self._transport.get_private_connection] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def list_private_connections( self, request: Optional[Union[clouddms.ListPrivateConnectionsRequest, 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.ListPrivateConnectionsPager: r"""Retrieves a list of private connections 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 clouddms_v1 def sample_list_private_connections(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ListPrivateConnectionsRequest( parent="parent_value", ) # Make the request page_result = client.list_private_connections(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.clouddms_v1.types.ListPrivateConnectionsRequest, dict]): The request object. Request message to retrieve a list of private connections in a given project and location. parent (str): Required. The parent that owns the collection of private connections. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.services.data_migration_service.pagers.ListPrivateConnectionsPager: Response message for 'ListPrivateConnections' request. 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, clouddms.ListPrivateConnectionsRequest): request = clouddms.ListPrivateConnectionsRequest(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._transport._wrapped_methods[self._transport.list_private_connections] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListPrivateConnectionsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def delete_private_connection( self, request: Optional[Union[clouddms.DeletePrivateConnectionRequest, 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.Operation: r"""Deletes a single Database Migration Service private connection. .. 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 clouddms_v1 def sample_delete_private_connection(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.DeletePrivateConnectionRequest( name="name_value", ) # Make the request operation = client.delete_private_connection(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.DeletePrivateConnectionRequest, dict]): The request object. Request message to delete a private connection. name (str): Required. The name of the private connection to delete. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: 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, clouddms.DeletePrivateConnectionRequest): request = clouddms.DeletePrivateConnectionRequest(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._transport._wrapped_methods[ self._transport.delete_private_connection ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, empty_pb2.Empty, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def get_conversion_workspace( self, request: Optional[Union[clouddms.GetConversionWorkspaceRequest, 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]] = (), ) -> conversionworkspace_resources.ConversionWorkspace: r"""Gets details of a single conversion workspace. .. 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 clouddms_v1 def sample_get_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.GetConversionWorkspaceRequest( name="name_value", ) # Make the request response = client.get_conversion_workspace(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.GetConversionWorkspaceRequest, dict]): The request object. Request message for 'GetConversionWorkspace' request. name (str): Required. Name of the conversion workspace resource to get. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.ConversionWorkspace: The main conversion workspace resource entity. """ # 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, clouddms.GetConversionWorkspaceRequest): request = clouddms.GetConversionWorkspaceRequest(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._transport._wrapped_methods[self._transport.get_conversion_workspace] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def list_conversion_workspaces( self, request: Optional[Union[clouddms.ListConversionWorkspacesRequest, 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.ListConversionWorkspacesPager: r"""Lists conversion workspaces 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 clouddms_v1 def sample_list_conversion_workspaces(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ListConversionWorkspacesRequest( parent="parent_value", ) # Make the request page_result = client.list_conversion_workspaces(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.clouddms_v1.types.ListConversionWorkspacesRequest, dict]): The request object. Retrieve a list of all conversion workspaces in a given project and location. parent (str): Required. The parent which owns this collection of conversion workspaces. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.services.data_migration_service.pagers.ListConversionWorkspacesPager: Response message for 'ListConversionWorkspaces' request. 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, clouddms.ListConversionWorkspacesRequest): request = clouddms.ListConversionWorkspacesRequest(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._transport._wrapped_methods[ self._transport.list_conversion_workspaces ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListConversionWorkspacesPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def create_conversion_workspace( self, request: Optional[ Union[clouddms.CreateConversionWorkspaceRequest, dict] ] = None, *, parent: Optional[str] = None, conversion_workspace: Optional[ conversionworkspace_resources.ConversionWorkspace ] = None, conversion_workspace_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a new conversion workspace 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 clouddms_v1 def sample_create_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) conversion_workspace = clouddms_v1.ConversionWorkspace() conversion_workspace.source.engine = "ORACLE" conversion_workspace.source.version = "version_value" conversion_workspace.destination.engine = "ORACLE" conversion_workspace.destination.version = "version_value" request = clouddms_v1.CreateConversionWorkspaceRequest( parent="parent_value", conversion_workspace_id="conversion_workspace_id_value", conversion_workspace=conversion_workspace, ) # Make the request operation = client.create_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.CreateConversionWorkspaceRequest, dict]): The request object. Request message to create a new Conversion Workspace in the specified project and region. parent (str): Required. The parent which owns this collection of conversion workspaces. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. conversion_workspace (google.cloud.clouddms_v1.types.ConversionWorkspace): Required. Represents a conversion workspace object. This corresponds to the ``conversion_workspace`` field on the ``request`` instance; if ``request`` is provided, this should not be set. conversion_workspace_id (str): Required. The ID of the conversion workspace to create. This corresponds to the ``conversion_workspace_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # 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, conversion_workspace, conversion_workspace_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, clouddms.CreateConversionWorkspaceRequest): request = clouddms.CreateConversionWorkspaceRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if conversion_workspace is not None: request.conversion_workspace = conversion_workspace if conversion_workspace_id is not None: request.conversion_workspace_id = conversion_workspace_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.create_conversion_workspace ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def update_conversion_workspace( self, request: Optional[ Union[clouddms.UpdateConversionWorkspaceRequest, dict] ] = None, *, conversion_workspace: Optional[ conversionworkspace_resources.ConversionWorkspace ] = 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.Operation: r"""Updates the parameters of a single conversion workspace. .. 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 clouddms_v1 def sample_update_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) conversion_workspace = clouddms_v1.ConversionWorkspace() conversion_workspace.source.engine = "ORACLE" conversion_workspace.source.version = "version_value" conversion_workspace.destination.engine = "ORACLE" conversion_workspace.destination.version = "version_value" request = clouddms_v1.UpdateConversionWorkspaceRequest( conversion_workspace=conversion_workspace, ) # Make the request operation = client.update_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.UpdateConversionWorkspaceRequest, dict]): The request object. Request message for 'UpdateConversionWorkspace' request. conversion_workspace (google.cloud.clouddms_v1.types.ConversionWorkspace): Required. The conversion workspace parameters to update. This corresponds to the ``conversion_workspace`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): Required. Field mask is used to specify the fields to be overwritten by the update in the conversion workspace resource. 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # 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([conversion_workspace, 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, clouddms.UpdateConversionWorkspaceRequest): request = clouddms.UpdateConversionWorkspaceRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if conversion_workspace is not None: request.conversion_workspace = conversion_workspace 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._transport._wrapped_methods[ self._transport.update_conversion_workspace ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("conversion_workspace.name", request.conversion_workspace.name),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_conversion_workspace( self, request: Optional[ Union[clouddms.DeleteConversionWorkspaceRequest, 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.Operation: r"""Deletes a single conversion workspace. .. 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 clouddms_v1 def sample_delete_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.DeleteConversionWorkspaceRequest( name="name_value", ) # Make the request operation = client.delete_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.DeleteConversionWorkspaceRequest, dict]): The request object. Request message for 'DeleteConversionWorkspace' request. name (str): Required. Name of the conversion workspace resource to delete. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: 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, clouddms.DeleteConversionWorkspaceRequest): request = clouddms.DeleteConversionWorkspaceRequest(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._transport._wrapped_methods[ self._transport.delete_conversion_workspace ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, empty_pb2.Empty, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def create_mapping_rule( self, request: Optional[Union[clouddms.CreateMappingRuleRequest, dict]] = None, *, parent: Optional[str] = None, mapping_rule: Optional[conversionworkspace_resources.MappingRule] = None, mapping_rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> conversionworkspace_resources.MappingRule: r"""Creates a new mapping rule for a given conversion workspace. .. 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 clouddms_v1 def sample_create_mapping_rule(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) mapping_rule = clouddms_v1.MappingRule() mapping_rule.single_entity_rename.new_name = "new_name_value" mapping_rule.rule_scope = "DATABASE_ENTITY_TYPE_DATABASE" mapping_rule.rule_order = 1075 request = clouddms_v1.CreateMappingRuleRequest( parent="parent_value", mapping_rule_id="mapping_rule_id_value", mapping_rule=mapping_rule, ) # Make the request response = client.create_mapping_rule(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.CreateMappingRuleRequest, dict]): The request object. Request message for 'CreateMappingRule' command. parent (str): Required. The parent which owns this collection of mapping rules. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. mapping_rule (google.cloud.clouddms_v1.types.MappingRule): Required. Represents a [mapping rule] (https://cloud.google.com/database-migration/reference/rest/v1/projects.locations.mappingRules) object. This corresponds to the ``mapping_rule`` field on the ``request`` instance; if ``request`` is provided, this should not be set. mapping_rule_id (str): Required. The ID of the rule to create. This corresponds to the ``mapping_rule_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.MappingRule: Definition of a transformation that is to be applied to a group of entities in the source schema. Several such transformations can be applied to an entity sequentially to define the corresponding entity in the target schema. """ # 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, mapping_rule, mapping_rule_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, clouddms.CreateMappingRuleRequest): request = clouddms.CreateMappingRuleRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if mapping_rule is not None: request.mapping_rule = mapping_rule if mapping_rule_id is not None: request.mapping_rule_id = mapping_rule_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_mapping_rule] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def delete_mapping_rule( self, request: Optional[Union[clouddms.DeleteMappingRuleRequest, 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]] = (), ) -> None: r"""Deletes a single mapping rule. .. 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 clouddms_v1 def sample_delete_mapping_rule(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.DeleteMappingRuleRequest( name="name_value", ) # Make the request client.delete_mapping_rule(request=request) Args: request (Union[google.cloud.clouddms_v1.types.DeleteMappingRuleRequest, dict]): The request object. Request message for 'DeleteMappingRule' request. name (str): Required. Name of the mapping rule resource to delete. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. """ # 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, clouddms.DeleteMappingRuleRequest): request = clouddms.DeleteMappingRuleRequest(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._transport._wrapped_methods[self._transport.delete_mapping_rule] # 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._validate_universe_domain() # Send the request. rpc( request, retry=retry, timeout=timeout, metadata=metadata, )
[docs] def list_mapping_rules( self, request: Optional[Union[clouddms.ListMappingRulesRequest, 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.ListMappingRulesPager: r"""Lists the mapping rules for a specific conversion workspace. .. 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 clouddms_v1 def sample_list_mapping_rules(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ListMappingRulesRequest( parent="parent_value", ) # Make the request page_result = client.list_mapping_rules(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.clouddms_v1.types.ListMappingRulesRequest, dict]): The request object. Retrieve a list of all mapping rules in a given conversion workspace. parent (str): Required. Name of the conversion workspace resource whose mapping rules are listed in the form of: projects/{project}/locations/{location}/conversionWorkspaces/{conversion_workspace}. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.services.data_migration_service.pagers.ListMappingRulesPager: Response message for 'ListMappingRulesRequest' request. 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, clouddms.ListMappingRulesRequest): request = clouddms.ListMappingRulesRequest(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._transport._wrapped_methods[self._transport.list_mapping_rules] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListMappingRulesPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_mapping_rule( self, request: Optional[Union[clouddms.GetMappingRuleRequest, 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]] = (), ) -> conversionworkspace_resources.MappingRule: r"""Gets the details of a mapping rule. .. 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 clouddms_v1 def sample_get_mapping_rule(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.GetMappingRuleRequest( name="name_value", ) # Make the request response = client.get_mapping_rule(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.GetMappingRuleRequest, dict]): The request object. Request message for 'GetMappingRule' request. name (str): Required. Name of the mapping rule resource to get. Example: conversionWorkspaces/123/mappingRules/rule123 In order to retrieve a previous revision of the mapping rule, also provide the revision ID. Example: conversionWorkspace/123/mappingRules/rule123@c7cfa2a8c7cfa2a8c7cfa2a8c7cfa2a8 This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.MappingRule: Definition of a transformation that is to be applied to a group of entities in the source schema. Several such transformations can be applied to an entity sequentially to define the corresponding entity in the target schema. """ # 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, clouddms.GetMappingRuleRequest): request = clouddms.GetMappingRuleRequest(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._transport._wrapped_methods[self._transport.get_mapping_rule] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def seed_conversion_workspace( self, request: Optional[Union[clouddms.SeedConversionWorkspaceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Imports a snapshot of the source database into the conversion workspace. .. 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 clouddms_v1 def sample_seed_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.SeedConversionWorkspaceRequest( source_connection_profile="source_connection_profile_value", ) # Make the request operation = client.seed_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.SeedConversionWorkspaceRequest, dict]): The request object. Request message for 'SeedConversionWorkspace' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # Create or coerce a protobuf request object. # - 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, clouddms.SeedConversionWorkspaceRequest): request = clouddms.SeedConversionWorkspaceRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.seed_conversion_workspace ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def import_mapping_rules( self, request: Optional[Union[clouddms.ImportMappingRulesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Imports the mapping rules for a given conversion workspace. Supports various formats of external rules files. .. 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 clouddms_v1 def sample_import_mapping_rules(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) rules_files = clouddms_v1.RulesFile() rules_files.rules_source_filename = "rules_source_filename_value" rules_files.rules_content = "rules_content_value" request = clouddms_v1.ImportMappingRulesRequest( parent="parent_value", rules_format="IMPORT_RULES_FILE_FORMAT_ORATOPG_CONFIG_FILE", rules_files=rules_files, auto_commit=True, ) # Make the request operation = client.import_mapping_rules(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.ImportMappingRulesRequest, dict]): The request object. Request message for 'ImportMappingRules' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # Create or coerce a protobuf request object. # - 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, clouddms.ImportMappingRulesRequest): request = clouddms.ImportMappingRulesRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.import_mapping_rules] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def convert_conversion_workspace( self, request: Optional[ Union[clouddms.ConvertConversionWorkspaceRequest, dict] ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a draft tree schema for the destination database. .. 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 clouddms_v1 def sample_convert_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ConvertConversionWorkspaceRequest( ) # Make the request operation = client.convert_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.ConvertConversionWorkspaceRequest, dict]): The request object. Request message for 'ConvertConversionWorkspace' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # Create or coerce a protobuf request object. # - 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, clouddms.ConvertConversionWorkspaceRequest): request = clouddms.ConvertConversionWorkspaceRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.convert_conversion_workspace ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def commit_conversion_workspace( self, request: Optional[ Union[clouddms.CommitConversionWorkspaceRequest, dict] ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Marks all the data in the conversion workspace as committed. .. 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 clouddms_v1 def sample_commit_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.CommitConversionWorkspaceRequest( name="name_value", ) # Make the request operation = client.commit_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.CommitConversionWorkspaceRequest, dict]): The request object. Request message for 'CommitConversionWorkspace' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # Create or coerce a protobuf request object. # - 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, clouddms.CommitConversionWorkspaceRequest): request = clouddms.CommitConversionWorkspaceRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.commit_conversion_workspace ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def rollback_conversion_workspace( self, request: Optional[ Union[clouddms.RollbackConversionWorkspaceRequest, dict] ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Rolls back a conversion workspace to the last committed snapshot. .. 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 clouddms_v1 def sample_rollback_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.RollbackConversionWorkspaceRequest( name="name_value", ) # Make the request operation = client.rollback_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.RollbackConversionWorkspaceRequest, dict]): The request object. Request message for 'RollbackConversionWorkspace' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # Create or coerce a protobuf request object. # - 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, clouddms.RollbackConversionWorkspaceRequest): request = clouddms.RollbackConversionWorkspaceRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.rollback_conversion_workspace ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def apply_conversion_workspace( self, request: Optional[Union[clouddms.ApplyConversionWorkspaceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Applies draft tree onto a specific destination database. .. 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 clouddms_v1 def sample_apply_conversion_workspace(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.ApplyConversionWorkspaceRequest( connection_profile="connection_profile_value", name="name_value", ) # Make the request operation = client.apply_conversion_workspace(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.ApplyConversionWorkspaceRequest, dict]): The request object. Request message for 'ApplyConversionWorkspace' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.clouddms_v1.types.ConversionWorkspace` The main conversion workspace resource entity. """ # Create or coerce a protobuf request object. # - 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, clouddms.ApplyConversionWorkspaceRequest): request = clouddms.ApplyConversionWorkspaceRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.apply_conversion_workspace ] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation.from_gapic( response, self._transport.operations_client, conversionworkspace_resources.ConversionWorkspace, metadata_type=clouddms.OperationMetadata, ) # Done; return the response. return response
[docs] def describe_database_entities( self, request: Optional[Union[clouddms.DescribeDatabaseEntitiesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.DescribeDatabaseEntitiesPager: r"""Describes the database entities tree for a specific conversion workspace and a specific tree type. Database entities are not resources like conversion workspaces or mapping rules, and they can't be created, updated or deleted. Instead, they are simple data objects describing the structure of the client database. .. 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 clouddms_v1 def sample_describe_database_entities(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.DescribeDatabaseEntitiesRequest( conversion_workspace="conversion_workspace_value", tree="DESTINATION_TREE", ) # Make the request page_result = client.describe_database_entities(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.clouddms_v1.types.DescribeDatabaseEntitiesRequest, dict]): The request object. Request message for 'DescribeDatabaseEntities' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.services.data_migration_service.pagers.DescribeDatabaseEntitiesPager: Response message for 'DescribeDatabaseEntities' request. Iterating over this object will yield results and resolve additional pages automatically. """ # Create or coerce a protobuf request object. # - 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, clouddms.DescribeDatabaseEntitiesRequest): request = clouddms.DescribeDatabaseEntitiesRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.describe_database_entities ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("conversion_workspace", request.conversion_workspace),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.DescribeDatabaseEntitiesPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def search_background_jobs( self, request: Optional[Union[clouddms.SearchBackgroundJobsRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> clouddms.SearchBackgroundJobsResponse: r"""Searches/lists the background jobs for a specific conversion workspace. The background jobs are not resources like conversion workspaces or mapping rules, and they can't be created, updated or deleted. Instead, they are a way to expose the data plane jobs log. .. 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 clouddms_v1 def sample_search_background_jobs(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.SearchBackgroundJobsRequest( conversion_workspace="conversion_workspace_value", ) # Make the request response = client.search_background_jobs(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.SearchBackgroundJobsRequest, dict]): The request object. Request message for 'SearchBackgroundJobs' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.SearchBackgroundJobsResponse: Response message for 'SearchBackgroundJobs' request. """ # Create or coerce a protobuf request object. # - 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, clouddms.SearchBackgroundJobsRequest): request = clouddms.SearchBackgroundJobsRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.search_background_jobs] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("conversion_workspace", request.conversion_workspace),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def describe_conversion_workspace_revisions( self, request: Optional[ Union[clouddms.DescribeConversionWorkspaceRevisionsRequest, dict] ] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> clouddms.DescribeConversionWorkspaceRevisionsResponse: r"""Retrieves a list of committed revisions of a specific conversion workspace. .. 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 clouddms_v1 def sample_describe_conversion_workspace_revisions(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.DescribeConversionWorkspaceRevisionsRequest( conversion_workspace="conversion_workspace_value", ) # Make the request response = client.describe_conversion_workspace_revisions(request=request) # Handle the response print(response) Args: request (Union[google.cloud.clouddms_v1.types.DescribeConversionWorkspaceRevisionsRequest, dict]): The request object. Request message for 'DescribeConversionWorkspaceRevisions' request. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.types.DescribeConversionWorkspaceRevisionsResponse: Response message for 'DescribeConversionWorkspaceRevisions' request. """ # Create or coerce a protobuf request object. # - 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, clouddms.DescribeConversionWorkspaceRevisionsRequest ): request = clouddms.DescribeConversionWorkspaceRevisionsRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.describe_conversion_workspace_revisions ] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("conversion_workspace", request.conversion_workspace),) ), ) # Validate the universe domain. self._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def fetch_static_ips( self, request: Optional[Union[clouddms.FetchStaticIpsRequest, 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]] = (), ) -> pagers.FetchStaticIpsPager: r"""Fetches a set of static IP addresses that need to be allowlisted by the customer when using the static-IP connectivity method. .. 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 clouddms_v1 def sample_fetch_static_ips(): # Create a client client = clouddms_v1.DataMigrationServiceClient() # Initialize request argument(s) request = clouddms_v1.FetchStaticIpsRequest( name="name_value", ) # Make the request page_result = client.fetch_static_ips(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.clouddms_v1.types.FetchStaticIpsRequest, dict]): The request object. Request message for 'FetchStaticIps' request. name (str): Required. The resource name for the location for which static IPs should be returned. Must be in the format ``projects/*/locations/*``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.cloud.clouddms_v1.services.data_migration_service.pagers.FetchStaticIpsPager: Response message for a 'FetchStaticIps' request. 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([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, clouddms.FetchStaticIpsRequest): request = clouddms.FetchStaticIpsRequest(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._transport._wrapped_methods[self._transport.fetch_static_ips] # 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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.FetchStaticIpsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
def __enter__(self) -> "DataMigrationServiceClient": return self
[docs] def __exit__(self, type, value, traceback): """Releases underlying transport's resources. .. warning:: ONLY use as a context manager if the transport is NOT shared with other clients! Exiting the with block will CLOSE the transport and may cause errors in other clients! """ self.transport.close()
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.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._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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.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._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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: 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._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._validate_universe_domain() # Send the request. rpc( request, retry=retry, timeout=timeout, metadata=metadata, )
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: 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._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._validate_universe_domain() # Send the request. rpc( request, retry=retry, timeout=timeout, metadata=metadata, )
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.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._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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.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._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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.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._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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.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._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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] 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.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.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._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._validate_universe_domain() # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=package_version.__version__ ) __all__ = ("DataMigrationServiceClient",)