def list(self, project, service_account_file=""):
        stub = index_pb2_grpc.DatastoreIndexServiceStub(channel.Channel())
        request = index_pb2.ListDatastoreIndexRequest()
        request.service_account_file = service_account_file
        request.Project = project

        return stub.ListDatastoreIndex(request).items
    def apply(self):
        stub = index_pb2_grpc.DatastoreIndexServiceStub(channel.Channel())
        request = index_pb2.ApplyDatastoreIndexRequest()
        if IndexAncestorEnum.to_proto(self.ancestor):
            request.resource.ancestor = IndexAncestorEnum.to_proto(
                self.ancestor)

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

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

        if IndexPropertiesArray.to_proto(self.properties):
            request.resource.properties.extend(
                IndexPropertiesArray.to_proto(self.properties))
        request.service_account_file = self.service_account_file

        response = stub.ApplyDatastoreIndex(request)
        self.ancestor = IndexAncestorEnum.from_proto(response.ancestor)
        self.index_id = Primitive.from_proto(response.index_id)
        self.kind = Primitive.from_proto(response.kind)
        self.project = Primitive.from_proto(response.project)
        self.properties = IndexPropertiesArray.from_proto(response.properties)
        self.state = IndexStateEnum.from_proto(response.state)
Ejemplo n.º 3
0
    def delete(self, project, indexId, service_account_file=""):
        stub = index_pb2_grpc.DatastoreIndexServiceStub(channel.Channel())
        request = index_pb2.DeleteDatastoreIndexRequest()
        request.service_account_file = service_account_file
        request.Project = project

        request.IndexId = indexId

        response = stub.DeleteDatastoreIndex(request)
    def delete(self):
        stub = index_pb2_grpc.DatastoreIndexServiceStub(channel.Channel())
        request = index_pb2.DeleteDatastoreIndexRequest()
        request.service_account_file = self.service_account_file
        if IndexAncestorEnum.to_proto(self.ancestor):
            request.resource.ancestor = IndexAncestorEnum.to_proto(
                self.ancestor)

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

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

        if IndexPropertiesArray.to_proto(self.properties):
            request.resource.properties.extend(
                IndexPropertiesArray.to_proto(self.properties))
        response = stub.DeleteDatastoreIndex(request)