def list(self, project, service_account_file=""):
        stub = snapshot_pb2_grpc.ComputeBetaSnapshotServiceStub(channel.Channel())
        request = snapshot_pb2.ListComputeBetaSnapshotRequest()
        request.service_account_file = service_account_file
        request.Project = project

        return stub.ListComputeBetaSnapshot(request).items
Example #2
0
    def delete(self, project, name, service_account_file=""):
        stub = snapshot_pb2_grpc.ComputeBetaSnapshotServiceStub(
            channel.Channel())
        request = snapshot_pb2.DeleteComputeBetaSnapshotRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Name = name

        response = stub.DeleteComputeBetaSnapshot(request)
    def apply(self):
        stub = snapshot_pb2_grpc.ComputeBetaSnapshotServiceStub(channel.Channel())
        request = snapshot_pb2.ApplyComputeBetaSnapshotRequest()
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if Primitive.to_proto(self.description):
            request.resource.description = Primitive.to_proto(self.description)

        if Primitive.to_proto(self.source_disk):
            request.resource.source_disk = Primitive.to_proto(self.source_disk)

        if SnapshotSnapshotEncryptionKey.to_proto(self.snapshot_encryption_key):
            request.resource.snapshot_encryption_key.CopyFrom(
                SnapshotSnapshotEncryptionKey.to_proto(self.snapshot_encryption_key)
            )
        else:
            request.resource.ClearField("snapshot_encryption_key")
        if SnapshotSourceDiskEncryptionKey.to_proto(self.source_disk_encryption_key):
            request.resource.source_disk_encryption_key.CopyFrom(
                SnapshotSourceDiskEncryptionKey.to_proto(
                    self.source_disk_encryption_key
                )
            )
        else:
            request.resource.ClearField("source_disk_encryption_key")
        if Primitive.to_proto(self.labels):
            request.resource.labels = Primitive.to_proto(self.labels)

        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if Primitive.to_proto(self.zone):
            request.resource.zone = Primitive.to_proto(self.zone)

        request.service_account_file = self.service_account_file

        response = stub.ApplyComputeBetaSnapshot(request)
        self.name = Primitive.from_proto(response.name)
        self.description = Primitive.from_proto(response.description)
        self.source_disk = Primitive.from_proto(response.source_disk)
        self.disk_size_gb = Primitive.from_proto(response.disk_size_gb)
        self.storage_bytes = Primitive.from_proto(response.storage_bytes)
        self.license = Primitive.from_proto(response.license)
        self.snapshot_encryption_key = SnapshotSnapshotEncryptionKey.from_proto(
            response.snapshot_encryption_key
        )
        self.source_disk_encryption_key = SnapshotSourceDiskEncryptionKey.from_proto(
            response.source_disk_encryption_key
        )
        self.self_link = Primitive.from_proto(response.self_link)
        self.labels = Primitive.from_proto(response.labels)
        self.project = Primitive.from_proto(response.project)
        self.zone = Primitive.from_proto(response.zone)
        self.id = Primitive.from_proto(response.id)
    def delete(self):
        stub = snapshot_pb2_grpc.ComputeBetaSnapshotServiceStub(
            channel.Channel())
        request = snapshot_pb2.DeleteComputeBetaSnapshotRequest()
        request.service_account_file = self.service_account_file
        if Primitive.to_proto(self.name):
            request.resource.name = Primitive.to_proto(self.name)

        if Primitive.to_proto(self.description):
            request.resource.description = Primitive.to_proto(self.description)

        if Primitive.to_proto(self.source_disk):
            request.resource.source_disk = Primitive.to_proto(self.source_disk)

        if SnapshotSnapshotEncryptionKey.to_proto(
                self.snapshot_encryption_key):
            request.resource.snapshot_encryption_key.CopyFrom(
                SnapshotSnapshotEncryptionKey.to_proto(
                    self.snapshot_encryption_key))
        else:
            request.resource.ClearField("snapshot_encryption_key")
        if SnapshotSourceDiskEncryptionKey.to_proto(
                self.source_disk_encryption_key):
            request.resource.source_disk_encryption_key.CopyFrom(
                SnapshotSourceDiskEncryptionKey.to_proto(
                    self.source_disk_encryption_key))
        else:
            request.resource.ClearField("source_disk_encryption_key")
        if Primitive.to_proto(self.labels):
            request.resource.labels = Primitive.to_proto(self.labels)

        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

        if Primitive.to_proto(self.zone):
            request.resource.zone = Primitive.to_proto(self.zone)

        response = stub.DeleteComputeBetaSnapshot(request)