#@ load("openapi.lib.yml", "response", "reference", "type", "array")

paths:
  /cluster:
    get:
      tags:
        - Distributed
      summary: Get cluster status info
      description: Get information about the current state and composition of the cluster
      operationId: cluster_status
      responses: #@ response(reference("ClusterStatus"))

  /cluster/telemetry:
    get:
      tags:
        - Distributed
      summary: Collect cluster telemetry data
      description: Get telemetry data, from the point of view of the cluster. This includes peers info, collections info, shard transfers, and resharding status
      operationId: cluster_telemetry
      parameters:
        - name: details_level
          in: query
          description: The level of detail to include in the response
          required: false
          schema:
            type: integer
        #! todo: - name: anonymize
        - name: timeout
          in: query
          description: Timeout for this request
          required: false
          schema:
            type: integer
            minimum: 1
            default: 60
      responses: #@ response(reference("DistributedTelemetryData"))

  /cluster/recover:
    post:
      tags:
        - Distributed
      summary: Tries to recover current peer Raft state.
      operationId: recover_current_peer
      responses: #@ response(type("boolean"))

  /cluster/peer/{peer_id}:
    delete:
      tags:
        - Distributed
      summary: Remove peer from the cluster
      description: Tries to remove peer from the cluster. Will return an error if peer has shards on it.
      operationId: remove_peer
      parameters:
        - name: peer_id
          in: path
          description: Id of the peer
          required: true
          schema:
            type: integer
        - name: timeout
          in: query
          description: |
            Wait for operation commit timeout in seconds.
            If timeout is reached - request will return with service error.
          schema:
            type: integer
            minimum: 1
        - name: force
          in: query
          description: If true - removes peer even if it has shards/replicas on it.
          schema:
            type: boolean
            default: false
      responses: #@ response(type("boolean"))
