def list(self, project, location, service_account_file=""): stub = disk_pb2_grpc.ComputeDiskServiceStub(channel.Channel()) request = disk_pb2.ListComputeDiskRequest() request.service_account_file = service_account_file request.Project = project request.Location = location return stub.ListComputeDisk(request).items
def delete(self, project, location, name, service_account_file=""): stub = disk_pb2_grpc.ComputeDiskServiceStub(channel.Channel()) request = disk_pb2.DeleteComputeDiskRequest() request.service_account_file = service_account_file request.Project = project request.Location = location request.Name = name response = stub.DeleteComputeDisk(request)
def apply(self): stub = disk_pb2_grpc.ComputeDiskServiceStub(channel.Channel()) request = disk_pb2.ApplyComputeDiskRequest() if Primitive.to_proto(self.description): request.resource.description = Primitive.to_proto(self.description) if DiskEncryptionKey.to_proto(self.disk_encryption_key): request.resource.disk_encryption_key.CopyFrom( DiskEncryptionKey.to_proto(self.disk_encryption_key)) else: request.resource.ClearField("disk_encryption_key") if DiskGuestOsFeatureArray.to_proto(self.guest_os_feature): request.resource.guest_os_feature.extend( DiskGuestOsFeatureArray.to_proto(self.guest_os_feature)) if Primitive.to_proto(self.labels): request.resource.labels = Primitive.to_proto(self.labels) if Primitive.to_proto(self.license): request.resource.license.extend(Primitive.to_proto(self.license)) if Primitive.to_proto(self.name): request.resource.name = Primitive.to_proto(self.name) if Primitive.to_proto(self.region): request.resource.region = Primitive.to_proto(self.region) if Primitive.to_proto(self.replica_zones): request.resource.replica_zones.extend( Primitive.to_proto(self.replica_zones)) if Primitive.to_proto(self.resource_policy): request.resource.resource_policy.extend( Primitive.to_proto(self.resource_policy)) if Primitive.to_proto(self.size_gb): request.resource.size_gb = Primitive.to_proto(self.size_gb) if Primitive.to_proto(self.source_image): request.resource.source_image = Primitive.to_proto( self.source_image) if DiskEncryptionKey.to_proto(self.source_image_encryption_key): request.resource.source_image_encryption_key.CopyFrom( DiskEncryptionKey.to_proto(self.source_image_encryption_key)) else: request.resource.ClearField("source_image_encryption_key") if Primitive.to_proto(self.source_snapshot): request.resource.source_snapshot = Primitive.to_proto( self.source_snapshot) if DiskEncryptionKey.to_proto(self.source_snapshot_encryption_key): request.resource.source_snapshot_encryption_key.CopyFrom( DiskEncryptionKey.to_proto( self.source_snapshot_encryption_key)) else: request.resource.ClearField("source_snapshot_encryption_key") if Primitive.to_proto(self.type): request.resource.type = Primitive.to_proto(self.type) if Primitive.to_proto(self.project): request.resource.project = Primitive.to_proto(self.project) if Primitive.to_proto(self.id): request.resource.id = Primitive.to_proto(self.id) if Primitive.to_proto(self.options): request.resource.options = Primitive.to_proto(self.options) if Primitive.to_proto(self.licenses): request.resource.licenses.extend(Primitive.to_proto(self.licenses)) if DiskGuestOsFeaturesArray.to_proto(self.guest_os_features): request.resource.guest_os_features.extend( DiskGuestOsFeaturesArray.to_proto(self.guest_os_features)) if int64Array.to_proto(self.license_codes): request.resource.license_codes.extend( int64Array.to_proto(self.license_codes)) if Primitive.to_proto(self.physical_block_size_bytes): request.resource.physical_block_size_bytes = Primitive.to_proto( self.physical_block_size_bytes) if Primitive.to_proto(self.resource_policies): request.resource.resource_policies.extend( Primitive.to_proto(self.resource_policies)) if Primitive.to_proto(self.source_disk): request.resource.source_disk = Primitive.to_proto(self.source_disk) if Primitive.to_proto(self.source_disk_id): request.resource.source_disk_id = Primitive.to_proto( self.source_disk_id) if Primitive.to_proto(self.location): request.resource.location = Primitive.to_proto(self.location) request.service_account_file = self.service_account_file response = stub.ApplyComputeDisk(request) self.self_link = Primitive.from_proto(response.self_link) self.description = Primitive.from_proto(response.description) self.disk_encryption_key = DiskEncryptionKey.from_proto( response.disk_encryption_key) self.guest_os_feature = DiskGuestOsFeatureArray.from_proto( response.guest_os_feature) self.labels = Primitive.from_proto(response.labels) self.label_fingerprint = Primitive.from_proto( response.label_fingerprint) self.license = Primitive.from_proto(response.license) self.name = Primitive.from_proto(response.name) self.region = Primitive.from_proto(response.region) self.replica_zones = Primitive.from_proto(response.replica_zones) self.resource_policy = Primitive.from_proto(response.resource_policy) self.size_gb = Primitive.from_proto(response.size_gb) self.source_image = Primitive.from_proto(response.source_image) self.source_image_encryption_key = DiskEncryptionKey.from_proto( response.source_image_encryption_key) self.source_image_id = Primitive.from_proto(response.source_image_id) self.source_snapshot = Primitive.from_proto(response.source_snapshot) self.source_snapshot_encryption_key = DiskEncryptionKey.from_proto( response.source_snapshot_encryption_key) self.source_snapshot_id = Primitive.from_proto( response.source_snapshot_id) self.type = Primitive.from_proto(response.type) self.zone = Primitive.from_proto(response.zone) self.project = Primitive.from_proto(response.project) self.id = Primitive.from_proto(response.id) self.status = DiskStatusEnum.from_proto(response.status) self.options = Primitive.from_proto(response.options) self.licenses = Primitive.from_proto(response.licenses) self.guest_os_features = DiskGuestOsFeaturesArray.from_proto( response.guest_os_features) self.last_attach_timestamp = Primitive.from_proto( response.last_attach_timestamp) self.last_detach_timestamp = Primitive.from_proto( response.last_detach_timestamp) self.users = Primitive.from_proto(response.users) self.license_codes = int64Array.from_proto(response.license_codes) self.physical_block_size_bytes = Primitive.from_proto( response.physical_block_size_bytes) self.resource_policies = Primitive.from_proto( response.resource_policies) self.source_disk = Primitive.from_proto(response.source_disk) self.source_disk_id = Primitive.from_proto(response.source_disk_id) self.location = Primitive.from_proto(response.location)
def delete(self): stub = disk_pb2_grpc.ComputeDiskServiceStub(channel.Channel()) request = disk_pb2.DeleteComputeDiskRequest() request.service_account_file = self.service_account_file if Primitive.to_proto(self.description): request.resource.description = Primitive.to_proto(self.description) if DiskEncryptionKey.to_proto(self.disk_encryption_key): request.resource.disk_encryption_key.CopyFrom( DiskEncryptionKey.to_proto(self.disk_encryption_key)) else: request.resource.ClearField("disk_encryption_key") if DiskGuestOsFeatureArray.to_proto(self.guest_os_feature): request.resource.guest_os_feature.extend( DiskGuestOsFeatureArray.to_proto(self.guest_os_feature)) if Primitive.to_proto(self.labels): request.resource.labels = Primitive.to_proto(self.labels) if Primitive.to_proto(self.license): request.resource.license.extend(Primitive.to_proto(self.license)) if Primitive.to_proto(self.name): request.resource.name = Primitive.to_proto(self.name) if Primitive.to_proto(self.region): request.resource.region = Primitive.to_proto(self.region) if Primitive.to_proto(self.replica_zones): request.resource.replica_zones.extend( Primitive.to_proto(self.replica_zones)) if Primitive.to_proto(self.resource_policy): request.resource.resource_policy.extend( Primitive.to_proto(self.resource_policy)) if Primitive.to_proto(self.size_gb): request.resource.size_gb = Primitive.to_proto(self.size_gb) if Primitive.to_proto(self.source_image): request.resource.source_image = Primitive.to_proto( self.source_image) if DiskEncryptionKey.to_proto(self.source_image_encryption_key): request.resource.source_image_encryption_key.CopyFrom( DiskEncryptionKey.to_proto(self.source_image_encryption_key)) else: request.resource.ClearField("source_image_encryption_key") if Primitive.to_proto(self.source_snapshot): request.resource.source_snapshot = Primitive.to_proto( self.source_snapshot) if DiskEncryptionKey.to_proto(self.source_snapshot_encryption_key): request.resource.source_snapshot_encryption_key.CopyFrom( DiskEncryptionKey.to_proto( self.source_snapshot_encryption_key)) else: request.resource.ClearField("source_snapshot_encryption_key") if Primitive.to_proto(self.type): request.resource.type = Primitive.to_proto(self.type) if Primitive.to_proto(self.project): request.resource.project = Primitive.to_proto(self.project) if Primitive.to_proto(self.id): request.resource.id = Primitive.to_proto(self.id) if Primitive.to_proto(self.options): request.resource.options = Primitive.to_proto(self.options) if Primitive.to_proto(self.licenses): request.resource.licenses.extend(Primitive.to_proto(self.licenses)) if DiskGuestOsFeaturesArray.to_proto(self.guest_os_features): request.resource.guest_os_features.extend( DiskGuestOsFeaturesArray.to_proto(self.guest_os_features)) if int64Array.to_proto(self.license_codes): request.resource.license_codes.extend( int64Array.to_proto(self.license_codes)) if Primitive.to_proto(self.physical_block_size_bytes): request.resource.physical_block_size_bytes = Primitive.to_proto( self.physical_block_size_bytes) if Primitive.to_proto(self.resource_policies): request.resource.resource_policies.extend( Primitive.to_proto(self.resource_policies)) if Primitive.to_proto(self.source_disk): request.resource.source_disk = Primitive.to_proto(self.source_disk) if Primitive.to_proto(self.source_disk_id): request.resource.source_disk_id = Primitive.to_proto( self.source_disk_id) if Primitive.to_proto(self.location): request.resource.location = Primitive.to_proto(self.location) response = stub.DeleteComputeDisk(request)