openapi: "3.0.3"
info:
  title: Management Center - WAN Replication API
  version: "1.0"
paths:
  /rest/clusters/{cluster}/wan/replications:
    parameters:
      - $ref: "#/components/parameters/Cluster"
    get:
      description: get all WAN replication configs for the given cluster
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/WanReplicationDTO"
    post:
     description: add new WAN replication
     requestBody:
       required: true
       content:
         application/json:
           schema:
             $ref: "#/components/schemas/AddWanReplicationDTO"
     responses:
       '200':
         description: success
         content:
           application/json:
             schema:
               $ref: "#/components/schemas/AddWanConfigResultDTO"
  /rest/clusters/{cluster}/wan/replications/{replication}:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/Replication"
    get:
      description: get WAN replication config for the given cluster and replication name
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WanReplicationDTO"
  /rest/clusters/{cluster}/wan/replications/{replication}/publishers/{publisher}:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/Replication"
      - $ref: "#/components/parameters/Publisher"
    get:
      description: get WAN publisher configuration
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WanPublisherStats"
  /rest/clusters/{cluster}/wan/replications/{replication}/maps:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/Replication"
    get:
      description: get IMaps with the given WAN replication
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/WanReplicatedMap"
  /rest/clusters/{cluster}/wan/consistencyChecks:
    parameters:
      - $ref: "#/components/parameters/Cluster"
    post:
      description: check consistency of the given map
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WanConsistencyCheckDTO"
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WanConsistencyCheckResultDTO"
  /rest/clusters/{cluster}/wan/replications/{replication}/publishers/{publisher}/queues:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/Replication"
      - $ref: "#/components/parameters/Publisher"
    delete:
      description: clear replication queues on all members
      responses:
        '200':
          description: success
  /rest/clusters/{cluster}/wan/replications/{replication}/publishers/{publisher}/members/{member}/queues:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/Replication"
      - $ref: "#/components/parameters/Publisher"
      - $ref: "#/components/parameters/Member"
    delete:
      description: clear replication queues on the given member
      responses:
        '200':
          description: success
  /rest/clusters/{cluster}/wan/replications/{replication}/publishers/{publisher}/state:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/Replication"
      - $ref: "#/components/parameters/Publisher"
    post:
      description: change state of the given publisher
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WanChangeStateDto"
      responses:
        '200':
          description: success
  /rest/clusters/{cluster}/wan/replications/{replication}/publishers/{publisher}/members/{member}/state:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/Replication"
      - $ref: "#/components/parameters/Publisher"
      - $ref: "#/components/parameters/Member"
    post:
      description: change state of the given publisher
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WanChangeStateDto"
      responses:
        '200':
          description: success
  /rest/clusters/{cluster}/wan/syncs:
    parameters:
      - $ref: "#/components/parameters/Cluster"
    post:
      description: sync the given map
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WanSyncDTO"
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WanSyncResultDTO"
    get:
      description: get WAN Sync events for cluster
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/EventsGroup"
  /rest/clusters/{cluster}/wan/syncs/{syncId}:
    parameters:
      - $ref: "#/components/parameters/Cluster"
      - $ref: "#/components/parameters/SyncId"
    get:
      description: get WAN Sync events for cluster
      responses:
        '200':
          description: success
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EventsGroup"
components:
  parameters:
    Cluster:
      name: cluster
      in: path
      description: cluster name
      schema:
        type: string
      required: true
    Replication:
      name: replication
      in: path
      description: WAN replication name
      schema:
        type: string
      required: true
    Publisher:
      name: publisher
      in: path
      description: WAN publisher name
      schema:
        type: string
      required: true
    Member:
      name: member
      in: path
      description: member
      schema:
        type: string
      required: true
    Map:
      name: map
      in: path
      description: map
      schema:
        type: string
      required: true
    SyncId:
      name: syncId
      in: path
      description: sync id
      schema:
        type: string
      required: true
  schemas:
    WanReplicationDTO:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
        state:
          $ref: "#/components/schemas/WanReplicationState"
        members:
          type: integer
        totalQueuedEvents:
          type: integer
        maxQueueFillPercent:
          type: integer
          minimum: 0
          maximum: 100
        destinations:
          type: array
          items:
            $ref: "#/components/schemas/WanPublisherStats"
      required:
        - name
        - state
        - members
        - totalQueuedEvents
        - destinations
    WanReplicationState:
      type: string
      enum:
        - REPLICATING
        - PAUSED
        - STOPPED
        - MIXED
    WanPublisherStats:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
        state:
          $ref: "#/components/schemas/WanReplicationState"
        supportsSyncCheck:
          type: boolean
        members:
          type: array
          nullable: true
          items:
            $ref: "#/components/schemas/WanPublisherMemberStats"
    WanPublisherMemberStats:
      type: object
      additionalProperties: false
      properties:
        member:
          type: string
        state:
          $ref: "#/components/schemas/WanPublisherState"
        connected:
          type: boolean
        eventsPerSecond:
          type: number
          nullable: true
        avgEventLatency:
          type: number
          nullable: true
        outboundQueueSize:
          type: integer
        outboundQueueFillPercent:
          type: integer
          minimum: 0
          maximum: 100
    WanPublisherState:
      type: string
      enum:
        - REPLICATING
        - PAUSED
        - STOPPED
    AddWanReplicationDTO:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
        targetClusterName:
          type: string
          minLength: 1
        publisherId:
          type: string
          minLength: 1
        endpoints:
          type: string
          minLength: 1
        queueCapacity:
          type: integer
          default: 10000
        batchSize:
          type: integer
          default: 500
        batchMaxDelay:
          type: integer
          default: 1000
        responseTimeout:
          type: integer
          default: 60000
        ackType:
          $ref: "#/components/schemas/WanAcknowledgeType"
        queueFullBehaviour:
          $ref: "#/components/schemas/WanQueueFullBehavior"
      required:
        - name
        - targetClusterName
        - publisherId
        - endpoints
    WanReplicatedMap:
      type: object
      additionalProperties: false
      properties:
        name:
          type: string
          minLength: 1
    WanAcknowledgeType:
      type: string
      enum:
        - ACK_ON_RECEIPT
        - ACK_ON_OPERATION_COMPLETE
      default: ACK_ON_OPERATION_COMPLETE
    WanQueueFullBehavior:
      type: string
      enum:
        - DISCARD_AFTER_MUTATION
        - THROW_EXCEPTION
        - THROW_EXCEPTION_ONLY_IF_REPLICATION_ACTIVE
      default: DISCARD_AFTER_MUTATION
    AddWanConfigResultDTO:
      type: object
      additionalProperties: false
      properties:
        addedPublisherIds:
          type: array
          items:
            type: string
        ignoredPublisherIds:
          type: array
          items:
            type: string
    EventsGroup:
      type: object
      additionalProperties: false
      properties:
        timestamp:
          type: integer
          format: int64
        uuid:
          type: string
        endpoint:
          type: string
        target:
          type: string
        map:
          type: string
        type:
          $ref: "#/components/schemas/WanEventsGroupType"
        status:
          $ref: "#/components/schemas/WanSyncActionStatus"
        summary:
          type: string
      required:
        - timestamp
        - uuid
        - endpoint
        - type
        - status
        - summary
    WanEventsGroupType:
      type: string
      enum:
        - SYNC
        - CHECK
        - CONFIG
    WanSyncActionStatus:
      type: object
      additionalProperties: false
      properties:
        status:
          type: string
          enum: [ DONE, ERROR, IN_PROGRESS ]
        progress:
          type: integer
          minimum: 0
          maximum: 100
        partitionsToSync:
          type: integer
        partitionsSynced:
          type: integer
    WanConsistencyCheckDTO:
      type: object
      additionalProperties: false
      properties:
        replication:
          type: string
        publisher:
          type: string
        map:
          type: string
    WanConsistencyCheckResultDTO:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
    WanChangeStateDto:
      type: object
      additionalProperties: false
      properties:
        state:
          $ref: "#/components/schemas/WanPublisherState"
    WanSyncDTO:
      type: object
      additionalProperties: false
      properties:
        replication:
          type: string
        publisher:
          type: string
        map:
          type: string
    WanSyncResultDTO:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
