openapi: "3.0.1"

info:
  description: "This is the Traffic Parrot HTTP Management API documentation."
  version: "4.2.0"
  title: "Traffic Parrot HTTP Management API"
  contact:
    email: "support@trafficparrot.com"

externalDocs:
  description: "Find out more"
  url: "https://trafficparrot.com/documentation/4.2.x"

tags:
- name: "localhost:8081/__admin"
  description: "Traffic Parrot HTTP component is based on WireMock"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/4.2.x/http.html"

- name: "localhost:8083/http/management"
  description: "Traffic Parrot HTTP management commands"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/4.2.x/http.html"

- name: "localhost:8080/ibmMq"
  description: "IBM&reg; WebSphere MQ"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/4.2.x/ibmmq.html"

- name: "localhost:8080/jms"
  description: "Java Message Service"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/4.2.x/jms.html"

- name: "localhost:8080/fileMessage"
  description: "File Messages"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/4.2.x/filemessage.html"


paths:
  /__admin/swagger-ui/:
    servers:
      - url: "http://localhost:8081"
    get:
      tags:
      - "localhost:8081/__admin"
      summary: "WireMock API documentation"
      responses:
        200:
          description: "OK"
          content:
            text/html:
              schema:
                type: "string"

  /http/management/importMappings:
    servers:
    - url: "http://localhost:8083"
    post:
      tags:
      - "localhost:8083/http/management"
      summary: "Import Swagger/RAML/OpenAPI files"
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                files:
                  type: "array"
                  items:
                    type: "string"
                    format: "binary"
      responses:
        200:
          description: "Successfully imported mapping ids"
          content:
            application/json:
              schema:
                type: "array"
                items:
                  type: "string"
                  format: "uuid"
              example:
                - "5e72e28a-8f66-4cb1-a920-7c9ee916ac10"
                - "9dd89493-64b5-4339-a514-a0375f64d205"
        400:
          description:
            content:
              content:
                application/json:
                  schema:
                    type: "object"
                    required:
                    - "result"
                    properties:
                      result:
                        type: "string"
                  example:
                    result: "Unable to import mappings from the given file(s). Check the logs for details."

  /ibmMq/record:
    servers:
      - url: "http://localhost:8080"
    get:
      tags:
      - "localhost:8080/ibmMq"
      summary: "IBM MQ recording status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Recording ON":
                  value:
                    status: "ON"
                "Recording OFF":
                  value:
                    status: "OFF"
    post:
      tags:
      - "localhost:8080/ibmMq"
      summary: "IBM MQ start and stop recording"
      description: "The connection ids refer to connections that are defined in [ibm-mq-connections.json](https://trafficparrot.com/documentation/4.2.x/ibmmq.html#define-connections)"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RecordSettings"
            examples:
              "Record queue ON":
                description: "You can choose to start record of queues or topics but not both at the same time."
                value:
                  action: "START"
                  messageMatcher: "time"
                  queue:
                    recordRequestsFromConnectionId:	"docker-connection-id"
                    recordRequestsFromQueue: "VIRTUAL.REQ.QL"
                    forwardRequestsToConnectionId: "real-connection-id"
                    forwardRequestsToQueue: "REAL.REQ.QL"
                    recordResponsesFromConnectionId: "real-connection-id"
                    recordResponsesFromQueue:	"REAL.RSP.QL"
                    forwardResponsesToConnectionId:	"docker-connection-id"
                    forwardResponsesToQueue: "VIRTUAL.RSP.QL"

              "Record topic ON":
                description: "You can choose to start record of queues or topics but not both at the same time"
                value:
                  action: "START"
                  messageMatcher: "time"
                  topic:
                    recordRequestsFromConnectionId:	"real-connection-id"
                    recordRequestsFromTopic: "REAL.TL"
                    recordResponsesFromConnectionId: "real-connection-id"
                    recordResponsesFromTopic: "REAL.TL"

              "Record OFF":
                description: "This will stop any recording that was previously in progress"
                value:
                  action: "STOP"

      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /ibmMq/replay:
    servers:
      - url: "http://localhost:8080"
    get:
      tags:
      - "localhost:8080/ibmMq"
      summary: "IBM MQ replay status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                "Replay OFF":
                  value:
                    status: "OFF"
    post:
      tags:
      - "localhost:8080/ibmMq"
      summary: "IBM MQ start and stop replay using current mappings"
      description: "The connection ids refer to connections that are defined in [ibm-mq-connections.json](https://trafficparrot.com/documentation/4.2.x/ibmmq.html#define-connections)"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ReplaySettings"
            examples:
              "Replay queue ON":
                description: "You can start replay of just queues"
                value:
                  action: "START"
                  queue:
                    consumeRequestsFromConnectionId: "docker-connection-id"
                    replayResponsesToConnectionId: "docker-connection-id"

              "Replay topic ON":
                description: "You can start replay of just topics"
                value:
                  action: "START"
                  topic:
                    replayToConnectionId: "docker-connection-id"

              "Replay both ON":
                description: "You can start replay of both queues and topics"
                value:
                  action: "START"
                  queue:
                    consumeRequestsFromConnectionId: "docker-connection-id"
                    replayResponsesToConnectionId: "docker-connection-id"
                  topic:
                    replayToConnectionId: "docker-connection-id"

              "Replay OFF":
                description: "This will stop any replay that was previously in progress"
                value:
                  action: "STOP"

      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /jms/record:
    servers:
      - url: "http://localhost:8080"
    get:
      tags:
      - "localhost:8080/jms"
      summary: "JMS record status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Recording ON":
                  value:
                    status: "ON"
                "Recording OFF":
                  value:
                    status: "OFF"
    post:
      tags:
      - "localhost:8080/jms"
      summary: "JMS start and stop recording"
      description: "The connection ids refer to connections that are defined in [jms-connections.json](https://trafficparrot.com/documentation/4.2.x/jms.html#define-jms-connections)"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RecordSettings"
            examples:
              "Record queue ON":
                description: "You can choose to start record of queues or topics but not both at the same time"
                value:
                  action: "START"
                  broker:
                    type: "INTERNAL"
                    internalProvider: "ACTIVE_MQ"
                    internalPort: 1234
                  messageMatcher: "time"
                  queue:
                    recordRequestsFromConnectionId:	"USE-TRAFFIC-PARROT-INTERNAL-BROKER"
                    recordRequestsFromQueue: "VIRTUAL.REQ.QL"
                    forwardRequestsToConnectionId: "real-connection-id"
                    forwardRequestsToQueue: "REAL.REQ.QL"
                    recordResponsesFromConnectionId: "real-connection-id"
                    recordResponsesFromQueue:	"REAL.RSP.QL"
                    forwardResponsesToConnectionId:	"USE-TRAFFIC-PARROT-INTERNAL-BROKER"
                    forwardResponsesToQueue: "VIRTUAL.RSP.QL"

              "Record topic ON":
                description: "You can choose to start record of queues or topics but not both at the same time"
                value:
                  action: "START"
                  broker:
                    type: "EXTERNAL"
                  messageMatcher: "time"
                  topic:
                    recordRequestsFromConnectionId:	"real-connection-id"
                    recordRequestsFromTopic: "REAL.TL"
                    recordResponsesFromConnectionId: "real-connection-id"
                    recordResponsesFromTopic: "REAL.TL"

              "Record OFF":
                description: "This will stop any recording that was previously in progress"
                value:
                  action: "STOP"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /jms/replay:
    servers:
      - url: "http://localhost:8080"
    get:
      tags:
      - "localhost:8080/jms"
      summary: "JMS replay status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                "Replay OFF":
                  value:
                    status: "OFF"
    post:
      tags:
      - "localhost:8080/jms"
      summary: "JMS start and stop replay using current mappings"
      description: "The connection ids refer to connections that are defined in [jms-connections.json](https://trafficparrot.com/documentation/4.2.x/jms.html#define-jms-connections)"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ReplaySettings"
            examples:
              "Replay queue ON":
                description: "You can start replay of just queues"
                value:
                  action: "START"
                  broker:
                    type: "INTERNAL"
                    internalProvider: "ACTIVE_MQ"
                    internalPort: 1234
                  queue:
                    consumeRequestsFromConnectionId: "USE-TRAFFIC-PARROT-INTERNAL-BROKER"
                    replayResponsesToConnectionId: "USE-TRAFFIC-PARROT-INTERNAL-BROKER"

              "Replay topic ON":
                description: "You can start replay of just topics"
                value:
                  action: "START"
                  broker:
                    type: "INTERNAL"
                    internalProvider: "ACTIVE_MQ"
                    internalPort: 1234
                  topic:
                    replayToConnectionId: " USE-TRAFFIC-PARROT-INTERNAL-BROKER"

              "Replay both ON":
                description: "You can choose to start replay of queues or topics or both"
                value:
                  action: "START"
                  broker:
                    type: "INTERNAL"
                    internalProvider: "ACTIVE_MQ"
                    internalPort: 1234
                  queue:
                    consumeRequestsFromConnectionId: "USE-TRAFFIC-PARROT-INTERNAL-BROKER"
                    replayResponsesToConnectionId: "USE-TRAFFIC-PARROT-INTERNAL-BROKER"
                  topic:
                    replayToConnectionId: "USE-TRAFFIC-PARROT-INTERNAL-BROKER"

              "Replay OFF":
                description: "This will stop any replay that was previously in progress"
                value:
                  action: "STOP"

      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /fileMessage/record:
    servers:
      - url: "http://localhost:8080"
    get:
      tags:
      - "localhost:8080/fileMessage"
      summary: "File Message record status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Recording ON":
                  value:
                    status: "ON"
                "Recording OFF":
                  value:
                    status: "OFF"
    post:
      tags:
      - "localhost:8080/fileMessage"
      summary: "File Message start and stop recording"
      description: "The root directory ids refer to directories that are defined in [root-directories.json](https://trafficparrot.com/documentation/4.2.x/filemessage.html#define-root-directories). The sub directories are relative to the defined root directories."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FileMessageRecordSettings"
            examples:
              "Record ON":
                description: "Turn on recording the configured directories"
                value:
                  action: "START"
                  directories:
                    recordRequestsFromRootDirectoryId: "virtual-root"
                    recordRequestsFromSubDirectory: "request-sub-directory"
                    forwardRequestsToRootDirectoryId: "real-root"
                    forwardRequestsToSubDirectory: "request-sub-directory"
                    recordResponsesFromRootDirectoryId: "real-root"
                    recordResponsesFromSubDirectory: "response-sub-directory"
                    forwardResponsesToRootDirectoryId: "virtual-root"
                    forwardResponsesToSubDirectory: "response-sub-directory"

              "Record OFF":
                description: "This will stop any recording that was previously in progress"
                value:
                  action: "STOP"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /fileMessage/replay:
    servers:
      - url: "http://localhost:8080"
    get:
      tags:
      - "localhost:8080/fileMessage"
      summary: "File Message replay status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                "Replay OFF":
                  value:
                    status: "OFF"
    post:
      tags:
      - "localhost:8080/fileMessage"
      summary: "File Message start and stop replay using current mappings"
      description: "The root directory ids refer to directories that are defined in [root-directories.json](https://trafficparrot.com/documentation/4.2.x/filemessage.html#define-root-directories)"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FileMessageReplaySettings"
            examples:
              "Replay ON":
                description: "You can start replay of existing mappings using this"
                value:
                  action: "START"
                  directories:
                    consumeRequestsFromRootDirectoryId: "virtual-root"
                    replayResponsesToRootDirectoryId: "virtual-root"

              "Replay OFF":
                description: "This will stop any replay that was previously in progress"
                value:
                  action: "STOP"

      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"


