def test_with_create_cluster_metadata(self): from google.protobuf import any_pb2 from google.protobuf.timestamp_pb2 import Timestamp from gcloud.bigtable._generated import (bigtable_cluster_data_pb2 as data_pb2) from gcloud.bigtable._generated import ( bigtable_cluster_service_messages_pb2 as messages_pb2) type_url = ('type.googleapis.com/' + messages_pb2._CREATECLUSTERMETADATA.full_name) metadata = messages_pb2.CreateClusterMetadata( request_time=Timestamp(seconds=1, nanos=1234), finish_time=Timestamp(seconds=10, nanos=891011), original_request=messages_pb2.CreateClusterRequest( name='foo', cluster_id='bar', cluster=data_pb2.Cluster( display_name='quux', serve_nodes=1337, ), ), ) any_val = any_pb2.Any( type_url=type_url, value=metadata.SerializeToString(), ) result = self._callFUT(any_val) self.assertEqual(result, metadata)
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_pb2.CreateClusterRequest` :returns: The CreateCluster request object containing the cluster info. """ zone_full_name = ('projects/' + cluster._client.project + '/zones/' + cluster.zone) return messages_pb2.CreateClusterRequest( name=zone_full_name, cluster_id=cluster.cluster_id, cluster=data_pb2.Cluster( display_name=cluster.display_name, serve_nodes=cluster.serve_nodes, ), )