openapi: "3.0.1"

info:
  description: "This is the Traffic Parrot OpenAPI documentation."
  version: "5.61.x"
  title: "Traffic Parrot OpenAPI documentation"
  contact:
    email: "support@trafficparrot.com"

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

tags:
- name: "Traffic Parrot HTTP WireMock compatible APIs"
  description: "Traffic Parrot HTTP component is based on WireMock"
  externalDocs:
    description: "Find out more"
    url: "http://wiremock.org/docs/api"

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

- name: "Traffic Parrot gRPC APIs"
  description: "gRPC Remote Procedure Calls"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/5.61.x/grpc.html"

- name: "Traffic Parrot Native IBM MQ APIs"
  description: "IBM&reg; WebSphere MQ"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/5.61.x/ibmmq.html"

- name: "Traffic Parrot JMS APIs"
  description: "Java Message Service"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/5.61.x/jms.html"

- name: "Traffic Parrot File Message APIs"
  description: "File Messages"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/5.61.x/filemessage.html"

- name: "Traffic Parrot Scenario APIs"
  description: "Scenarios"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/5.61.x/user_guide.html#scenarios"

- name: "Traffic Parrot State APIs"
  description: "State management for in-memory state with namespace support for scenario isolation"
  externalDocs:
    description: "Find out more"
    url: "https://trafficparrot.com/documentation/5.61.x/release_notes.html#version-5-3-1"

servers:
  - url: "http://localhost:8080"

