# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc

from flyteidl.datacatalog import datacatalog_pb2 as flyteidl_dot_datacatalog_dot_datacatalog__pb2


class DataCatalogStub(object):
  """
  Data Catalog service definition
  Data Catalog is a service for indexing parameterized, strongly-typed data artifacts across revisions.
  Artifacts are associated with a Dataset, and can be tagged for retrieval.
  """

  def __init__(self, channel):
    """Constructor.

    Args:
      channel: A grpc.Channel.
    """
    self.CreateDataset = channel.unary_unary(
        '/datacatalog.DataCatalog/CreateDataset',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateDatasetRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateDatasetResponse.FromString,
        )
    self.GetDataset = channel.unary_unary(
        '/datacatalog.DataCatalog/GetDataset',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetDatasetRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetDatasetResponse.FromString,
        )
    self.CreateArtifact = channel.unary_unary(
        '/datacatalog.DataCatalog/CreateArtifact',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateArtifactRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateArtifactResponse.FromString,
        )
    self.GetArtifact = channel.unary_unary(
        '/datacatalog.DataCatalog/GetArtifact',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetArtifactRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetArtifactResponse.FromString,
        )
    self.AddTag = channel.unary_unary(
        '/datacatalog.DataCatalog/AddTag',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.AddTagRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.AddTagResponse.FromString,
        )
    self.ListArtifacts = channel.unary_unary(
        '/datacatalog.DataCatalog/ListArtifacts',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListArtifactsRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListArtifactsResponse.FromString,
        )
    self.ListDatasets = channel.unary_unary(
        '/datacatalog.DataCatalog/ListDatasets',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListDatasetsRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListDatasetsResponse.FromString,
        )
    self.GetOrReserveArtifact = channel.unary_unary(
        '/datacatalog.DataCatalog/GetOrReserveArtifact',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetOrReserveArtifactRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetOrReserveArtifactResponse.FromString,
        )
    self.ExtendReservation = channel.unary_unary(
        '/datacatalog.DataCatalog/ExtendReservation',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ExtendReservationRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ExtendReservationResponse.FromString,
        )
    self.ReleaseReservation = channel.unary_unary(
        '/datacatalog.DataCatalog/ReleaseReservation',
        request_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ReleaseReservationRequest.SerializeToString,
        response_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ReleaseReservationResponse.FromString,
        )


class DataCatalogServicer(object):
  """
  Data Catalog service definition
  Data Catalog is a service for indexing parameterized, strongly-typed data artifacts across revisions.
  Artifacts are associated with a Dataset, and can be tagged for retrieval.
  """

  def CreateDataset(self, request, context):
    """Create a new Dataset. Datasets are unique based on the DatasetID. Datasets are logical groupings of artifacts.
    Each dataset can have one or more artifacts
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def GetDataset(self, request, context):
    """Get a Dataset by the DatasetID. This returns the Dataset with the associated metadata.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def CreateArtifact(self, request, context):
    """Create an artifact and the artifact data associated with it. An artifact can be a hive partition or arbitrary
    files or data values
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def GetArtifact(self, request, context):
    """Retrieve an artifact by an identifying handle. This returns an artifact along with the artifact data.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def AddTag(self, request, context):
    """Associate a tag with an artifact. Tags are unique within a Dataset.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def ListArtifacts(self, request, context):
    """Return a paginated list of artifacts
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def ListDatasets(self, request, context):
    """Return a paginated list of datasets
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def GetOrReserveArtifact(self, request, context):
    """Get an artifact and the corresponding data. If the artifact does not exist,
    try to reserve a spot for populating the artifact.
    Once you preserve a spot, you should call ExtendReservation API periodically
    to extend the reservation. Otherwise, the reservation can expire and other
    tasks may take the spot.
    If the same owner_id calls this API for the same dataset and it has an active reservation and the artifacts have not been written yet by a different owner, the API will respond with an Acquired Reservation Status (providing idempotency).
    Note: We may have multiple concurrent tasks with the same signature
    and the same input that try to populate the same artifact at the same time.
    Thus with reservation, only one task can run at a time, until the reservation
    expires.
    Note: If task A does not extend the reservation in time and the reservation
    expires, another task B may take over the reservation, resulting in two tasks
    A and B running in parallel. So a third task C may get the Artifact from A or B,
    whichever writes last.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def ExtendReservation(self, request, context):
    """Extend the reservation to keep it from expiring. If the reservation expires,
    other tasks can take over the reservation by calling GetOrReserveArtifact.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')

  def ReleaseReservation(self, request, context):
    """Release the reservation when the task holding the spot fails so that the other tasks
    can grab the spot.
    """
    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
    context.set_details('Method not implemented!')
    raise NotImplementedError('Method not implemented!')


def add_DataCatalogServicer_to_server(servicer, server):
  rpc_method_handlers = {
      'CreateDataset': grpc.unary_unary_rpc_method_handler(
          servicer.CreateDataset,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateDatasetRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateDatasetResponse.SerializeToString,
      ),
      'GetDataset': grpc.unary_unary_rpc_method_handler(
          servicer.GetDataset,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetDatasetRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetDatasetResponse.SerializeToString,
      ),
      'CreateArtifact': grpc.unary_unary_rpc_method_handler(
          servicer.CreateArtifact,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateArtifactRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.CreateArtifactResponse.SerializeToString,
      ),
      'GetArtifact': grpc.unary_unary_rpc_method_handler(
          servicer.GetArtifact,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetArtifactRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetArtifactResponse.SerializeToString,
      ),
      'AddTag': grpc.unary_unary_rpc_method_handler(
          servicer.AddTag,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.AddTagRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.AddTagResponse.SerializeToString,
      ),
      'ListArtifacts': grpc.unary_unary_rpc_method_handler(
          servicer.ListArtifacts,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListArtifactsRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListArtifactsResponse.SerializeToString,
      ),
      'ListDatasets': grpc.unary_unary_rpc_method_handler(
          servicer.ListDatasets,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListDatasetsRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ListDatasetsResponse.SerializeToString,
      ),
      'GetOrReserveArtifact': grpc.unary_unary_rpc_method_handler(
          servicer.GetOrReserveArtifact,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetOrReserveArtifactRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.GetOrReserveArtifactResponse.SerializeToString,
      ),
      'ExtendReservation': grpc.unary_unary_rpc_method_handler(
          servicer.ExtendReservation,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ExtendReservationRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ExtendReservationResponse.SerializeToString,
      ),
      'ReleaseReservation': grpc.unary_unary_rpc_method_handler(
          servicer.ReleaseReservation,
          request_deserializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ReleaseReservationRequest.FromString,
          response_serializer=flyteidl_dot_datacatalog_dot_datacatalog__pb2.ReleaseReservationResponse.SerializeToString,
      ),
  }
  generic_handler = grpc.method_handlers_generic_handler(
      'datacatalog.DataCatalog', rpc_method_handlers)
  server.add_generic_rpc_handlers((generic_handler,))
