openapi: 3.1.0
x-stoplight:
  id: okoe8mh50pjec
info:
  title: chat
  version: '1.0'
servers:
  - url: 'http://chat:3010'
x-exegesis-controller: messagesController
paths:
  '/project/{projectId}/messages':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
    get:
      summary: Get Global messages
      tags: []
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Message'
      operationId: getGlobalMessages
      description: Get global messages for the project with Project ID provided
      parameters:
        - schema:
            type: string
          in: query
          name: before
        - schema:
            type: string
          in: query
          name: limit
    post:
      summary: Send Global message
      operationId: sendGlobalMessage
      responses:
        '201':
          description: OK
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Message'
            examples:
              example-1:
                value:
                  user_id: string
                  content: string
        description: 'UserID and Content of the message to be posted. '
      description: Send global message  for the project with Project ID provided
  '/project/{projectId}/messages/{messageId}':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: messageId
        in: path
        required: true
    get:
      summary: Get single global message
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
        '404':
          description: Message not found
      operationId: getGlobalMessage
      description: Get a single global message by message ID for the project with Project ID provided
    delete:
      summary: Delete global message
      operationId: deleteGlobalMessage
      responses:
        '204':
          description: No Content
      description: 'Delete global message'
  '/project/{projectId}/thread/{threadId}/messages':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
    post:
      summary: Send message
      operationId: sendMessage
      responses:
        '201':
          description: Created
      description: Add a message to the thread with thread ID provided from the Project with Project ID provided.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Message'
        description: |-
          JSON object with :
          - user_id: Id of the user
          - content: Content of the message
  '/project/{projectId}/threads':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
    get:
      summary: Get Threads
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Thread'
              examples: {}
        '404':
          description: Not Found
      operationId: getThreads
      description: Get the list of threads for the project with Project ID provided
  '/project/{projectId}/thread/{threadId}/messages/{messageId}/edit':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
      - schema:
          type: string
        name: messageId
        in: path
        required: true
    post:
      summary: Edit message
      operationId: editMessage
      responses:
        '204':
          description: No Content
        '404':
          description: Not Found
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
                user_id:
                  type: string
                  readOnly: true
              required:
                - content
            examples: {}
        description: |-
          JSON object with :
          - content: Content of the message to edit
          - user_id: Id of the user (optional)
      description: |
        Update message with Message ID provided from the Thread ID and Project ID provided
  '/project/{projectId}/messages/{messageId}/edit':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: messageId
        in: path
        required: true
    post:
      summary: Edit global message
      operationId: editGlobalMessage
      responses:
        '204':
          description: No Content
        '404':
          description: Not Found
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
                user_id:
                  type: string
                  readOnly: true
              required:
                - content
            examples: {}
        description: |-
          JSON object with :
          - content: Content of the message to edit
          - user_id: Id of the user (optional)
      description: |
        Update global message with Message ID provided from the Project ID provided
  '/project/{projectId}/thread/{threadId}/messages/{messageId}':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
      - schema:
          type: string
        name: messageId
        in: path
        required: true
    get:
      summary: Get thread message
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
        '404':
          description: Message not found
      operationId: getThreadMessage
      description: Get a specific message by message ID from the thread with Thread ID and Project ID provided
    delete:
      summary: Delete message
      operationId: deleteMessage
      responses:
        '204':
          description: No Content
      description: 'Delete message with Message ID provided, from the Thread with ThreadID and ProjectID provided'
  '/project/{projectId}/thread/{threadId}/user/{userId}/messages/{messageId}':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
      - schema:
          type: string
        name: userId
        in: path
        required: true
      - schema:
          type: string
        name: messageId
        in: path
        required: true
    delete:
      summary: Delete message written by a given user
      operationId: deleteUserMessage
      responses:
        '204':
          description: No Content
  '/project/{projectId}/thread/{threadId}/resolve':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
    post:
      summary: Resolve Thread
      operationId: resolveThread
      responses:
        '204':
          description: No Content
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                user_id:
                  type: string
              required:
                - user_id
        description: |-
          JSON object with :
          - user_id: Id of the user.
      description: Mark Thread with ThreadID and ProjectID provided owned by the user with UserID provided as resolved.
  '/project/{projectId}/thread/{threadId}/reopen':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
    post:
      summary: Reopen Thread
      operationId: reopenThread
      responses:
        '204':
          description: No Content
      description: |-
        Reopen Thread with ThreadID and ProjectID provided.
        i.e unmark it as resolved.
  '/project/{projectId}/thread/{threadId}':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
      - schema:
          type: string
        name: threadId
        in: path
        required: true
    get:
      summary: Get Thread
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Thread'
        '404':
          description: Thread not found
      operationId: getThread
      description: Get a thread with ThreadID and ProjectID provided
    delete:
      summary: Delete thread
      operationId: deleteThread
      responses:
        '204':
          description: No Content
      description: Delete thread with ThreadID and ProjectID provided
  '/project/{projectId}/resolved-thread-ids':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
    get:
      summary: Get resolved thread ids
      operationId: getResolvedThreadIds
      responses:
        '200':
          description: Resolved thread ids
  '/project/{projectId}':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
    delete:
      summary: Destroy project
      operationId: destroyProject
      responses:
        '204':
          description: No Content
      description: 'Delete all threads from Project with Project ID provided, and all messages in those threads.'
  /status:
    get:
      summary: Check status
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
                description: chat is alive
      operationId: getStatus
      description: Check that the Chat service is alive
    head:
      summary: Check status
      tags: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
                description: chat is alive
      operationId: getStatus
      description: Check that the Chat service is alive
  '/project/{projectId}/duplicate-comment-threads':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
    post:
      summary: Duplicate comment threads
      operationId: duplicateCommentThreads
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                threads:
                  type: array
                  items:
                    type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  newThreads:
                    type: object
                description: Mapping of old thread ids to their duplicated thread ids
      description: Duplicate a list of comment threads
  '/project/{projectId}/generate-thread-data':
    parameters:
      - schema:
          type: string
        name: projectId
        in: path
        required: true
    post:
      summary: Generate thread data to load into the frontend
      operationId: generateThreadData
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                threads:
                  type: array
                  items:
                    type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
      description: Load threads and generate a json blob containing all messages in all the threads
components:
  schemas:
    Message:
      title: Message
      x-stoplight:
        id: ue9n1vvezlutw
      type: object
      examples:
        - user_id: string
        - content: string
      properties:
        user_id:
          type: string
        content:
          type: string
      required:
        - user_id
        - content
    Thread:
      title: Thread
      x-stoplight:
        id: 0ppt3jw4h5bua
      type: array
      items:
        $ref: '#/components/schemas/Message'