paths:
  /api/scenarios:
    get:
      operationId: getScenarios
      tags:
       - "Traffic Parrot Scenario APIs"
      summary: "Get all test scenarios"
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.scenarios.v1+json':
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Scenario"

  /api/scenarios/{name}:
    put:
      operationId: createOrUpdateScenario
      tags:
        - "Traffic Parrot Scenario APIs"
      summary: "Create or update test scenario"
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          'application/vnd.trafficparrot.scenarios.v1+json':
            schema:
              $ref: "#/components/schemas/ScenarioUpdate"
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.scenarios.v1+json':
              schema:
                $ref: "#/components/schemas/Scenario"

  /api/scenarios/http/composite:
    get:
      operationId: getCompositeScenarioStatus
      tags:
        - "Traffic Parrot Scenario APIs"
      summary: "Get status of composite scenario"
      responses:
        200:
          description: "OK"
          content:
            'application/json':
              schema:
                $ref: "#/components/schemas/CompositeMetadata"

  /api/scenarios/http/composite/add:
    post:
      operationId: addScenarioToComposite
      tags:
        - "Traffic Parrot Scenario APIs"
      summary: "Add a scenario to the composite"
      parameters:
        - in: query
          name: scenario
          required: true
          schema:
            type: string
          description: "Name of the scenario to add"
      responses:
        200:
          description: "OK"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  message:
                    type: string
                example:
                  message: "Scenario 'MyScenario' added to Composite"
        400:
          description: "Bad Request"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  error:
                    type: string
                example:
                  error: "Scenario name is required"
        500:
          description: "Internal Server Error"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  error:
                    type: string
                example:
                  error: "Failed to add scenario: ..."

  /api/scenarios/http/composite/remove:
    post:
      operationId: removeScenarioFromComposite
      tags:
        - "Traffic Parrot Scenario APIs"
      summary: "Remove a scenario from the composite"
      parameters:
        - in: query
          name: scenario
          required: true
          schema:
            type: string
          description: "Name of the scenario to remove"
      responses:
        200:
          description: "OK"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  message:
                    type: string
                example:
                  message: "Scenario 'MyScenario' removed from Composite"
        400:
          description: "Bad Request"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  error:
                    type: string
                example:
                  error: "Scenario name is required"
        500:
          description: "Internal Server Error"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  error:
                    type: string
                example:
                  error: "Failed to remove scenario: ..."

  /api/scenarios/http/composite/clear:
    post:
      operationId: clearCompositeScenarios
      tags:
        - "Traffic Parrot Scenario APIs"
      summary: "Clear all scenarios from the composite"
      responses:
        200:
          description: "OK"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  message:
                    type: string
                example:
                  message: "All scenarios cleared from Composite"
        500:
          description: "Internal Server Error"
          content:
            'application/json':
              schema:
                type: object
                properties:
                  error:
                    type: string
                example:
                  error: "Failed to clear scenarios: ..."

  /api/state:
    delete:
      operationId: deleteAllStateVariables
      tags:
        - "Traffic Parrot State APIs"
      summary: "Delete all state variables across all namespaces"
      responses:
        204:
          description: "OK"

  /api/state/global/{name}:
    get:
      operationId: getGlobalStateVariable
      tags:
        - "Traffic Parrot State APIs"
      summary: "Get current value of global state that can be used in virtual service responses"
      parameters:
        - in: path
          name: name
          schema:
            type: string
          required: true
          description: Name of the state
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.state.v1+json':
              schema:
                $ref: "#/components/schemas/State"

        404:
          description: "No global state with the given name found"

    put:
      operationId: createOrUpdateGlobalStateVariable
      tags:
        - "Traffic Parrot State APIs"
      summary: "Create or update global state that can be used in virtual service responses"
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          'application/vnd.trafficparrot.state.v1+json':
            schema:
              $ref: "#/components/schemas/StateUpdate"
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.state.v1+json':
              schema:
                $ref: "#/components/schemas/State"

  /api/state/{namespace}:
    get:
      operationId: listNamespacedState
      tags:
        - "Traffic Parrot State APIs"
      summary: "List all state variables in a namespace"
      parameters:
        - in: path
          name: namespace
          schema:
            type: string
          required: true
          description: Namespace to list state variables for (e.g. "global", "scenario-1")
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.state.v1+json':
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/State"

    delete:
      operationId: clearNamespace
      tags:
        - "Traffic Parrot State APIs"
      summary: "Delete all state variables in a namespace"
      parameters:
        - in: path
          name: namespace
          schema:
            type: string
          required: true
          description: Namespace to clear (e.g. "scenario-1")
      responses:
        204:
          description: "OK"

  /api/state/{namespace}/{name}:
    get:
      operationId: getNamespacedStateVariable
      tags:
        - "Traffic Parrot State APIs"
      summary: "Get current value of a namespaced state variable"
      parameters:
        - in: path
          name: namespace
          schema:
            type: string
          required: true
          description: Namespace of the state variable (e.g. "global", "scenario-1")
        - in: path
          name: name
          schema:
            type: string
          required: true
          description: Name of the state variable
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.state.v1+json':
              schema:
                $ref: "#/components/schemas/State"
        404:
          description: "No state variable with the given namespace and name found"

    put:
      operationId: createOrUpdateNamespacedStateVariable
      tags:
        - "Traffic Parrot State APIs"
      summary: "Create or update a namespaced state variable"
      parameters:
        - in: path
          name: namespace
          schema:
            type: string
          required: true
          description: Namespace of the state variable (e.g. "scenario-1")
        - in: path
          name: name
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          'application/vnd.trafficparrot.state.v1+json':
            schema:
              $ref: "#/components/schemas/StateUpdate"
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.state.v1+json':
              schema:
                $ref: "#/components/schemas/State"

  /api/grpc/requests:
    delete:
      operationId: deleteGrpcRequests
      tags:
        - "Traffic Parrot gRPC APIs"
      summary: "Delete all gRPC requests from the journal"
      responses:
        204:
          description: "OK"

  /api/grpc/requests/count:
    post:
      operationId: countGrpcRequests
      tags:
        - "Traffic Parrot gRPC APIs"
      summary: "Count the number of gRPC requests in the journal that match the given pattern"
      requestBody:
        required: true
        content:
          'application/vnd.trafficparrot.grpc.requests.count.v1+json':
            schema:
              $ref: "#/components/schemas/GrpcRequestPattern"
            examples:
              "Count by method, metadata and payload":
                value:
                  method: "com.example.Service/Method"
                  metadata:
                    example-key:
                      equalTo: "value"
                  payloadJson:
                    equalToJson: "{ \"example\": \"value\"}"

      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.grpc.requests.count.v1+json':
              schema:
                $ref: "#/components/schemas/RequestCount"

  /api/jms/requests:
    delete:
      operationId: deleteJmsRequests
      tags:
        - "Traffic Parrot JMS APIs"
      summary: "Delete all JMS requests from the journal"
      responses:
        204:
          description: "OK"

  /api/jms/requests/count:
    post:
      operationId: countJmsRequests
      tags:
        - "Traffic Parrot JMS APIs"
      summary: "Count the number of JMS requests in the journal that match the given pattern"
      requestBody:
        required: true
        content:
          'application/vnd.trafficparrot.jms.requests.count.v1+json':
            schema:
              $ref: "#/components/schemas/MessageRequestPattern"
            examples:
              "Count by method, metadata and payload":
                value:
                  {
                    "destination": {
                      "name": "request-queue",
                      "type": "QUEUE"
                    },
                    "messageText": {
                      "contains": "example"
                    }
                  }
      responses:
        200:
          description: "OK"
          content:
            'application/vnd.trafficparrot.grpc.requests.count.v1+json':
              schema:
                $ref: "#/components/schemas/RequestCount"

  /api/http/:
    get:
      operationId: httpAdminWithoutPrefix
      tags:
      - "Traffic Parrot HTTP WireMock compatible APIs"
      summary: "WireMock compatible APIs are hosted here with the __admin prefix removed"
      responses:
        200:
          description: "OK"

  /api/http/__admin:
    get:
      operationId: httpAdmin
      tags:
        - "Traffic Parrot HTTP WireMock compatible APIs"
      summary: "WireMock compatible APIs are hosted here"
      responses:
        200:
          description: "OK"

  /http/management/importMappings:
    post:
      operationId: importHttpMappings
      tags:
      - "Traffic Parrot HTTP APIs"
      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: "Unable to import mappings"
          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."

  /api/health:
    get:
      operationId: checkHealth
      tags:
        - "Traffic Parrot HTTP APIs"
      summary: "Check if Traffic Parrot is running"
      responses:
        200:
          description: "Traffic Parrot is healthy and ready"
          content:
            text/plain:
              schema:
                type: string
                example: "Health OK"

  /management/http/startRecording:
    post:
      operationId: startHttpRecording
      tags:
        - "Traffic Parrot HTTP APIs"
      summary: "Start HTTP recording/proxying"
      description: "Start recording HTTP traffic. Supports single backend or multi-backend recording with path-based routing using arrow syntax (e.g., '/api/.*->http://api.example.com')"
      parameters:
        - in: query
          name: proxy-url
          required: true
          schema:
            type: string
          description: "Target URL(s) to proxy to. For single backend: 'http://api.example.com'. For multi-backend: '/api/v1/.*->http://api1.example.com,/api/v2/.*->http://api2.example.com,.*->http://default.example.com'"
          examples:
            single:
              value: "http://api.example.com:8090"
              summary: "Single backend recording"
            multi:
              value: "/users/.*->http://users-api:8080,/orders/.*->http://orders-api:8081,.*->http://gateway:8080"
              summary: "Multi-backend recording with path routing"
        - in: query
          name: record-request-headers-for-matching
          required: false
          schema:
            type: string
          description: "Comma-separated list of request headers to record for matching"
          example: "X-Example,X-User-Id"
      responses:
        200:
          description: "Recording started successfully"
        400:
          description: "Invalid parameters"

  /management/http/currentRecordingStatus:
    get:
      operationId: getHttpRecordingStatus
      tags:
        - "Traffic Parrot HTTP APIs"
      summary: "Get current HTTP recording status"
      responses:
        200:
          description: "Current recording status"
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum: ["recording", "not recording"]
                  proxyUrl:
                    type: string
                    description: "The proxy URL configuration if recording"
                  baseUrl:
                    type: string
                    description: "The base URL being recorded"
                  recordingPort:
                    type: integer
                    description: "The port used for recording"
                example:
                  status: "recording"
                  proxyUrl: "/api/.*->http://backend:8080,.*->http://default:8090"
                  baseUrl: "http://localhost:8081"
                  recordingPort: 8081

  /management/http/stopRecording:
    post:
      operationId: stopHttpRecording
      tags:
        - "Traffic Parrot HTTP APIs"
      summary: "Stop HTTP recording"
      responses:
        200:
          description: "Recording stopped successfully"

  /ibmMq/record:
    get:
      operationId: getIbmMqRecording
      tags:
      - "Traffic Parrot Native IBM MQ APIs"
      summary: "IBM MQ recording status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TpApiResponse"
              examples:
                "Recording ON":
                  value:
                    status: "ON"
                "Recording OFF":
                  value:
                    status: "OFF"
    post:
      operationId: ibmMqRecording
      tags:
      - "Traffic Parrot Native IBM MQ APIs"
      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/5.61.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/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /ibmMq/replay:
    get:
      operationId: getIbmMqReplay
      tags:
      - "Traffic Parrot Native IBM MQ APIs"
      summary: "IBM MQ replay status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                "Replay OFF":
                  value:
                    status: "OFF"
    post:
      operationId: ibmMqReplay
      tags:
      - "Traffic Parrot Native IBM MQ APIs"
      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/5.61.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/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /jms/record:
    get:
      operationId: getJmsRecording
      tags:
      - "Traffic Parrot JMS APIs"
      summary: "JMS record status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TpApiResponse"
              examples:
                "Recording ON":
                  value:
                    status: "ON"
                "Recording OFF":
                  value:
                    status: "OFF"
    post:
      operationId: jmsRecording
      tags:
      - "Traffic Parrot JMS APIs"
      summary: "JMS start and stop recording"
      description: "The connection ids refer to connections that are defined in [jms-connections.json](https://trafficparrot.com/documentation/5.61.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/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /jms/replay:
    get:
      operationId: getJmsReplay
      tags:
      - "Traffic Parrot JMS APIs"
      summary: "JMS replay status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                "Replay OFF":
                  value:
                    status: "OFF"
    post:
      operationId: jmsReplay
      tags:
      - "Traffic Parrot JMS APIs"
      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/5.61.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/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /fileMessage/record:
    get:
      operationId: getFileMessageRecording
      tags:
      - "Traffic Parrot File Message APIs"
      summary: "File Message record status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TpApiResponse"
              examples:
                "Recording ON":
                  value:
                    status: "ON"
                "Recording OFF":
                  value:
                    status: "OFF"
    post:
      operationId: fileMessageRecording
      tags:
      - "Traffic Parrot File Message APIs"
      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/5.61.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/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"

  /fileMessage/replay:
    get:
      operationId: getFileMessageReplay
      tags:
      - "Traffic Parrot File Message APIs"
      summary: "File Message replay status"
      responses:
        200:
          description: "OK"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                "Replay OFF":
                  value:
                    status: "OFF"
    post:
      operationId: fileMessageReplay
      tags:
      - "Traffic Parrot File Message APIs"
      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/5.61.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/TpApiResponse"
              examples:
                "Replay ON":
                  value:
                    status: "ON"
                    flash:
                      success: "Started"
                "Replay OFF":
                  value:
                    status: "OFF"
                    flash:
                      success: "Stopped"


