def test_default(self): from google.protobuf.struct_pb2 import Struct from google.cloud._testing import _Monkey from google.cloud import operation as MUT type_url_map = {} with _Monkey(MUT, _TYPE_URL_MAP=type_url_map): self._call_fut(Struct) type_url = MUT._compute_type_url(Struct) self.assertEqual(type_url_map, {type_url: Struct})
from google.cloud.bigtable._generated import ( bigtable_instance_admin_pb2 as messages_v2_pb2) from google.cloud.operation import Operation from google.cloud.operation import _compute_type_url from google.cloud.operation import _register_type_url _CLUSTER_NAME_RE = re.compile(r'^projects/(?P<project>[^/]+)/' r'instances/(?P<instance>[^/]+)/clusters/' r'(?P<cluster_id>[a-z][-a-z0-9]*)$') DEFAULT_SERVE_NODES = 3 """Default number of nodes to use when creating a cluster.""" _UPDATE_CLUSTER_METADATA_URL = _compute_type_url( messages_v2_pb2.UpdateClusterMetadata) _register_type_url( _UPDATE_CLUSTER_METADATA_URL, messages_v2_pb2.UpdateClusterMetadata) def _prepare_create_request(cluster): """Creates a protobuf request for a CreateCluster request. :type cluster: :class:`Cluster` :param cluster: The cluster to be created. :rtype: :class:`.messages_v2_pb2.CreateClusterRequest` :returns: The CreateCluster request object containing the cluster info. """ return messages_v2_pb2.CreateClusterRequest( parent=cluster._instance.name,
from google.cloud.bigtable._generated import ( bigtable_table_admin_pb2 as table_messages_v2_pb2) from google.cloud.bigtable.cluster import Cluster from google.cloud.bigtable.cluster import DEFAULT_SERVE_NODES from google.cloud.bigtable.table import Table from google.cloud.operation import Operation from google.cloud.operation import _compute_type_url from google.cloud.operation import _register_type_url _EXISTING_INSTANCE_LOCATION_ID = 'see-existing-cluster' _INSTANCE_NAME_RE = re.compile(r'^projects/(?P<project>[^/]+)/' r'instances/(?P<instance_id>[a-z][-a-z0-9]*)$') _CREATE_INSTANCE_METADATA_URL = _compute_type_url( messages_v2_pb2.CreateInstanceMetadata) _register_type_url( _CREATE_INSTANCE_METADATA_URL, messages_v2_pb2.CreateInstanceMetadata) def _prepare_create_request(instance): """Creates a protobuf request for a CreateInstance request. :type instance: :class:`Instance` :param instance: The instance to be created. :rtype: :class:`.messages_v2_pb2.CreateInstanceRequest` :returns: The CreateInstance request object containing the instance info. """ parent_name = ('projects/' + instance._client.project) message = messages_v2_pb2.CreateInstanceRequest(
def _call_fut(self, klass, prefix=None): from google.cloud.operation import _compute_type_url if prefix is None: return _compute_type_url(klass) return _compute_type_url(klass, prefix)