components:
  schemas:
    ApiResponse:
      type: "object"
      properties:
        status:
          type: "string"
          enum:
          - "ON"
          - "OFF"
          - "UNKNOWN"
        flash:
          type: "object"
          properties:
            error:
              type: "string"
            success:
              type: "string"

    RecordSettings:
      type: "object"
      required:
      - "action"
      properties:
        action:
          $ref: "#/components/schemas/ActionSettings"
        broker:
          $ref: "#/components/schemas/BrokerSettings"
        messageMatcher:
          type: "string"
          enum:
          - "time"
          - "correlationId"
        queue:
          $ref: "#/components/schemas/QueueRecordSettings"

    QueueRecordSettings:
      type: "object"
      required:
      - "recordRequestsFromConnectionId"
      - "recordRequestsFromQueue"
      - "forwardRequestsToConnectionId"
      - "forwardRequestsToQueue"
      - "recordResponsesFromConnectionId"
      - "recordResponsesFromQueue"
      - "forwardResponsesToConnectionId"
      - "forwardResponsesToQueue"
      properties:
        recordRequestsFromConnectionId:
          type: "string"
        recordRequestsFromQueue:
          type: "string"
        forwardRequestsToConnectionId:
          type: "string"
        forwardRequestsToQueue:
          type: "string"
        recordResponsesFromConnectionId:
          type: "string"
        recordResponsesFromQueue:
          type: "string"
        forwardResponsesToConnectionId:
          type: "string"
        forwardResponsesToQueue:
          type: "string"

    ReplaySettings:
      type: "object"
      required:
      - "action"
      properties:
        action:
          $ref: "#/components/schemas/ActionSettings"
        broker:
          $ref: "#/components/schemas/BrokerSettings"
        queue:
          $ref: "#/components/schemas/QueueReplaySettings"
        topic:
          $ref: "#/components/schemas/TopicReplaySettings"

    QueueReplaySettings:
      type: "object"
      required:
      - "consumeRequestsFromConnectionId"
      - "replayResponsesToConnectionId"
      properties:
        consumeRequestsFromConnectionId:
          type: "string"
        replayResponsesToConnectionId:
          type: "string"

    TopicReplaySettings:
      type: "object"
      required:
      - "replayToConnectionId"
      properties:
        replayToConnectionId:
          type: "string"

    FileMessageRecordSettings:
      type: "object"
      required:
      - "action"
      properties:
        action:
          $ref: "#/components/schemas/ActionSettings"
        directories:
          $ref: "#/components/schemas/RecordDirectorySettings"

    RecordDirectorySettings:
      type: "object"
      required:
      - "recordRequestsFromRootDirectoryId"
      - "recordRequestsFromSubDirectory"
      - "forwardRequestsToRootDirectoryId"
      - "forwardRequestsToSubDirectory"
      - "recordResponsesFromRootDirectoryId"
      - "recordResponsesFromSubDirectory"
      - "forwardResponsesToRootDirectoryId"
      - "forwardResponsesToSubDirectory"
      properties:
        recordRequestsFromRootDirectoryId:
          type: "string"
        recordRequestsFromSubDirectory:
          type: "string"
        forwardRequestsToRootDirectoryId:
          type: "string"
        forwardRequestsToSubDirectory:
          type: "string"
        recordResponsesFromRootDirectoryId:
          type: "string"
        recordResponsesFromSubDirectory:
          type: "string"
        forwardResponsesToRootDirectoryId:
          type: "string"
        forwardResponsesToSubDirectory:
          type: "string"

    FileMessageReplaySettings:
      type: "object"
      required:
      - "action"
      properties:
        action:
          $ref: "#/components/schemas/ActionSettings"
        directories:
          $ref: "#/components/schemas/ReplayDirectorySettings"

    ReplayDirectorySettings:
      type: "object"
      required:
      - "consumeRequestsFromRootDirectoryId"
      - "replayResponsesToRootDirectoryId"
      properties:
        consumeRequestsFromRootDirectoryId:
          type: "string"
        replayResponsesToRootDirectoryId:
          type: "string"

    ActionSettings:
      type: "string"
      enum:
      - "START"
      - "STOP"

    BrokerSettings:
      type: "object"
      required:
      - "type"
      properties:
        type:
          type: "string"
          enum:
          - "INTERNAL"
          - "EXTERNAL"
        internalProvider:
          type: "string"
          enum:
          - "ACTIVE_MQ"
        internalPort:
          type: "integer"
          format: "int32"
