def apply(self): stub = instance_template_pb2_grpc.ComputeInstanceTemplateServiceStub( channel.Channel()) request = instance_template_pb2.ApplyComputeInstanceTemplateRequest() if Primitive.to_proto(self.description): request.resource.description = Primitive.to_proto(self.description) if Primitive.to_proto(self.self_link): request.resource.self_link = Primitive.to_proto(self.self_link) if Primitive.to_proto(self.name): request.resource.name = Primitive.to_proto(self.name) if InstanceTemplateProperties.to_proto(self.properties): request.resource.properties.CopyFrom( InstanceTemplateProperties.to_proto(self.properties)) else: request.resource.ClearField("properties") if Primitive.to_proto(self.project): request.resource.project = Primitive.to_proto(self.project) request.service_account_file = self.service_account_file response = stub.ApplyComputeInstanceTemplate(request) self.creation_timestamp = Primitive.from_proto( response.creation_timestamp) self.description = Primitive.from_proto(response.description) self.id = Primitive.from_proto(response.id) self.self_link = Primitive.from_proto(response.self_link) self.name = Primitive.from_proto(response.name) self.properties = InstanceTemplateProperties.from_proto( response.properties) self.project = Primitive.from_proto(response.project)
def delete(self): stub = instance_template_pb2_grpc.ComputeInstanceTemplateServiceStub( channel.Channel() ) request = instance_template_pb2.DeleteComputeInstanceTemplateRequest() request.service_account_file = self.service_account_file if Primitive.to_proto(self.description): request.resource.description = Primitive.to_proto(self.description) if Primitive.to_proto(self.self_link): request.resource.self_link = Primitive.to_proto(self.self_link) if Primitive.to_proto(self.name): request.resource.name = Primitive.to_proto(self.name) if InstanceTemplateProperties.to_proto(self.properties): request.resource.properties.CopyFrom( InstanceTemplateProperties.to_proto(self.properties) ) else: request.resource.ClearField("properties") if Primitive.to_proto(self.project): request.resource.project = Primitive.to_proto(self.project) response = stub.DeleteComputeInstanceTemplate(request)
def list(self, project, service_account_file=""): stub = instance_template_pb2_grpc.ComputeInstanceTemplateServiceStub( channel.Channel()) request = instance_template_pb2.ListComputeInstanceTemplateRequest() request.service_account_file = service_account_file request.Project = project return stub.ListComputeInstanceTemplate(request).items
def delete(self, project, name, service_account_file=""): stub = instance_template_pb2_grpc.ComputeInstanceTemplateServiceStub( channel.Channel()) request = instance_template_pb2.DeleteComputeInstanceTemplateRequest() request.service_account_file = service_account_file request.Project = project request.Name = name response = stub.DeleteComputeInstanceTemplate(request)