components:
  schemas:
    GrpcRequestPattern:
      type: "object"
      properties:
        method:
          type: "string"
          description: "The fully qualified gRPC method e.g. com.example.Service/Method"
        metadata:
          type: "object"
          description: "Metadata patterns to match against in the <key>: { \"predicate\": \"value\" } form"
        payloadJson:
          type: "object"
          description: "Request payload JSON representation to match against in the { \"predicate\": \"value\" } form"

    MessageRequestPattern:
      type: "object"
      properties:
        destination:
          $ref: "#/components/schemas/GrpcRequestPattern"
        messageText:
          type: "object"
          description: "Message text to match against in the { \"predicate\": \"value\" } form"

    Destination:
      type: "object"
      properties:
        name:
          type: "string"
          description: "The name of the queue or topic"
        type:
          type: "string"
          enum:
            - "QUEUE"
            - "TOPIC"
          description: "The destination is a queue or topic"

    RequestCount:
      type: "object"
      required:
        - "count"
        - "requestJournalDisabled"
      properties:
        count:
          type: "integer"
          minimum: 0
        requestJournalDisabled:
          type: "boolean"
          default: false

    State:
      type: "object"
      required:
        - "namespace"
        - "name"
        - "value"
      example:
        namespace: "global"
        name: "name"
        value: 12345
      properties:
        namespace:
          type: "string"
        name:
          type: "string"
        value:
          oneOf:
            - type: "string"
            - type: "integer"
            - type: "number"
            - type: "boolean"

    StateUpdate:
      type: "object"
      required:
        - "value"
      example:
        value: 12345
      properties:
        value:
          oneOf:
            - type: "string"
            - type: "integer"
            - type: "number"
            - type: "boolean"

    Scenario:
      type: "object"
      required:
        - "name"
        - "enabled"
      properties:
        name:
          type: "string"
        enabled:
          type: "boolean"

    ScenarioUpdate:
      required:
        - "enabled"
      type: "object"
      properties:
        enabled:
          type: "boolean"

    CompositeMetadata:
      type: "object"
      required:
        - "name"
        - "scenarioNames"
        - "httpStubMappingIds"
      properties:
        name:
          type: "string"
          example: "Composite"
        scenarioNames:
          type: "array"
          items:
            type: "string"
          example: ["ScenarioA", "ScenarioB"]
        httpStubMappingIds:
          type: "array"
          items:
            type: "string"
          example: ["123e4567-e89b-12d3-a456-426614174000", "987fcdeb-51a2-43d1-b678-532910987654"]

    TpApiResponse:
      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"
