def delete(self):
        stub = instance_pb2_grpc.FileInstanceServiceStub(channel.Channel())
        request = instance_pb2.DeleteFileInstanceRequest()
        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 InstanceTierEnum.to_proto(self.tier):
            request.resource.tier = InstanceTierEnum.to_proto(self.tier)

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

        if InstanceFileSharesArray.to_proto(self.file_shares):
            request.resource.file_shares.extend(
                InstanceFileSharesArray.to_proto(self.file_shares))
        if InstanceNetworksArray.to_proto(self.networks):
            request.resource.networks.extend(
                InstanceNetworksArray.to_proto(self.networks))
        if Primitive.to_proto(self.project):
            request.resource.project = Primitive.to_proto(self.project)

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

        response = stub.DeleteFileInstance(request)
Exemple #2
0
    def list(self, project, location, service_account_file=""):
        stub = instance_pb2_grpc.FileInstanceServiceStub(channel.Channel())
        request = instance_pb2.ListFileInstanceRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.Location = location

        return stub.ListFileInstance(request).items
Exemple #3
0
    def apply(self):
        stub = instance_pb2_grpc.FileInstanceServiceStub(channel.Channel())
        request = instance_pb2.ApplyFileInstanceRequest()
        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 InstanceTierEnum.to_proto(self.tier):
            request.resource.tier = InstanceTierEnum.to_proto(self.tier)

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

        if InstanceFileSharesArray.to_proto(self.file_shares):
            request.resource.file_shares.extend(
                InstanceFileSharesArray.to_proto(self.file_shares))
        if InstanceNetworksArray.to_proto(self.networks):
            request.resource.networks.extend(
                InstanceNetworksArray.to_proto(self.networks))
        if Primitive.to_proto(self.etag):
            request.resource.etag = Primitive.to_proto(self.etag)

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

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

        request.service_account_file = self.service_account_file

        response = stub.ApplyFileInstance(request)
        self.name = Primitive.from_proto(response.name)
        self.description = Primitive.from_proto(response.description)
        self.state = InstanceStateEnum.from_proto(response.state)
        self.status_message = Primitive.from_proto(response.status_message)
        self.create_time = Primitive.from_proto(response.create_time)
        self.tier = InstanceTierEnum.from_proto(response.tier)
        self.labels = Primitive.from_proto(response.labels)
        self.file_shares = InstanceFileSharesArray.from_proto(
            response.file_shares)
        self.networks = InstanceNetworksArray.from_proto(response.networks)
        self.etag = Primitive.from_proto(response.etag)
        self.project = Primitive.from_proto(response.project)
        self.location = Primitive.from_proto(response.location)