openapi: 3.1.0
info:
  title: TMT API
  description: API working with Automation
  version: 1.0.0
paths:
  /api/v2/rpc (EXPORT_QF_DATA_STRUCTURE):
    post:
      summary: Export data structure
      description: >-
        Export data structure of a project version, include Version, Test Suite,
        Test folder and Test case in a hierarchy. The process submit a task
        request to processing data asynchronously. The operation simply returns
        the document reference of the task request. Which you can refer to get
        the task status by calling [Get task
        request](./task#/paths/~1api~1v2~1rpc%20(GET_DOCUMENT)/post)
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportDataStructureRequest'
              examples:
                $ref: example/EXPORT_QF_DATA_STRUCTURE-request.json
      responses:
        '200':
          description: Task request's document reference
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskRequestDocumentResult'
                examples:
                  $ref: example/EXPORT_QF_DATA_STRUCTURE-response.json
  /api/v2/rpc (EXPORT_QF_DATA_DETAIL):
    post:
      summary: Export data detail
      description: >-
        Export data detail of a project version, include Version, Test Suite,
        Test folder and Test case. The process submit a task request to
        processing data asynchronously. The operation simply returns the
        document reference of the task request. Which you can refer to get the
        task status by calling [Get task
        request](/./task#/paths/~1api~1v2~1rpc%20(GET_DOCUMENT)/post)
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportDataDetailRequest'
              examples:
                $ref: example/EXPORT_QF_DATA_DETAIL-request.json
      responses:
        '200':
          description: Task request's document reference
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskRequestDocumentResult'
                examples:
                  $ref: example/EXPORT_QF_DATA_DETAIL-response.json
  /api/v2/rpc (CREATE_QF_RUN):
    post:
      summary: Create a run for automation.
      description: Create a run for automation
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateQFRunRequest'
              examples:
                $ref: example/CREATE_QF_RUN-request.json
      responses:
        '200':
          description: Task run's document reference
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateQFRunResponse'
                examples:
                  $ref: example/CREATE_QF_RUN-response.json
  /api/automation/data/{taskRequestId}:
    get:
      summary: Download the data structure detail
      description: >-
        Use the id from TaskRequest docRef to download the file exported from
        other APIs. Data is only available when the task request's status is
        DONE. That means you can call [Get task
        request](./task#/paths/~1api~1v2~1rpc%20(GET_DOCUMENT)/post)
        periodically to get the status before downloading
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
        - name: taskRequestId
          in: path
          description: task request's document reference
          required: true
          schema:
            type: string
            example: TaskRequest-dm/c2c83935-a22e-4257-ad0b-3db534e2e212
      responses:
        '200':
          description: Detail information according to the task request
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/TmtStructureResponse'
                  - $ref: '#/components/schemas/TmtDetailResponse'
              examples:
                TmtStructureResponse:
                  value:
                    Project:
                      technicalId: Project-dm/32003
                      id: P_1
                      title: Project
                    children:
                      - Version:
                          technicalId: Version-dm/32006
                          id: 7ad48175-b43f-44f4-a496-42bbb152ff31
                          title: Migration
                        children:
                          - TestSuite:
                              technicalId: TestSuite-dm/32008
                              id: S_1
                              title: Test Suite 1
                            children:
                              - TestFolder:
                                  technicalId: TestFolder-dm/32009
                                  id: F_1
                                  title: TestFolder 1
                                children:
                                  - TestCase:
                                      technicalId: TestCase-dm/32010
                                      id: C_1
                                      title: TestCase 1
                              - TestCase:
                                  technicalId: TestCase-dm/32011
                                  id: C_2
                                  title: TestCase 2
                TmtDetailResponse:
                  value:
                    - id: P_354
                      technicalId: Project-dm/32003
                      title: Project
                      metadata:
                        createdOn: 1716795405252
                        createdBy: hehe
                    - versionNumber: 1.0.0
                      title: Migration
                      state: open
                      metadata:
                        createdOn: 1716795406385
                        createdBy: hehe
                        editedOn: 1716795408877
                        editedBy: hehe
                        derivedFrom: ''
                    - id: S_1
                      technicalId: TestSuite-dm/32008
                      title: Test Suite 1
                      tags: ''
                      metadata:
                        createdOn: 1716795406960
                        createdBy: hehe
                        editedOn: 1717042386127
                        editedBy: hehe
                    - id: F_1
                      technicalId: TestFolder-dm/32009
                      title: TestFolder 1
                    - id: C_2
                      technicalId: TestCase-dm/32011
                      title: TestCase 2
                      status: NEW
                      assignee: ''
                      type: ''
                      automation: ''
                      prioritization: ''
                      versionDelta: false
                      description: ''
                      tags: ''
                      attachments: []
                      precondition: ''
                      testSteps:
                        - Id: f9eb9871-6162-4532-9448-0a43d884e2d5
                          'No': 1
                      metadata:
                        createdOn: 1716795407782
                        createdBy: hehe
                        editedOn: 1716795407782
                        editedBy: hehe
                    - id: C_1
                      technicalId: TestCase-dm/32010
                      title: TestCase 1
                      status: NEW
                      assignee: ''
                      type: FUNCTIONAL
                      automation: TO_BE_EVALUATED
                      prioritization: OPTIONAL
                      versionDelta: true
                      description: asasd
                      tags: '123123'
                      attachments:
                        - FileName: Screen Shot 2024-01-15 at 15.55.19.png
                          CreatedAt: '2024-05-27T10:07:16'
                          UploadOn: '2024-05-27'
                          OriginalFileName: Screen Shot 2024-01-15 at 15.55.19.png
                          UploadBy: hehe
                          Referenced: false
                          CopyNumber: 0
                          ThumbnailId: 64428623-db9c-4188-accc-bd423e0254b0
                          File:
                            content: null
                            attachment_id: 9e63c12f-d5df-4f76-a57c-9318da34e705
                            internal_filename: >-
                              1716804433523-e2d70d3d-d842-4324-b28d-10c917f66bde.png
                            original_filename: Screen Shot 2024-01-15 at 15.55.19.png
                            size: 8826
                            mime_type: image/png
                      precondition: asd
                      testSteps:
                        - Id: f9eb9871-6162-4532-9448-0a43d884e2d5
                          'No': 1
                          Action: '123'
                          ExpectedResult: '123'
                      metadata:
                        createdOn: 1716795407508
                        createdBy: hehe
                        editedOn: 1716804539772
                        editedBy: hehe
security:
  - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    CreateQFRunResponse:
      allOf:
        - $ref: '#/components/schemas/RpcResult'
        - type: object
          properties:
            result:
              type: object
              properties:
                docRef:
                  type: string
                  description: test run document reference
      examples:
        - jsonrpc: '2.0'
          id: CREATE_QF_RUN
          result:
            docRef: TestRun-dm/661654
    CreateQFRunRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
              description: CREATE_QF_RUN
            params:
              required:
                - projectId
                - subprojectId
                - version
              properties:
                projectId:
                  type: string
                  description: project id
                subprojectId:
                  type: string
                  description: sub project id
                version:
                  type: string
                  description: project version number
                title:
                  type: string
                  description: title for the test run.
                  default: QF-TEST - Test Automation
                language:
                  type: string
                  description: >-
                    If title is not defined, language will be determined to
                    generate the title in the desired language
                  default: En
      examples:
        - jsonrpc: '2.0'
          id: CREATE_QF_RUN_123123
          method: CREATE_QF_RUN
          params:
            projectId: P_28
            subprojectId: SP_1
            version: 3.0.0
            title: Auto Run for QF
    ExportDataStructureRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
              description: EXPORT_QF_DATA_STRUCTURE
            params:
              required:
                - projectId
                - subprojectId
                - version
              properties:
                projectId:
                  type: string
                  description: project id
                subprojectId:
                  type: string
                  description: sub project id
                version:
                  type: string
                  description: project version number
      examples:
        - id: EXPORT_QF_DATA_STRUCTURE
          jsonrpc: '2.0'
          method: EXPORT_QF_DATA_STRUCTURE
          params:
            projectId: P_1
            subprojectId: _
            version: 1.0.0
    ExportDataDetailRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
              description: EXPORT_QF_DATA_DETAIL
            params:
              required:
                - projectId
                - subprojectId
                - version
              properties:
                projectId:
                  type: string
                  description: project id
                subprojectId:
                  type: string
                  description: sub project id
                version:
                  type: string
                  description: project version number
      examples:
        - jsonrpc: '2.0'
          id: EXPORT_QF_DATA_DETAIL
          method: EXPORT_QF_DATA_DETAIL
          params:
            projectId: P_1
            subprojectId: _
            version: 1.0.0
    TmtStructureResponse:
      type: object
      properties:
        Project:
          $ref: '#/components/schemas/NodeDetail'
        children:
          type: array
          items:
            $ref: '#/components/schemas/VersionNode'
    VersionNode:
      type: object
      properties:
        Version:
          $ref: '#/components/schemas/NodeDetail'
        children:
          type: array
          items:
            $ref: '#/components/schemas/TestSuiteNode'
    TestSuiteNode:
      type: object
      properties:
        TestSuite:
          $ref: '#/components/schemas/NodeDetail'
        children:
          type: array
          items:
            $ref: '#/components/schemas/TestcaseOrFolderNode'
    TestcaseOrFolderNode:
      type: object
      oneOf:
        - $ref: '#/components/schemas/TestCaseNode'
        - $ref: '#/components/schemas/TestFolderNode'
    TestCaseNode:
      type: object
      properties:
        TestCase:
          $ref: '#/components/schemas/NodeDetail'
    TestFolderNode:
      type: object
      properties:
        TestFolder:
          $ref: '#/components/schemas/NodeDetail'
        children:
          type: array
          items:
            $ref: '#/components/schemas/TestcaseOrFolderNode'
    NodeDetail:
      type: object
      properties:
        technicalId:
          type: string
        id:
          type: string
        title:
          type: string
    BaseEntity:
      type: object
      properties:
        id:
          type: string
          description: business id of the object
        technicalId:
          type: string
          description: >-
            document reference of the object. You can use this to determine the
            object type
        title:
          type: string
          description: title of the object
        metadata:
          $ref: '#/components/schemas/Metadata'
    TmtDetailResponse:
      type: array
      items:
        $ref: '#/components/schemas/TmtDetailItem'
    TmtDetailItem:
      oneOf:
        - $ref: '#/components/schemas/Project'
        - $ref: '#/components/schemas/Version'
        - $ref: '#/components/schemas/TestSuite'
        - $ref: '#/components/schemas/TestFolder'
        - $ref: '#/components/schemas/TestCase'
    Project:
      $ref: '#/components/schemas/BaseEntity'
    Version:
      type: object
      properties:
        versionNumber:
          type: string
          description: project version number
        title:
          type: string
          description: title of the object
        state:
          type: string
          description: state of the object
        metadata:
          $ref: '#/components/schemas/Metadata'
    TestSuite:
      allOf:
        - $ref: '#/components/schemas/BaseEntity'
      properties:
        tags:
          type: string
          nullable: true
    TestFolder:
      allOf:
        - $ref: '#/components/schemas/BaseEntity'
    TestCase:
      allOf:
        - $ref: '#/components/schemas/BaseEntity'
      properties:
        status:
          type: string
          description: The current status of this item
          enum:
            - NEW
            - IN_PROGRESS
            - TO_BE_REVIEWED
            - TO_BE_CORRECTED
            - TO_BE_REVIEWED_AGAIN
            - REVIEWED
            - DONE
        assignee:
          type: string
          nullable: true
          description: assignee of this test case
        type:
          type: string
          nullable: true
          description: The type of test case
          enum:
            - FUNCTIONAL
            - PERFORMANCE
            - SECURITY
            - USABILITY
            - MODEL
        automation:
          type: string
          nullable: true
          description: Indicates the automation status of this test case
          enum:
            - TO_BE_EVALUATED
            - TO_BE_AUTOMATED
            - AUTOMATED
            - AUTOMATED
            - NOT_TO_BE_AUTOMATED
        prioritization:
          type: string
          nullable: true
          enum:
            - MANDATORY
            - OPTIONAL
            - NO_TEST
        versionDelta:
          type: boolean
          description: >-
            Indicates if this item is an important addition for the next test
            run (Version delta)
        description:
          type: string
          nullable: true
          description: description of the object
        tags:
          type: string
          nullable: true
          description: tags of the test cases. The values are separated by the comma
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Attachment'
        precondition:
          type: string
          nullable: true
          description: The preconditions required before executing this test case.
        testSteps:
          $ref: '#/components/schemas/TestSteps'
        metadata:
          $ref: '#/components/schemas/Metadata'
    Metadata:
      type: object
      properties:
        createdOn:
          type: integer
          format: int64
          description: when is the object created
        createdBy:
          type: string
          description: who created the object
        editedOn:
          type: integer
          format: int64
          description: when is the object edited
          nullable: true
        editedBy:
          type: string
          description: who edited the object
          nullable: true
        derivedFrom:
          type: string
          description: applicable for version object
          nullable: true
    RpcRequestWithIdAndJsonRpc:
      type: object
      required:
        - id
        - jsonrpc
      properties:
        id:
          type: string
          description: id of the operation
        jsonrpc:
          type: string
          description: must be 2.0
          example: '2.0'
    RpcResult:
      type: object
      properties:
        jsonrpc:
          type: string
          description: request jsonrpc version
        id:
          type: string
          description: id of the operation
        result:
          type: object
    TaskRequestDocumentResult:
      allOf:
        - $ref: '#/components/schemas/RpcResult'
        - type: object
          properties:
            result:
              type: string
              description: task request's document reference
      examples:
        - jsonrpc: '2.0'
          id: EXPORT_QF_DATA_STRUCTURE
          result: TaskRequest-dm/129000
    File:
      type: object
      properties:
        content:
          type: string
          nullable: true
          description: Content of the file in base64 format.
        attachment_id:
          type: string
          description: Unique identifier for the attachment.
        internal_filename:
          type: string
          description: Internal storage filename for the attachment.
        original_filename:
          type: string
          description: Original name of the uploaded file.
        size:
          type: integer
          description: Size of the file in bytes.
        mime_type:
          type: string
          description: MIME type of the file.
    Attachment:
      type: object
      properties:
        FileName:
          type: string
          description: Name of the file attached.
        CreatedAt:
          type: string
          format: date-time
          description: Timestamp when the attachment was created.
        UploadOn:
          type: string
          format: date
          description: Date when the file was uploaded.
        OriginalFileName:
          type: string
          description: Original filename as provided during upload.
        UploadBy:
          type: string
          description: Username of the uploader.
        Referenced:
          type: boolean
          description: Indicates if the attachment is referenced elsewhere.
        CopyNumber:
          type: integer
          description: Number of times the attachment has been copied.
        ThumbnailId:
          type: string
          description: Identifier for the attachment’s thumbnail image.
        File:
          $ref: '#/components/schemas/File'
    TestSteps:
      type: array
      items:
        type: object
        properties:
          'No':
            type: integer
            description: Number of the test step (one based)
          Id:
            type: string
            description: Id of the test step (as UUID format) (it is only unique within TC)
          Action:
            type: string
            description: The action to be performed in this test step.
          ExpectedResult:
            type: string
            description: The expected result upon completion of this test step.
  parameters:
    ProjectIdHeader:
      name: Project-Id
      in: header
      required: true
      schema:
        type: string
      description: Project Id or the project document reference
    SubProjectIdHeader:
      name: Subproject-Id
      in: header
      required: false
      schema:
        type: string
      description: >-
        Sub Project Id or the project document reference. It might be required
        if you want to access the sub project's resource
