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.vmmigration_v1.services.vm_migration.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.vmmigration_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.vmmigration_v1.services.vm_migration import pagers
from google.cloud.vmmigration_v1.types import vmmigration

from .transports.base import DEFAULT_CLIENT_INFO, VmMigrationTransport
from .transports.grpc import VmMigrationGrpcTransport
from .transports.grpc_asyncio import VmMigrationGrpcAsyncIOTransport
from .transports.rest import VmMigrationRestTransport


class VmMigrationClientMeta(type):
    """Metaclass for the VmMigration 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[VmMigrationTransport]]
    _transport_registry["grpc"] = VmMigrationGrpcTransport
    _transport_registry["grpc_asyncio"] = VmMigrationGrpcAsyncIOTransport
    _transport_registry["rest"] = VmMigrationRestTransport

    def get_transport_class(
        cls,
        label: Optional[str] = None,
    ) -> Type[VmMigrationTransport]:
        """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 VmMigrationClient(metaclass=VmMigrationClientMeta): """VM 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 = "vmmigration.googleapis.com" DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore DEFAULT_ENDPOINT ) _DEFAULT_ENDPOINT_TEMPLATE = "vmmigration.{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: VmMigrationClient: 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: VmMigrationClient: 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) -> VmMigrationTransport: """Returns the transport used by the client instance. Returns: VmMigrationTransport: The transport used by the client instance. """ return self._transport
[docs] @staticmethod def clone_job_path( project: str, location: str, source: str, migrating_vm: str, clone_job: str, ) -> str: """Returns a fully-qualified clone_job string.""" return "projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/cloneJobs/{clone_job}".format( project=project, location=location, source=source, migrating_vm=migrating_vm, clone_job=clone_job, )
[docs] @staticmethod def parse_clone_job_path(path: str) -> Dict[str, str]: """Parses a clone_job path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/sources/(?P<source>.+?)/migratingVms/(?P<migrating_vm>.+?)/cloneJobs/(?P<clone_job>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def cutover_job_path( project: str, location: str, source: str, migrating_vm: str, cutover_job: str, ) -> str: """Returns a fully-qualified cutover_job string.""" return "projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/cutoverJobs/{cutover_job}".format( project=project, location=location, source=source, migrating_vm=migrating_vm, cutover_job=cutover_job, )
[docs] @staticmethod def parse_cutover_job_path(path: str) -> Dict[str, str]: """Parses a cutover_job path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/sources/(?P<source>.+?)/migratingVms/(?P<migrating_vm>.+?)/cutoverJobs/(?P<cutover_job>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def datacenter_connector_path( project: str, location: str, source: str, datacenter_connector: str, ) -> str: """Returns a fully-qualified datacenter_connector string.""" return "projects/{project}/locations/{location}/sources/{source}/datacenterConnectors/{datacenter_connector}".format( project=project, location=location, source=source, datacenter_connector=datacenter_connector, )
[docs] @staticmethod def parse_datacenter_connector_path(path: str) -> Dict[str, str]: """Parses a datacenter_connector path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/sources/(?P<source>.+?)/datacenterConnectors/(?P<datacenter_connector>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def group_path( project: str, location: str, group: str, ) -> str: """Returns a fully-qualified group string.""" return "projects/{project}/locations/{location}/groups/{group}".format( project=project, location=location, group=group, )
[docs] @staticmethod def parse_group_path(path: str) -> Dict[str, str]: """Parses a group path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/groups/(?P<group>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def migrating_vm_path( project: str, location: str, source: str, migrating_vm: str, ) -> str: """Returns a fully-qualified migrating_vm string.""" return "projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}".format( project=project, location=location, source=source, migrating_vm=migrating_vm, )
[docs] @staticmethod def parse_migrating_vm_path(path: str) -> Dict[str, str]: """Parses a migrating_vm path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/sources/(?P<source>.+?)/migratingVms/(?P<migrating_vm>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def replication_cycle_path( project: str, location: str, source: str, migrating_vm: str, replication_cycle: str, ) -> str: """Returns a fully-qualified replication_cycle string.""" return "projects/{project}/locations/{location}/sources/{source}/migratingVms/{migrating_vm}/replicationCycles/{replication_cycle}".format( project=project, location=location, source=source, migrating_vm=migrating_vm, replication_cycle=replication_cycle, )
[docs] @staticmethod def parse_replication_cycle_path(path: str) -> Dict[str, str]: """Parses a replication_cycle path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/sources/(?P<source>.+?)/migratingVms/(?P<migrating_vm>.+?)/replicationCycles/(?P<replication_cycle>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def source_path( project: str, location: str, source: str, ) -> str: """Returns a fully-qualified source string.""" return "projects/{project}/locations/{location}/sources/{source}".format( project=project, location=location, source=source, )
[docs] @staticmethod def parse_source_path(path: str) -> Dict[str, str]: """Parses a source path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/sources/(?P<source>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def target_project_path( project: str, location: str, target_project: str, ) -> str: """Returns a fully-qualified target_project string.""" return "projects/{project}/locations/{location}/targetProjects/{target_project}".format( project=project, location=location, target_project=target_project, )
[docs] @staticmethod def parse_target_project_path(path: str) -> Dict[str, str]: """Parses a target_project path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/targetProjects/(?P<target_project>.+?)$", path, ) return m.groupdict() if m else {}
[docs] @staticmethod def utilization_report_path( project: str, location: str, source: str, utilization_report: str, ) -> str: """Returns a fully-qualified utilization_report string.""" return "projects/{project}/locations/{location}/sources/{source}/utilizationReports/{utilization_report}".format( project=project, location=location, source=source, utilization_report=utilization_report, )
[docs] @staticmethod def parse_utilization_report_path(path: str) -> Dict[str, str]: """Parses a utilization_report path into its component segments.""" m = re.match( r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/sources/(?P<source>.+?)/utilizationReports/(?P<utilization_report>.+?)$", 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 = VmMigrationClient._DEFAULT_UNIVERSE if universe_domain != _default_universe: raise MutualTLSChannelError( f"mTLS is not supported in any universe other than {_default_universe}." ) api_endpoint = VmMigrationClient.DEFAULT_MTLS_ENDPOINT else: api_endpoint = VmMigrationClient._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 = VmMigrationClient._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, VmMigrationTransport, Callable[..., VmMigrationTransport]] ] = None, client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the vm migration 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,VmMigrationTransport,Callable[..., VmMigrationTransport]]]): 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 VmMigrationTransport 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, ) = VmMigrationClient._read_environment_variables() self._client_cert_source = VmMigrationClient._get_client_cert_source( self._client_options.client_cert_source, self._use_client_cert ) self._universe_domain = VmMigrationClient._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, VmMigrationTransport) if transport_provided: # transport is a VmMigrationTransport 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(VmMigrationTransport, transport) self._api_endpoint = self._transport.host self._api_endpoint = self._api_endpoint or VmMigrationClient._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[VmMigrationTransport], Callable[..., VmMigrationTransport] ] = ( VmMigrationClient.get_transport_class(transport) if isinstance(transport, str) or transport is None else cast(Callable[..., VmMigrationTransport], 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_sources( self, request: Optional[Union[vmmigration.ListSourcesRequest, 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.ListSourcesPager: r"""Lists Sources 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 vmmigration_v1 def sample_list_sources(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListSourcesRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_sources(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListSourcesRequest, dict]): The request object. Request message for 'ListSources' request. parent (str): Required. The parent, which owns this collection of sources. 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.vmmigration_v1.services.vm_migration.pagers.ListSourcesPager: Response message for 'ListSources' 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, vmmigration.ListSourcesRequest): request = vmmigration.ListSourcesRequest(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_sources] # 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.ListSourcesPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_source( self, request: Optional[Union[vmmigration.GetSourceRequest, 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]] = (), ) -> vmmigration.Source: r"""Gets details of a single Source. .. 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 vmmigration_v1 def sample_get_source(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetSourceRequest( name="name_value", ) # Make the request response = client.get_source(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetSourceRequest, dict]): The request object. Request message for 'GetSource' request. name (str): Required. The Source name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.Source: Source message describes a specific vm migration Source resource. It contains the source environment information. """ # 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, vmmigration.GetSourceRequest): request = vmmigration.GetSourceRequest(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_source] # 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_source( self, request: Optional[Union[vmmigration.CreateSourceRequest, dict]] = None, *, parent: Optional[str] = None, source: Optional[vmmigration.Source] = None, source_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 Source 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 vmmigration_v1 def sample_create_source(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateSourceRequest( parent="parent_value", source_id="source_id_value", ) # Make the request operation = client.create_source(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateSourceRequest, dict]): The request object. Request message for 'CreateSource' request. parent (str): Required. The Source's parent. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. source (google.cloud.vmmigration_v1.types.Source): Required. The create request body. This corresponds to the ``source`` field on the ``request`` instance; if ``request`` is provided, this should not be set. source_id (str): Required. The source identifier. This corresponds to the ``source_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.vmmigration_v1.types.Source` Source message describes a specific vm migration Source resource. It contains the source environment information. """ # 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, source, source_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, vmmigration.CreateSourceRequest): request = vmmigration.CreateSourceRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if source is not None: request.source = source if source_id is not None: request.source_id = source_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_source] # 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, vmmigration.Source, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def update_source( self, request: Optional[Union[vmmigration.UpdateSourceRequest, dict]] = None, *, source: Optional[vmmigration.Source] = 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 Source. .. 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 vmmigration_v1 def sample_update_source(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.UpdateSourceRequest( ) # Make the request operation = client.update_source(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.UpdateSourceRequest, dict]): The request object. Update message for 'UpdateSources' request. source (google.cloud.vmmigration_v1.types.Source): Required. The update request body. This corresponds to the ``source`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields to be overwritten in the Source resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.Source` Source message describes a specific vm migration Source resource. It contains the source environment information. """ # 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([source, 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, vmmigration.UpdateSourceRequest): request = vmmigration.UpdateSourceRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if source is not None: request.source = source 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_source] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("source.name", request.source.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, vmmigration.Source, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_source( self, request: Optional[Union[vmmigration.DeleteSourceRequest, 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 Source. .. 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 vmmigration_v1 def sample_delete_source(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.DeleteSourceRequest( name="name_value", ) # Make the request operation = client.delete_source(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.DeleteSourceRequest, dict]): The request object. Request message for 'DeleteSource' request. name (str): Required. The Source name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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, vmmigration.DeleteSourceRequest): request = vmmigration.DeleteSourceRequest(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_source] # 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=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def fetch_inventory( self, request: Optional[Union[vmmigration.FetchInventoryRequest, dict]] = None, *, source: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> vmmigration.FetchInventoryResponse: r"""List remote source's inventory of VMs. The remote source is the onprem vCenter (remote in the sense it's not in Compute Engine). The inventory describes the list of existing VMs in that source. Note that this operation lists the VMs on the remote source, as opposed to listing the MigratingVms resources in the vmmigration service. .. 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 vmmigration_v1 def sample_fetch_inventory(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.FetchInventoryRequest( source="source_value", ) # Make the request response = client.fetch_inventory(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.FetchInventoryRequest, dict]): The request object. Request message for [fetchInventory][google.cloud.vmmigration.v1.VmMigration.FetchInventory]. source (str): Required. The name of the Source. This corresponds to the ``source`` 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.vmmigration_v1.types.FetchInventoryResponse: Response message for [fetchInventory][google.cloud.vmmigration.v1.VmMigration.FetchInventory]. """ # 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([source]) 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, vmmigration.FetchInventoryRequest): request = vmmigration.FetchInventoryRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if source is not None: request.source = source # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.fetch_inventory] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata((("source", request.source),)), ) # 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_utilization_reports( self, request: Optional[ Union[vmmigration.ListUtilizationReportsRequest, 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.ListUtilizationReportsPager: r"""Lists Utilization Reports of the given Source. .. 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 vmmigration_v1 def sample_list_utilization_reports(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListUtilizationReportsRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_utilization_reports(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListUtilizationReportsRequest, dict]): The request object. Request message for 'ListUtilizationReports' request. parent (str): Required. The Utilization Reports parent. 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.vmmigration_v1.services.vm_migration.pagers.ListUtilizationReportsPager: Response message for 'ListUtilizationReports' 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, vmmigration.ListUtilizationReportsRequest): request = vmmigration.ListUtilizationReportsRequest(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_utilization_reports] # 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.ListUtilizationReportsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_utilization_report( self, request: Optional[Union[vmmigration.GetUtilizationReportRequest, 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]] = (), ) -> vmmigration.UtilizationReport: r"""Gets a single Utilization Report. .. 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 vmmigration_v1 def sample_get_utilization_report(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetUtilizationReportRequest( name="name_value", ) # Make the request response = client.get_utilization_report(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetUtilizationReportRequest, dict]): The request object. Request message for 'GetUtilizationReport' request. name (str): Required. The Utilization Report name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.UtilizationReport: Utilization report details the utilization (CPU, memory, etc.) of selected source VMs. """ # 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, vmmigration.GetUtilizationReportRequest): request = vmmigration.GetUtilizationReportRequest(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_utilization_report] # 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_utilization_report( self, request: Optional[ Union[vmmigration.CreateUtilizationReportRequest, dict] ] = None, *, parent: Optional[str] = None, utilization_report: Optional[vmmigration.UtilizationReport] = None, utilization_report_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 UtilizationReport. .. 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 vmmigration_v1 def sample_create_utilization_report(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateUtilizationReportRequest( parent="parent_value", utilization_report_id="utilization_report_id_value", ) # Make the request operation = client.create_utilization_report(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateUtilizationReportRequest, dict]): The request object. Request message for 'CreateUtilizationReport' request. parent (str): Required. The Utilization Report's parent. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. utilization_report (google.cloud.vmmigration_v1.types.UtilizationReport): Required. The report to create. This corresponds to the ``utilization_report`` field on the ``request`` instance; if ``request`` is provided, this should not be set. utilization_report_id (str): Required. The ID to use for the report, which will become the final component of the reports's resource name. This value maximum length is 63 characters, and valid characters are /[a-z][0-9]-/. It must start with an english letter and must not end with a hyphen. This corresponds to the ``utilization_report_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.vmmigration_v1.types.UtilizationReport` Utilization report details the utilization (CPU, memory, etc.) of selected source VMs. """ # 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, utilization_report, utilization_report_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, vmmigration.CreateUtilizationReportRequest): request = vmmigration.CreateUtilizationReportRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if utilization_report is not None: request.utilization_report = utilization_report if utilization_report_id is not None: request.utilization_report_id = utilization_report_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.create_utilization_report ] # 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, vmmigration.UtilizationReport, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_utilization_report( self, request: Optional[ Union[vmmigration.DeleteUtilizationReportRequest, 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 Utilization Report. .. 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 vmmigration_v1 def sample_delete_utilization_report(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.DeleteUtilizationReportRequest( name="name_value", ) # Make the request operation = client.delete_utilization_report(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.DeleteUtilizationReportRequest, dict]): The request object. Request message for 'DeleteUtilizationReport' request. name (str): Required. The Utilization Report name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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, vmmigration.DeleteUtilizationReportRequest): request = vmmigration.DeleteUtilizationReportRequest(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_utilization_report ] # 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=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def list_datacenter_connectors( self, request: Optional[ Union[vmmigration.ListDatacenterConnectorsRequest, 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.ListDatacenterConnectorsPager: r"""Lists DatacenterConnectors in a given Source. .. 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 vmmigration_v1 def sample_list_datacenter_connectors(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListDatacenterConnectorsRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_datacenter_connectors(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListDatacenterConnectorsRequest, dict]): The request object. Request message for 'ListDatacenterConnectors' request. parent (str): Required. The parent, which owns this collection of connectors. 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.vmmigration_v1.services.vm_migration.pagers.ListDatacenterConnectorsPager: Response message for 'ListDatacenterConnectors' 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, vmmigration.ListDatacenterConnectorsRequest): request = vmmigration.ListDatacenterConnectorsRequest(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_datacenter_connectors ] # 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.ListDatacenterConnectorsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_datacenter_connector( self, request: Optional[ Union[vmmigration.GetDatacenterConnectorRequest, 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]] = (), ) -> vmmigration.DatacenterConnector: r"""Gets details of a single DatacenterConnector. .. 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 vmmigration_v1 def sample_get_datacenter_connector(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetDatacenterConnectorRequest( name="name_value", ) # Make the request response = client.get_datacenter_connector(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetDatacenterConnectorRequest, dict]): The request object. Request message for 'GetDatacenterConnector' request. name (str): Required. The name of the DatacenterConnector. 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.vmmigration_v1.types.DatacenterConnector: DatacenterConnector message describes a connector between the Source and Google Cloud, which is installed on a vmware datacenter (an OVA vm installed by the user) to connect the Datacenter to Google Cloud and support vm migration data transfer. """ # 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, vmmigration.GetDatacenterConnectorRequest): request = vmmigration.GetDatacenterConnectorRequest(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_datacenter_connector] # 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_datacenter_connector( self, request: Optional[ Union[vmmigration.CreateDatacenterConnectorRequest, dict] ] = None, *, parent: Optional[str] = None, datacenter_connector: Optional[vmmigration.DatacenterConnector] = None, datacenter_connector_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 DatacenterConnector in a given Source. .. 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 vmmigration_v1 def sample_create_datacenter_connector(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateDatacenterConnectorRequest( parent="parent_value", datacenter_connector_id="datacenter_connector_id_value", ) # Make the request operation = client.create_datacenter_connector(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateDatacenterConnectorRequest, dict]): The request object. Request message for 'CreateDatacenterConnector' request. parent (str): Required. The DatacenterConnector's parent. Required. The Source in where the new DatacenterConnector will be created. For example: ``projects/my-project/locations/us-central1/sources/my-source`` This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. datacenter_connector (google.cloud.vmmigration_v1.types.DatacenterConnector): Required. The create request body. This corresponds to the ``datacenter_connector`` field on the ``request`` instance; if ``request`` is provided, this should not be set. datacenter_connector_id (str): Required. The datacenterConnector identifier. This corresponds to the ``datacenter_connector_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.vmmigration_v1.types.DatacenterConnector` DatacenterConnector message describes a connector between the Source and Google Cloud, which is installed on a vmware datacenter (an OVA vm installed by the user) to connect the Datacenter to Google Cloud and support vm migration data transfer. """ # 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, datacenter_connector, datacenter_connector_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, vmmigration.CreateDatacenterConnectorRequest): request = vmmigration.CreateDatacenterConnectorRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if datacenter_connector is not None: request.datacenter_connector = datacenter_connector if datacenter_connector_id is not None: request.datacenter_connector_id = datacenter_connector_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.create_datacenter_connector ] # 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, vmmigration.DatacenterConnector, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_datacenter_connector( self, request: Optional[ Union[vmmigration.DeleteDatacenterConnectorRequest, 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 DatacenterConnector. .. 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 vmmigration_v1 def sample_delete_datacenter_connector(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.DeleteDatacenterConnectorRequest( name="name_value", ) # Make the request operation = client.delete_datacenter_connector(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.DeleteDatacenterConnectorRequest, dict]): The request object. Request message for 'DeleteDatacenterConnector' request. name (str): Required. The DatacenterConnector name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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, vmmigration.DeleteDatacenterConnectorRequest): request = vmmigration.DeleteDatacenterConnectorRequest(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_datacenter_connector ] # 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=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def upgrade_appliance( self, request: Optional[Union[vmmigration.UpgradeApplianceRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Upgrades the appliance relate to this DatacenterConnector to the in-place updateable version. .. 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 vmmigration_v1 def sample_upgrade_appliance(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.UpgradeApplianceRequest( datacenter_connector="datacenter_connector_value", ) # Make the request operation = client.upgrade_appliance(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.UpgradeApplianceRequest, dict]): The request object. Request message for 'UpgradeAppliance' 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.vmmigration_v1.types.UpgradeApplianceResponse` Response message for 'UpgradeAppliance' 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, vmmigration.UpgradeApplianceRequest): request = vmmigration.UpgradeApplianceRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.upgrade_appliance] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("datacenter_connector", request.datacenter_connector),) ), ) # 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, vmmigration.UpgradeApplianceResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def create_migrating_vm( self, request: Optional[Union[vmmigration.CreateMigratingVmRequest, dict]] = None, *, parent: Optional[str] = None, migrating_vm: Optional[vmmigration.MigratingVm] = None, migrating_vm_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 MigratingVm in a given Source. .. 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 vmmigration_v1 def sample_create_migrating_vm(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateMigratingVmRequest( parent="parent_value", migrating_vm_id="migrating_vm_id_value", ) # Make the request operation = client.create_migrating_vm(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateMigratingVmRequest, dict]): The request object. Request message for 'CreateMigratingVm' request. parent (str): Required. The MigratingVm's parent. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. migrating_vm (google.cloud.vmmigration_v1.types.MigratingVm): Required. The create request body. This corresponds to the ``migrating_vm`` field on the ``request`` instance; if ``request`` is provided, this should not be set. migrating_vm_id (str): Required. The migratingVm identifier. This corresponds to the ``migrating_vm_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.vmmigration_v1.types.MigratingVm` MigratingVm describes the VM that will be migrated from a Source environment and its replication state. """ # 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, migrating_vm, migrating_vm_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, vmmigration.CreateMigratingVmRequest): request = vmmigration.CreateMigratingVmRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if migrating_vm is not None: request.migrating_vm = migrating_vm if migrating_vm_id is not None: request.migrating_vm_id = migrating_vm_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_migrating_vm] # 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, vmmigration.MigratingVm, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def list_migrating_vms( self, request: Optional[Union[vmmigration.ListMigratingVmsRequest, 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.ListMigratingVmsPager: r"""Lists MigratingVms in a given Source. .. 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 vmmigration_v1 def sample_list_migrating_vms(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListMigratingVmsRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_migrating_vms(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListMigratingVmsRequest, dict]): The request object. Request message for 'LisMigratingVmsRequest' request. parent (str): Required. The parent, which owns this collection of MigratingVms. 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.vmmigration_v1.services.vm_migration.pagers.ListMigratingVmsPager: Response message for 'ListMigratingVms' 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, vmmigration.ListMigratingVmsRequest): request = vmmigration.ListMigratingVmsRequest(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_migrating_vms] # 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.ListMigratingVmsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_migrating_vm( self, request: Optional[Union[vmmigration.GetMigratingVmRequest, 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]] = (), ) -> vmmigration.MigratingVm: r"""Gets details of a single MigratingVm. .. 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 vmmigration_v1 def sample_get_migrating_vm(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetMigratingVmRequest( name="name_value", ) # Make the request response = client.get_migrating_vm(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetMigratingVmRequest, dict]): The request object. Request message for 'GetMigratingVm' request. name (str): Required. The name of the MigratingVm. 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.vmmigration_v1.types.MigratingVm: MigratingVm describes the VM that will be migrated from a Source environment and its replication state. """ # 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, vmmigration.GetMigratingVmRequest): request = vmmigration.GetMigratingVmRequest(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_migrating_vm] # 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 update_migrating_vm( self, request: Optional[Union[vmmigration.UpdateMigratingVmRequest, dict]] = None, *, migrating_vm: Optional[vmmigration.MigratingVm] = 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 MigratingVm. .. 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 vmmigration_v1 def sample_update_migrating_vm(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.UpdateMigratingVmRequest( ) # Make the request operation = client.update_migrating_vm(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.UpdateMigratingVmRequest, dict]): The request object. Request message for 'UpdateMigratingVm' request. migrating_vm (google.cloud.vmmigration_v1.types.MigratingVm): Required. The update request body. This corresponds to the ``migrating_vm`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields to be overwritten in the MigratingVm resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.MigratingVm` MigratingVm describes the VM that will be migrated from a Source environment and its replication state. """ # 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([migrating_vm, 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, vmmigration.UpdateMigratingVmRequest): request = vmmigration.UpdateMigratingVmRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if migrating_vm is not None: request.migrating_vm = migrating_vm 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_migrating_vm] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migrating_vm.name", request.migrating_vm.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, vmmigration.MigratingVm, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_migrating_vm( self, request: Optional[Union[vmmigration.DeleteMigratingVmRequest, 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 MigratingVm. .. 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 vmmigration_v1 def sample_delete_migrating_vm(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.DeleteMigratingVmRequest( name="name_value", ) # Make the request operation = client.delete_migrating_vm(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.DeleteMigratingVmRequest, dict]): The request object. Request message for 'DeleteMigratingVm' request. name (str): Required. The name of the MigratingVm. 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, vmmigration.DeleteMigratingVmRequest): request = vmmigration.DeleteMigratingVmRequest(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_migrating_vm] # 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=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def start_migration( self, request: Optional[Union[vmmigration.StartMigrationRequest, dict]] = None, *, migrating_vm: 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"""Starts migration for a VM. Starts the process of uploading data and creating snapshots, in replication cycles scheduled by the policy. .. 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 vmmigration_v1 def sample_start_migration(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.StartMigrationRequest( migrating_vm="migrating_vm_value", ) # Make the request operation = client.start_migration(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.StartMigrationRequest, dict]): The request object. Request message for 'StartMigrationRequest' request. migrating_vm (str): Required. The name of the MigratingVm. This corresponds to the ``migrating_vm`` 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.vmmigration_v1.types.StartMigrationResponse` Response message for 'StartMigration' request. """ # 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([migrating_vm]) 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, vmmigration.StartMigrationRequest): request = vmmigration.StartMigrationRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if migrating_vm is not None: request.migrating_vm = migrating_vm # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.start_migration] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migrating_vm", request.migrating_vm),) ), ) # 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, vmmigration.StartMigrationResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def resume_migration( self, request: Optional[Union[vmmigration.ResumeMigrationRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Resumes a migration for a VM. When called on a paused migration, will start the process of uploading data and creating snapshots; when called on a completed cut-over migration, will update the migration to active state and start the process of uploading data and creating snapshots. .. 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 vmmigration_v1 def sample_resume_migration(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ResumeMigrationRequest( migrating_vm="migrating_vm_value", ) # Make the request operation = client.resume_migration(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ResumeMigrationRequest, dict]): The request object. Request message for 'ResumeMigration' 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.vmmigration_v1.types.ResumeMigrationResponse` Response message for 'ResumeMigration' 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, vmmigration.ResumeMigrationRequest): request = vmmigration.ResumeMigrationRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.resume_migration] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migrating_vm", request.migrating_vm),) ), ) # 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, vmmigration.ResumeMigrationResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def pause_migration( self, request: Optional[Union[vmmigration.PauseMigrationRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Pauses a migration for a VM. If cycle tasks are running they will be cancelled, preserving source task data. Further replication cycles will not be triggered while the VM is paused. .. 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 vmmigration_v1 def sample_pause_migration(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.PauseMigrationRequest( migrating_vm="migrating_vm_value", ) # Make the request operation = client.pause_migration(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.PauseMigrationRequest, dict]): The request object. Request message for 'PauseMigration' 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.vmmigration_v1.types.PauseMigrationResponse` Response message for 'PauseMigration' 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, vmmigration.PauseMigrationRequest): request = vmmigration.PauseMigrationRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.pause_migration] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migrating_vm", request.migrating_vm),) ), ) # 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, vmmigration.PauseMigrationResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def finalize_migration( self, request: Optional[Union[vmmigration.FinalizeMigrationRequest, dict]] = None, *, migrating_vm: 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"""Marks a migration as completed, deleting migration resources that are no longer being used. Only applicable after cutover is done. .. 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 vmmigration_v1 def sample_finalize_migration(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.FinalizeMigrationRequest( migrating_vm="migrating_vm_value", ) # Make the request operation = client.finalize_migration(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.FinalizeMigrationRequest, dict]): The request object. Request message for 'FinalizeMigration' request. migrating_vm (str): Required. The name of the MigratingVm. This corresponds to the ``migrating_vm`` 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.vmmigration_v1.types.FinalizeMigrationResponse` Response message for 'FinalizeMigration' request. """ # 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([migrating_vm]) 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, vmmigration.FinalizeMigrationRequest): request = vmmigration.FinalizeMigrationRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if migrating_vm is not None: request.migrating_vm = migrating_vm # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.finalize_migration] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("migrating_vm", request.migrating_vm),) ), ) # 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, vmmigration.FinalizeMigrationResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def create_clone_job( self, request: Optional[Union[vmmigration.CreateCloneJobRequest, dict]] = None, *, parent: Optional[str] = None, clone_job: Optional[vmmigration.CloneJob] = None, clone_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"""Initiates a Clone of a specific migrating VM. .. 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 vmmigration_v1 def sample_create_clone_job(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateCloneJobRequest( parent="parent_value", clone_job_id="clone_job_id_value", ) # Make the request operation = client.create_clone_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateCloneJobRequest, dict]): The request object. Request message for 'CreateCloneJob' request. parent (str): Required. The Clone's parent. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. clone_job (google.cloud.vmmigration_v1.types.CloneJob): Required. The clone request body. This corresponds to the ``clone_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. clone_job_id (str): Required. The clone job identifier. This corresponds to the ``clone_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.vmmigration_v1.types.CloneJob` CloneJob describes the process of creating a clone of a [MigratingVM][google.cloud.vmmigration.v1.MigratingVm] to the requested target based on the latest successful uploaded snapshots. While the migration cycles of a MigratingVm take place, it is possible to verify the uploaded VM can be started in the cloud, by creating a clone. The clone can be created without any downtime, and it is created using the latest snapshots which are already in the cloud. The cloneJob is only responsible for its work, not its products, which means once it is finished, it will never touch the instance it created. It will only delete it in case of the CloneJob being cancelled or upon failure to clone. """ # 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, clone_job, clone_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, vmmigration.CreateCloneJobRequest): request = vmmigration.CreateCloneJobRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if clone_job is not None: request.clone_job = clone_job if clone_job_id is not None: request.clone_job_id = clone_job_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_clone_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, vmmigration.CloneJob, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def cancel_clone_job( self, request: Optional[Union[vmmigration.CancelCloneJobRequest, 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"""Initiates the cancellation of a running clone 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 vmmigration_v1 def sample_cancel_clone_job(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CancelCloneJobRequest( name="name_value", ) # Make the request operation = client.cancel_clone_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CancelCloneJobRequest, dict]): The request object. Request message for 'CancelCloneJob' request. name (str): Required. The clone job id 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.cloud.vmmigration_v1.types.CancelCloneJobResponse` Response message for 'CancelCloneJob' request. """ # 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, vmmigration.CancelCloneJobRequest): request = vmmigration.CancelCloneJobRequest(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.cancel_clone_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, vmmigration.CancelCloneJobResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def list_clone_jobs( self, request: Optional[Union[vmmigration.ListCloneJobsRequest, 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.ListCloneJobsPager: r"""Lists CloneJobs of a given migrating VM. .. 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 vmmigration_v1 def sample_list_clone_jobs(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListCloneJobsRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_clone_jobs(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListCloneJobsRequest, dict]): The request object. Request message for 'ListCloneJobsRequest' request. parent (str): Required. The parent, which owns this collection of source VMs. 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.vmmigration_v1.services.vm_migration.pagers.ListCloneJobsPager: Response message for 'ListCloneJobs' 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, vmmigration.ListCloneJobsRequest): request = vmmigration.ListCloneJobsRequest(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_clone_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.ListCloneJobsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_clone_job( self, request: Optional[Union[vmmigration.GetCloneJobRequest, 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]] = (), ) -> vmmigration.CloneJob: r"""Gets details of a single CloneJob. .. 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 vmmigration_v1 def sample_get_clone_job(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetCloneJobRequest( name="name_value", ) # Make the request response = client.get_clone_job(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetCloneJobRequest, dict]): The request object. Request message for 'GetCloneJob' request. name (str): Required. The name of the CloneJob. 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.vmmigration_v1.types.CloneJob: CloneJob describes the process of creating a clone of a [MigratingVM][google.cloud.vmmigration.v1.MigratingVm] to the requested target based on the latest successful uploaded snapshots. While the migration cycles of a MigratingVm take place, it is possible to verify the uploaded VM can be started in the cloud, by creating a clone. The clone can be created without any downtime, and it is created using the latest snapshots which are already in the cloud. The cloneJob is only responsible for its work, not its products, which means once it is finished, it will never touch the instance it created. It will only delete it in case of the CloneJob being cancelled or upon failure to clone. """ # 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, vmmigration.GetCloneJobRequest): request = vmmigration.GetCloneJobRequest(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_clone_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_cutover_job( self, request: Optional[Union[vmmigration.CreateCutoverJobRequest, dict]] = None, *, parent: Optional[str] = None, cutover_job: Optional[vmmigration.CutoverJob] = None, cutover_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"""Initiates a Cutover of a specific migrating VM. The returned LRO is completed when the cutover job resource is created and the job is initiated. .. 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 vmmigration_v1 def sample_create_cutover_job(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateCutoverJobRequest( parent="parent_value", cutover_job_id="cutover_job_id_value", ) # Make the request operation = client.create_cutover_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateCutoverJobRequest, dict]): The request object. Request message for 'CreateCutoverJob' request. parent (str): Required. The Cutover's parent. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. cutover_job (google.cloud.vmmigration_v1.types.CutoverJob): Required. The cutover request body. This corresponds to the ``cutover_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. cutover_job_id (str): Required. The cutover job identifier. This corresponds to the ``cutover_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.vmmigration_v1.types.CutoverJob` CutoverJob message describes a cutover of a migrating VM. The CutoverJob is the operation of shutting down the VM, creating a snapshot and clonning the VM using the replicated snapshot. """ # 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, cutover_job, cutover_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, vmmigration.CreateCutoverJobRequest): request = vmmigration.CreateCutoverJobRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if cutover_job is not None: request.cutover_job = cutover_job if cutover_job_id is not None: request.cutover_job_id = cutover_job_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_cutover_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, vmmigration.CutoverJob, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def cancel_cutover_job( self, request: Optional[Union[vmmigration.CancelCutoverJobRequest, 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"""Initiates the cancellation of a running cutover 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 vmmigration_v1 def sample_cancel_cutover_job(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CancelCutoverJobRequest( name="name_value", ) # Make the request operation = client.cancel_cutover_job(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CancelCutoverJobRequest, dict]): The request object. Request message for 'CancelCutoverJob' request. name (str): Required. The cutover job id 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.cloud.vmmigration_v1.types.CancelCutoverJobResponse` Response message for 'CancelCutoverJob' request. """ # 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, vmmigration.CancelCutoverJobRequest): request = vmmigration.CancelCutoverJobRequest(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.cancel_cutover_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, vmmigration.CancelCutoverJobResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def list_cutover_jobs( self, request: Optional[Union[vmmigration.ListCutoverJobsRequest, 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.ListCutoverJobsPager: r"""Lists CutoverJobs of a given migrating VM. .. 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 vmmigration_v1 def sample_list_cutover_jobs(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListCutoverJobsRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_cutover_jobs(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListCutoverJobsRequest, dict]): The request object. Request message for 'ListCutoverJobsRequest' request. parent (str): Required. The parent, which owns this collection of migrating VMs. 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.vmmigration_v1.services.vm_migration.pagers.ListCutoverJobsPager: Response message for 'ListCutoverJobs' 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, vmmigration.ListCutoverJobsRequest): request = vmmigration.ListCutoverJobsRequest(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_cutover_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.ListCutoverJobsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_cutover_job( self, request: Optional[Union[vmmigration.GetCutoverJobRequest, 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]] = (), ) -> vmmigration.CutoverJob: r"""Gets details of a single CutoverJob. .. 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 vmmigration_v1 def sample_get_cutover_job(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetCutoverJobRequest( name="name_value", ) # Make the request response = client.get_cutover_job(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetCutoverJobRequest, dict]): The request object. Request message for 'GetCutoverJob' request. name (str): Required. The name of the CutoverJob. 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.vmmigration_v1.types.CutoverJob: CutoverJob message describes a cutover of a migrating VM. The CutoverJob is the operation of shutting down the VM, creating a snapshot and clonning the VM using the replicated snapshot. """ # 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, vmmigration.GetCutoverJobRequest): request = vmmigration.GetCutoverJobRequest(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_cutover_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 list_groups( self, request: Optional[Union[vmmigration.ListGroupsRequest, 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.ListGroupsPager: r"""Lists Groups 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 vmmigration_v1 def sample_list_groups(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListGroupsRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_groups(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListGroupsRequest, dict]): The request object. Request message for 'ListGroups' request. parent (str): Required. The parent, which owns this collection of groups. 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.vmmigration_v1.services.vm_migration.pagers.ListGroupsPager: Response message for 'ListGroups' 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, vmmigration.ListGroupsRequest): request = vmmigration.ListGroupsRequest(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_groups] # 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.ListGroupsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_group( self, request: Optional[Union[vmmigration.GetGroupRequest, 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]] = (), ) -> vmmigration.Group: r"""Gets details of a single Group. .. 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 vmmigration_v1 def sample_get_group(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetGroupRequest( name="name_value", ) # Make the request response = client.get_group(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetGroupRequest, dict]): The request object. Request message for 'GetGroup' request. name (str): Required. The group name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.Group: Describes message for 'Group' resource. The Group is a collections of several MigratingVms. """ # 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, vmmigration.GetGroupRequest): request = vmmigration.GetGroupRequest(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_group] # 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_group( self, request: Optional[Union[vmmigration.CreateGroupRequest, dict]] = None, *, parent: Optional[str] = None, group: Optional[vmmigration.Group] = None, group_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 Group 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 vmmigration_v1 def sample_create_group(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateGroupRequest( parent="parent_value", group_id="group_id_value", ) # Make the request operation = client.create_group(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateGroupRequest, dict]): The request object. Request message for 'CreateGroup' request. parent (str): Required. The Group's parent. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. group (google.cloud.vmmigration_v1.types.Group): Required. The create request body. This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. group_id (str): Required. The group identifier. This corresponds to the ``group_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.vmmigration_v1.types.Group` Describes message for 'Group' resource. The Group is a collections of several MigratingVms. """ # 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, group, group_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, vmmigration.CreateGroupRequest): request = vmmigration.CreateGroupRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if group is not None: request.group = group if group_id is not None: request.group_id = group_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_group] # 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, vmmigration.Group, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def update_group( self, request: Optional[Union[vmmigration.UpdateGroupRequest, dict]] = None, *, group: Optional[vmmigration.Group] = 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 Group. .. 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 vmmigration_v1 def sample_update_group(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.UpdateGroupRequest( ) # Make the request operation = client.update_group(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.UpdateGroupRequest, dict]): The request object. Update message for 'UpdateGroups' request. group (google.cloud.vmmigration_v1.types.Group): Required. The update request body. This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields to be overwritten in the Group resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.Group` Describes message for 'Group' resource. The Group is a collections of several MigratingVms. """ # 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([group, 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, vmmigration.UpdateGroupRequest): request = vmmigration.UpdateGroupRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if group is not None: request.group = group 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_group] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("group.name", request.group.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, vmmigration.Group, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_group( self, request: Optional[Union[vmmigration.DeleteGroupRequest, 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 Group. .. 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 vmmigration_v1 def sample_delete_group(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.DeleteGroupRequest( name="name_value", ) # Make the request operation = client.delete_group(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.DeleteGroupRequest, dict]): The request object. Request message for 'DeleteGroup' request. name (str): Required. The Group name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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, vmmigration.DeleteGroupRequest): request = vmmigration.DeleteGroupRequest(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_group] # 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=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def add_group_migration( self, request: Optional[Union[vmmigration.AddGroupMigrationRequest, dict]] = None, *, group: 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"""Adds a MigratingVm to a Group. .. 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 vmmigration_v1 def sample_add_group_migration(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.AddGroupMigrationRequest( group="group_value", ) # Make the request operation = client.add_group_migration(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.AddGroupMigrationRequest, dict]): The request object. Request message for 'AddGroupMigration' request. group (str): Required. The full path name of the Group to add to. This corresponds to the ``group`` 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.vmmigration_v1.types.AddGroupMigrationResponse` Response message for 'AddGroupMigration' request. """ # 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([group]) 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, vmmigration.AddGroupMigrationRequest): request = vmmigration.AddGroupMigrationRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if group is not None: request.group = group # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.add_group_migration] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata((("group", request.group),)), ) # 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, vmmigration.AddGroupMigrationResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def remove_group_migration( self, request: Optional[Union[vmmigration.RemoveGroupMigrationRequest, dict]] = None, *, group: 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"""Removes a MigratingVm from a Group. .. 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 vmmigration_v1 def sample_remove_group_migration(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.RemoveGroupMigrationRequest( group="group_value", ) # Make the request operation = client.remove_group_migration(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.RemoveGroupMigrationRequest, dict]): The request object. Request message for 'RemoveMigration' request. group (str): Required. The name of the Group. This corresponds to the ``group`` 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.vmmigration_v1.types.RemoveGroupMigrationResponse` Response message for 'RemoveMigration' request. """ # 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([group]) 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, vmmigration.RemoveGroupMigrationRequest): request = vmmigration.RemoveGroupMigrationRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if group is not None: request.group = group # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.remove_group_migration] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata((("group", request.group),)), ) # 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, vmmigration.RemoveGroupMigrationResponse, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def list_target_projects( self, request: Optional[Union[vmmigration.ListTargetProjectsRequest, 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.ListTargetProjectsPager: r"""Lists TargetProjects in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is ``global``. .. 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 vmmigration_v1 def sample_list_target_projects(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListTargetProjectsRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_target_projects(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListTargetProjectsRequest, dict]): The request object. Request message for 'ListTargetProjects' call. parent (str): Required. The parent, which owns this collection of targets. 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.vmmigration_v1.services.vm_migration.pagers.ListTargetProjectsPager: Response message for 'ListTargetProjects' call. 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, vmmigration.ListTargetProjectsRequest): request = vmmigration.ListTargetProjectsRequest(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_target_projects] # 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.ListTargetProjectsPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_target_project( self, request: Optional[Union[vmmigration.GetTargetProjectRequest, 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]] = (), ) -> vmmigration.TargetProject: r"""Gets details of a single TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is ``global``. .. 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 vmmigration_v1 def sample_get_target_project(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetTargetProjectRequest( name="name_value", ) # Make the request response = client.get_target_project(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetTargetProjectRequest, dict]): The request object. Request message for 'GetTargetProject' call. name (str): Required. The TargetProject name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.TargetProject: TargetProject message represents a target Compute Engine project for a migration or a clone. """ # 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, vmmigration.GetTargetProjectRequest): request = vmmigration.GetTargetProjectRequest(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_target_project] # 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_target_project( self, request: Optional[Union[vmmigration.CreateTargetProjectRequest, dict]] = None, *, parent: Optional[str] = None, target_project: Optional[vmmigration.TargetProject] = None, target_project_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 TargetProject in a given project. NOTE: TargetProject is a global resource; hence the only supported value for location is ``global``. .. 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 vmmigration_v1 def sample_create_target_project(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.CreateTargetProjectRequest( parent="parent_value", target_project_id="target_project_id_value", ) # Make the request operation = client.create_target_project(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.CreateTargetProjectRequest, dict]): The request object. Request message for 'CreateTargetProject' request. parent (str): Required. The TargetProject's parent. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. target_project (google.cloud.vmmigration_v1.types.TargetProject): Required. The create request body. This corresponds to the ``target_project`` field on the ``request`` instance; if ``request`` is provided, this should not be set. target_project_id (str): Required. The target_project identifier. This corresponds to the ``target_project_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.vmmigration_v1.types.TargetProject` TargetProject message represents a target Compute Engine project for a migration or a clone. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, target_project, target_project_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, vmmigration.CreateTargetProjectRequest): request = vmmigration.CreateTargetProjectRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if parent is not None: request.parent = parent if target_project is not None: request.target_project = target_project if target_project_id is not None: request.target_project_id = target_project_id # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_target_project] # 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, vmmigration.TargetProject, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def update_target_project( self, request: Optional[Union[vmmigration.UpdateTargetProjectRequest, dict]] = None, *, target_project: Optional[vmmigration.TargetProject] = 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 TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is ``global``. .. 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 vmmigration_v1 def sample_update_target_project(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.UpdateTargetProjectRequest( ) # Make the request operation = client.update_target_project(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.UpdateTargetProjectRequest, dict]): The request object. Update message for 'UpdateTargetProject' request. target_project (google.cloud.vmmigration_v1.types.TargetProject): Required. The update request body. This corresponds to the ``target_project`` field on the ``request`` instance; if ``request`` is provided, this should not be set. update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields to be overwritten in the TargetProject resource by the update. The fields specified in the update_mask are relative to the resource, not the full request. A field will be overwritten if it is in the mask. If the user does not provide a mask then all fields will be overwritten. This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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.vmmigration_v1.types.TargetProject` TargetProject message represents a target Compute Engine project for a migration or a clone. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([target_project, 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, vmmigration.UpdateTargetProjectRequest): request = vmmigration.UpdateTargetProjectRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if target_project is not None: request.target_project = target_project 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_target_project] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata( (("target_project.name", request.target_project.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, vmmigration.TargetProject, metadata_type=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def delete_target_project( self, request: Optional[Union[vmmigration.DeleteTargetProjectRequest, 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 TargetProject. NOTE: TargetProject is a global resource; hence the only supported value for location is ``global``. .. 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 vmmigration_v1 def sample_delete_target_project(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.DeleteTargetProjectRequest( name="name_value", ) # Make the request operation = client.delete_target_project(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.DeleteTargetProjectRequest, dict]): The request object. Request message for 'DeleteTargetProject' request. name (str): Required. The TargetProject name. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.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, vmmigration.DeleteTargetProjectRequest): request = vmmigration.DeleteTargetProjectRequest(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_target_project] # 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=vmmigration.OperationMetadata, ) # Done; return the response. return response
[docs] def list_replication_cycles( self, request: Optional[Union[vmmigration.ListReplicationCyclesRequest, 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.ListReplicationCyclesPager: r"""Lists ReplicationCycles in a given MigratingVM. .. 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 vmmigration_v1 def sample_list_replication_cycles(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.ListReplicationCyclesRequest( parent="parent_value", page_token="page_token_value", ) # Make the request page_result = client.list_replication_cycles(request=request) # Handle the response for response in page_result: print(response) Args: request (Union[google.cloud.vmmigration_v1.types.ListReplicationCyclesRequest, dict]): The request object. Request message for 'LisReplicationCyclesRequest' request. parent (str): Required. The parent, which owns this collection of ReplicationCycles. 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.vmmigration_v1.services.vm_migration.pagers.ListReplicationCyclesPager: Response message for 'ListReplicationCycles' 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, vmmigration.ListReplicationCyclesRequest): request = vmmigration.ListReplicationCyclesRequest(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_replication_cycles] # 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.ListReplicationCyclesPager( method=rpc, request=request, response=response, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
[docs] def get_replication_cycle( self, request: Optional[Union[vmmigration.GetReplicationCycleRequest, 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]] = (), ) -> vmmigration.ReplicationCycle: r"""Gets details of a single ReplicationCycle. .. 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 vmmigration_v1 def sample_get_replication_cycle(): # Create a client client = vmmigration_v1.VmMigrationClient() # Initialize request argument(s) request = vmmigration_v1.GetReplicationCycleRequest( name="name_value", ) # Make the request response = client.get_replication_cycle(request=request) # Handle the response print(response) Args: request (Union[google.cloud.vmmigration_v1.types.GetReplicationCycleRequest, dict]): The request object. Request message for 'GetReplicationCycle' request. name (str): Required. The name of the ReplicationCycle. 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.vmmigration_v1.types.ReplicationCycle: ReplicationCycle contains information about the current replication cycle status. """ # 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, vmmigration.GetReplicationCycleRequest): request = vmmigration.GetReplicationCycleRequest(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_replication_cycle] # 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
def __enter__(self) -> "VmMigrationClient": 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 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__ = ("VmMigrationClient",)