openapi: 3.0.3
info:
  title: Testany Platform API
  description: |-
    Testany API provides programmatic access to our testing platform, enabling users to automate testing workflows, manage test executions, and retrieve test results with ease.
  termsOfService: https://www.testany.io/terms-of-service
  contact:
    email: customer-support@testany.io
  license:                                    # need refine
    name: Testany
    url: https://www.testany.com.cn
  version: 2.1.0
servers:
  - url: "https://{tenant}.testany.com.cn/api/v2"
    description: "Your dedicated tenant"
    variables:
      tenant:
        default: "your-tenant"
        description: "Your organization's tenant name (provided during onboarding)"

  - url: "https://app.testany.com.cn/api/v2"
    description: "Multi-tenant shared environment"

security:
  - bearerAuth: []
tags:
  - name: Case Management
    description: Manage and retrieve metadata related to individual test cases within the platform.
  - name: Pipeline Management
    description: Access and operate on test pipelines, including creation, reading, updates, and deletion.
  - name: Execution Management
    description: Control and monitor the execution of test cases and pipelines, including results tracking.
  - name: Workspace Management
    description: Manage workspace configurations, resources, and settings within the platform.
  - name: Plan Management
    description: Define, manage, and schedule test executions on the platform.
  - name: User Management
    description: Handle user accounts, roles, and permissions for secure and organized access to platform features.
  - name: Metering Query
    description: Retrieve metering data, providing insights into usage statistics across workspaces and tenants.
  - name: Gatekeeper Management
    description: Set up and manage gatekeepers for triggering pipeline executions under specified conditions.
  - name: Internal API
    description: Internal functionalities for platform operations and service-to-service interactions.
  - name: Authorization Management
    description: Validate and manage user permissions and access control for platform operations.
  - name: Tenant Management
    description: APIs dedicated to tenant-level management, enabling administrators to oversee tenant configurations, billing & credit info, and resource allocation.
  - name: Testany Secrets Service Management
    description: Securely manage sensitive secrets and credentials within the platform's secrets service.
  - name: Partner Management
    description: Manage partner configurations and integrations within the platform.
  - name: NG Management APIs
    description: Perform administrative tasks at the global level for Notification Gateway.
  - name: NG Receiver APIs
    description: APIs to manage receivers, including configuration and notification settings.
  - name: NG Rule APIs
    description: Manage rules of the notifications
  - name: NG Utility APIs
    description: Utility functions to support miscellaneous operational needs within the Notification Gateway Service.
  - name: Directory View Management APIs
    description: APIs to manage directory views within the platform.



paths:
  /tenant/organization:
    get:
      tags:
        - Tenant Management
      summary: Get organization metadata
      description: get organization metadata, include organization name, uuid, domain_prefix and logo, etc.
      operationId: getOrganizationInfo
      parameters: 
        - name: Tenant  
          in: header
          description: The value is `org_domain_prefix` of the tenant you admin. If the value is not provided, the API will return the usage info of the current tenant.
          schema: 
            $ref: '#/components/schemas/org_domain_prefix_base_string'
      responses:
        '200':
          description: Return organization metadata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TenantDetailInfo'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
      
  /tenant/organization/{uuid}:
    patch:
      tags:
        - Tenant Management
      summary: Update organization base infomation
      description: For tenant global admin use only. base info include `name`, `wide_logo`, `square_logo` and `timezone`
      operationId: updateOrganizationInfo
      parameters:
        - name: uuid
          in: path
          description: organization uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
      requestBody:
        description: |
          Update organization base info. Currently, `timezone` is not allowed to be updated.
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/TenantBaseInfoPack' 
        required: true
      responses:
        '200':
          description: Return updated tenant name and logos
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TenantDetailInfo'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /tenant/organization/{uuid}/usage:
    get:
      tags:
        - Tenant Management
      summary: Get organization usage
      description: get organization usage info, this method is for global admin and authorized Testany employee only
      operationId: getOrganizationUsage
      parameters:
        - name: Tenant  
          in: header
          description: The value is `org_domain_prefix` of the tenant you admin. If the value is not provided, the API will return the usage info of the current tenant.
          schema: 
            $ref: '#/components/schemas/org_domain_prefix_base_string'
        - name: uuid
          in: path
          description: organization uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
      responses:
        '200':
          description: |- 
            Return organization usage data
            - deployment_type: 1. Single-Tenant Instance 2. Multi-Tenant Instance
            - payment_method: 1. Prepaid 2. Postpaid
            - credit_balance: The remaining balance allows for the number of pipeline executions.
            - grace_credit_balance: The remaining balance of the grace credit.
            - time_to_depletion: The estimated time to depletion of the credit balance (in days).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TenantUsageResponse'
        default:
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'       

  /tenant/organization/{uuid}/topup:
    get:
      tags:
        - Tenant Management
      summary: Get tenant topup history for prepaid tenant
      description: Retrieve top-up history, this method is for Global Admin & authorized Testany employee only
      operationId: getOrganizationTopupHistory
      parameters:
        - name: Tenant  
          in: header
          description: The value is `org_domain_prefix` of the tenant you admin. If the value is not provided, the API will return the top-up history of the current tenant.
          schema: 
            $ref: '#/components/schemas/org_domain_prefix_base_string'
        - name: uuid
          in: path
          description: tenant uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
      responses:
        '200':
          description: Return the full list of tenant top-up records in an array format.
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  allOf:
                    - $ref: '#/components/schemas/TenantInvoiceBaseInfo'
                    - type: object
                      properties: 
                        topup_date:
                          $ref: '#/components/schemas/date_base_string'
                        operator:
                          $ref: '#/components/schemas/user_uid_base_string'
                        topup_id:
                          $ref: '#/components/schemas/uuid_base_string'
              example:
                - topup_date: "2021-01-01"
                  topup_amount: 10000
                  po_number: "PO-0001"
                  grace_credit_amount: 1024
                  operator: john.doe@testany.io
                  topup_id: 123e4567-e89b-12d3-a456-426614174000
                - topup_date: "2021-02-01"
                  topup_amount: 20000
                  po_number: "PO-0002"
                  grace_credit_amount: 2048
                  operator: joe.ron@testany.io
                  topup_id: 123e4567-e89b-12d3-a456-426614174001
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'        

    post:
      tags:
        - Tenant Management
      summary: Credit topup for prepaid tenant
      description: top-up credit, for authorized Testany employee only
      operationId: topupOrganizationCredit
      parameters:
        - name: Tenant  
          in: header
          description: The tenant where the Testany employee authentication system is located.
          schema: 
            $ref: '#/components/schemas/org_domain_prefix_base_string'
        - name: uuid
          in: path
          description: organization uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
      requestBody:
        description: |
          - `topup_amount` is the amount of the pipline execution times to be added to the tenant's acconut balance.
          - `po_number` is the purchase order number from the customer. If there's no PO number got from customer, please use empty string here.
          - `grace_credit_amount` is the amount of the grace credit to the total credit balance. If there's no grace credit, you don't have to include this field in your request.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TenantInvoiceBaseInfo'
            example:
              topup_amount: 10000
              po_number: "PO-0001"
              grace_credit_amount: 1024
        required: true
      responses:
        '200':
          description: Return organization current topup data
          content:
            application/json:
              schema:
                type: object
                allOf:
                  - $ref: '#/components/schemas/TenantInvoiceBaseInfo'
                properties:
                  topup_date_time:
                    $ref: '#/components/schemas/date_time_base_string'
                  operator:
                    $ref: '#/components/schemas/user_uid_base_string'
                  topup_id:
                    $ref: '#/components/schemas/uuid_base_string'
              example:
                topup_date_time: "2021-01-01T00:00:00Z"
                topup_amount: 200
                po_number: "PO-0002"
                grace_credit_amount: 1024
                operator: john.doe@testany.io
                topup_id: 123e4567-e89b-12d3-a456-426614174000
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse' 
                 
  /tenant/organization/{uuid}/topup/{topup_id}:
    delete: 
      tags:
        - Tenant Management
      summary: Revoke tenant topup record
      description: Revoke tenant topup record, for authorized Testany employee only
      operationId: revokeOrganizationTopup
      parameters:
        - name: Tenant  
          in: header
          description: The tenant where the Testany employee authentication system is located.
          schema: 
            $ref: '#/components/schemas/org_domain_prefix_base_string'
        - name: uuid
          in: path
          description: organization uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
        - name: topup_id
          in: path
          description: topup record uuid
          required: true
          schema:
            $ref: '#/components/schemas/uuid_base_string'
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
      

                
  /tenant/findLabels:
    get:
      tags:
        - Tenant Management
      summary: Get tenant labels
      description: get tenant labels
      operationId: getTenantLabels
      responses:
        '200':
          description: Return organization data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/tenant_labels_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /tenant/label:
    post:
      tags:
        - Tenant Management
      summary: Create a tenant label
      description: create a tenant label
      operationId: addTenantLabel
      requestBody:
        description: |
          Label
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                name: 
                  $ref: '#/components/schemas/tenant_label_base_string'
              required:
                - name
      responses:
        '200':
          description: Return label data
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  name:
                    $ref: '#/components/schemas/tenant_label_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    
  /permission/check:
    post:
      tags:
        - Authorization Management
      summary: Check user permission
      description: check user permission
      operationId: userPermissionCheck
      requestBody:
        description: |
          Permission check
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/permission_check_object'
        required: true
      responses:
        '200':
          description: Return permission check result
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  result:
                    $ref: '#/components/schemas/boolean_base_boolean'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /permission/signForTSSM:
    post:
      tags:
        - Authorization Management
      summary: Check user permission
      description: check user for TSSM permission
      operationId: userTSSMPermissionSign
      requestBody:
        description: |
          Permission check used sign payload
          - `workspace_key`: used for check create/list credentialsafe API
          - `credentialsafe_key`: edit/delete credentialsafe, create/edit/delete/read/list credential
          - `case_key`: used for findAll binding credentials
          - `secure_uuid`: used for bind credential or findAll binding credentials
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              $ref: '#/components/schemas/sign_for_TSSM_permission_check_object'
        required: true
      responses:
        '200':
          description: Return permission check result
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                $ref: '#/components/schemas/permission_sign_response_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /permission-internal/check:
    post:
      tags:
        - Authorization Management
      summary: Check user permission
      description: check user permission
      operationId: userPermissionCheckInternal
      requestBody:
        description: |
          Permission check
        content:
          application/json:
            schema:
              additionalProperties: true
              type: object
              $ref: '#/components/schemas/permission_internal_check_object'
        required: true
      responses:
        '200':
          description: Return permission check result
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  result:
                    $ref: '#/components/schemas/boolean_base_boolean'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /permission-internal/sign:
    post:
      tags:
        - Authorization Management
      summary: Use this method to sign your payload
      description: use this method to sign your payload
      operationId: signPayload
      requestBody:
        description: |
                provide your payload which need to sign
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              $ref: '#/components/schemas/permission_sign_request_base_string'
#              example: "{\"data1\":\"1111\",\"data2\":\"2222\"}"
        required: true
      responses:
        '200':
          description: Return permission check result
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                $ref: '#/components/schemas/permission_sign_response_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/case/secureUUIDsToCases:
    post:
      tags:
        - Internal API
      summary: Trigger pipelines by pipeline key list
      description: trigger pipelines by pipeline key list
      operationId: listcases
      requestBody:
        description: |
          find cases by secureuuids, if the secureuuid not findout any test cases, remove it from the response.
        content:
          application/json:
            schema:
              type: array
              maxItems: 10000
              items:
                type: string
                example: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
               
        required: true
      responses:
        '200':
          description: Successful triggered
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  type: object
                  additionalProperties: false
                  properties:
                    key:
                      type: string
                      example: "A12B123D"
                    name:
                      type: string
                      example: "A12B123D"
                    description:
                      type: string
                      example: "A12B123D"
                    environment:
                      type: string
                      example: "PROD"
                    owned_by:
                      type: array
                      maxItems: 10000
                      items:
                        type: string
                        example: "boyi.liang@testany.io"
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/case/fetchSecureUUID:
    get:
      tags:
        - Internal API
      summary: Get case secure uuid
      description: Get case secure uuid
      operationId: getCaseSecureUUIDInternalUse
      parameters:
        - name: key
          in: query
          description: the case key
          required: false
          schema:
            type: string
            pattern: "^[0-9a-fA-F]{8}$"
            example: 'AB12CD12'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  secureUUID:
                    type: string
                    example: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/plan/findDetail/{key}:
    get:
      tags:
        - Internal API
      summary: Get plan details
      description: |
        http://backend.testany-dev/internal/plan/findDetail/{key}
        Get plan detail data
      
      operationId: getPlanDetail
      parameters:
        - name: key
          in: path
          description: the plan key
          required: true
          schema:
            type: string
            pattern: 'P-[A-Z][A-Z0-9]{2}-[0-9a-fA-F]{4}'
            example: 'P-WKS-0001'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  key:
                    type: string
                    example: 'P-WKS-0001'
                  name:
                    type: string
                    example: 'My first plan'
                  owner:
                    type: array
                    maxItems: 10000
                    items:
                      type: string
                      example: abc@testany.io
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/gatekeeper/findDetail/{key}:
    get:
      tags:
        - Internal API
      summary: Get gatekeeper details
      description: |
        http://gatekeeper-service.testany-dev/internal/gatekeeper/findDetail/{key}
        Get gatekeeper detail data
      operationId: getGatekeeperDetail
      parameters:
        - name: key
          in: path
          description: the plan key
          required: true
          schema:
            type: string
            pattern: 'G-[A-Z][A-Z0-9]{2}-[0-9a-fA-F]{4}'
            example: G-WKS-0001'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  key:
                    type: string
                    example: 'P-WKS-0001'
                  name:
                    type: string
                    example: 'My first plan'
                  owner:
                    type: array
                    maxItems: 10000
                    items:
                      type: string
                      example: abc@testany.io
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
 
  /internal/batchTrigger:
    post:
      tags:
        - Internal API
      summary: Trigger pipelines by pipeline key list
      description: trigger pipelines by pipeline key list
      operationId: triggerPipelines
      requestBody:
        description: |
          pipeline keys and userid
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                pipelines: 
                  type: array
                  maxItems: 10000
                  items:
                    type: string
                    example: 'WKS-0001'
                trigger_user: 
                  type: string
                  example: 'boyi.liang@testany.io'
        required: true
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/batchTriggerPipelines:
    post:
      tags:
        - Internal API
      summary: Trigger pipelines by pipeline key list
      description: trigger pipelines by pipeline key list
      operationId: triggerPipelineByKeyList
      requestBody:
        description: |
          pipeline keys and plan or gatekeeper
          
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                pipelines: 
                  type: array
                  maxItems: 10000
                  items:
                    type: string
                    example: 'WKS-0001'
                watchers: 
                  type: array
                  maxItems: 10000
                  items:
                    type: string
                    example: 'xxx@testany.io'
                    description: user uid
                key:
                  type: string
                  example: 'KEY'
                type:
                  type: string
                  example: 'plan or gatekeeper'
        required: true
      responses:
        '200':
          description: Successful triggered
          content:
              application/json:
                schema:
                  additionalProperties: false
                  type: object
                  properties:
                    triggered:
                      type: array
                      maxItems: 10000
                      items:
                        additionalProperties: false
                        type: object
                        properties:
                          pipeline:
                            type: string
                            example: "WKS-0001"
                          execution:
                            type: string
                            example: "WKS-0001-ABECD"
                    error:
                      type: string
                      example: "error message if any error occured."
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/groupTrigger/{group_key}:
    post:
      tags:
        - Internal API
      summary: Execute pipeline by a group key, triggered by group key
      description: Returns a Pipeline Execution Key List
      operationId: executePipelineByGroupKey
      parameters:
        - name: group_key
          in: path
          description: key of plan to return
          required: true
          schema:
            type: string
            example: G-WKS-0001 or P-WKS-0001
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  executions:
                    type: array
                    maxItems: 10000
                    items:
                      additionalProperties: false
                      type: object
                      properties:
                        exectuion:
                          type: string
                          example: 'WKS-0001-1A2E'
                        pipeline:
                          type: string
                          example: 'WKS-0001'
                        error:
                          type: object
                          additionalProperties: false
                          properties:
                            code:
                              type: string
                              example: 'E101001'
                            message:
                              type: string
                              example: 'Some Errors'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
   
    

  /case/myCases:
    get:
      tags:
        - Case Management
      summary: Retrieve a list of test cases owned by a specified user
      description: Retrieve a list of test cases owned by a specified user. If a `uid` is provided, the API will return cases owned by the specified user. If `uid` is not provided, it defaults to listing cases owned by the current user accessing the API.
      operationId: listMyCases
      parameters:
        - name: uid
          in: query
          description: The unique identifier of the user whose cases are being queried. If omitted, the API will return cases owned by the current user.
          required: false
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/CaseForMyList'
                example:
                  - key: "A12B123D"
                    name: "My first case"
                    description: "This is my first case"
                    environment: "PROD"
                  - key: "A12B123E"
                    name: "My second case"
                    description: "This is my second case"
                    environment: "PROD"
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'


  /case/dryRun/{dry_run_id}:
    get:
      tags:
        - Case Management
      summary: Get the details of a dry run case.
      description: Retrieve detailed results of a test case DryRun. The `dry_run_id` is the unique identifier for this specific DryRun instance.
      operationId: getDryRunCaseDetail
      parameters:
        - name: dry_run_id
          in: path
          description: string
          schema:
            $ref: '#/components/schemas/case_dry_run_id_base_string'
          required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaseForDryRun'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'


  /case/{key}/dryRun:
    post:
      tags:
        - Case Management
      summary: Submit a case for DryRun
      description: This endpoint initiates a DryRun request to the system for a test case. It allows users to validate and test the modifications made to the case. The `key` parameter is the unique identifier of the test case. This DryRun simulates the case execution with the proposed changes, providing insights into potential issues or necessary adjustments. Users can use the `dry_run_id` returned in this API's response as a "ticket" to check the results of the DryRun by calling GET /case/dryRun/{dry_run_id}.
      operationId: CaseDryRun
      parameters:
        - name: key
          in: path
          description: "The key of the test case."
          schema:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'
          required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaseDryRunID'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /case:
    post:
      tags:
        - Case Management
      summary: Add a new Case
      description: Add a new Case
      operationId: addCase
      requestBody:
        description: Create a new Case
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CaseSharedFields'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties: 
                  key:
                    $ref: '#/components/schemas/unit_layer_object_key_base_string'

        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    
  /case/filterListCases:
    get:
      tags:
        - Case Management
      summary: List Cases with limited fields
      description: For Pre query, list a lite cases to find out a specific Case Key or Name
      operationId: filterListCases
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/CaseFilter'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/filterListCreators:
    get:
      tags:
        - Case Management
      summary: List Case Creators
      description: For Pre query, list creators
      operationId: filterListCaseCreators
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForFilter'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/filterListEnvironments:
    get:
      tags:
        - Case Management
      summary: List case by environment 
      description: For Pre query, list cases by selected environments
      operationId: filterListCaseEnvs
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/object_environments_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/filterListVersions:
    get:
      tags:
        - Case Management
      summary: List all test case versions visible to current user
      description: List all test case versions visible to current user
      operationId: filterListCaseVersions
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/object_labels_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/filterListWorkspaces:
    get:
      deprecated: true
      tags:
        - Case Management
      summary: List case by workspace 
      description: For Pre query, list cases by selected workspaces
      operationId: filterListCaseWorkspaces
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/workspace_key_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/filterListRuntimes:
    get:
      tags:
        - Case Management
      summary: List case by runtimes 
      description: For Pre query, list case by selected runtimes
      operationId: filterListCaseRuntimes
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  additionalProperties: false
                  type: object
                  properties:
                    runtime_uuid: 
                      $ref: '#/components/schemas/runtime_uuid_base_string'
                    runtime_name:
                      allOf:
                        - $ref: '#/components/schemas/runtime_name_base_string'
                      example: 'CloudPrime-Default'                     
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'


  /case/findCases:
    post:
      tags:
        - Case Management
      summary: Finds Cases with multiple filters
      description: Find Cases by keyOrName, description, env, creator
      operationId: findCasesByNameOrKeyOrDescriptionOrEnv
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                next_page_token:
                  $ref: '#/components/schemas/page_next_page_token_base_string'
                page:
                  $ref: '#/components/schemas/page_page_number_base_integer'
                page_size:
                  $ref: '#/components/schemas/page_page_size_base_integer'
                key_or_name:
                  $ref: '#/components/schemas/unit_layer_object_key_base_string'
                environments:
                  $ref: '#/components/schemas/object_environments_base_array'
                owned_by:
                  $ref: '#/components/schemas/object_owner_base_string'
                workspaces:
                  $ref: '#/components/schemas/workspace_key_base_array'
                is_not_private:
                  $ref: '#/components/schemas/boolean_base_boolean'
                owned_by_me:
                  $ref: '#/components/schemas/boolean_base_boolean'
                runtime_uuid:
                  $ref: '#/components/schemas/runtime_uuid_base_string'
                executor:
                  $ref: '#/components/schemas/case_executor_base_string'
                relay_flag:
                  $ref: '#/components/schemas/case_relay_flag_base_boolean'
                case_labels:
                  $ref: '#/components/schemas/object_labels_base_array'
                case_version:
                  $ref: '#/components/schemas/object_label_base_string'
                created_at_from:
                  $ref: '#/components/schemas/date_time_base_string'
                created_at_to:
                  $ref: '#/components/schemas/date_time_base_string'
                updated_at_from:
                  $ref: '#/components/schemas/date_time_base_string'
                updated_at_to:
                  $ref: '#/components/schemas/date_time_base_string'
      responses:
        '200':
          description: successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string'
            x-Total-Items:
              description: |
                total items in the result set
              schema:
                type: integer
                format: int32
                example: 1000
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/CaseForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/{key}:
    get:
      tags:
        - Case Management
      summary: Get Case Detail by key
      description: Returns a single Case
      operationId: getCaseByKey
      parameters:
        - name: key
          in: path
          description: key of the test case
          required: true
          schema:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Case'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - Case Management
      summary: Update an existing Case
      description: Update an existing Case by Id
      operationId: updateCase
      parameters:
        - name: key
          in: path
          description: key of case to return
          required: true
          schema:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'
      requestBody:
        description: Update an existent Case Metadata
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CaseForUpdate'
      responses:
        '200':
          description: Successful operation
          content: 
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  dry_run_ready:
                    $ref: '#/components/schemas/case_dry_run_ready_base_boolean'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - Case Management
      summary: Delete a Case
      description: Delete a Case. Please note when a Case is used by any Pipeline (orchestrated in a Pipeline), it cannot be deleted.
      operationId: deleteCase
      parameters:
        - name: key
          in: path
          description: Case key to delete
          required: true
          schema:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/{key}/script:
    get:
      tags:
        - Case Management
      summary: Retrieve the script file for a case by its key
      description: Retrieve the script file for a case by its key. This API is only applicable to cases registered through script uploads.
      operationId: getCaseCodeByKey
      parameters:
        - name: key
          in: path
          description: key of the test case on the Testany platform
          required: true
          schema:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/zip:
              schema:
                $ref: '#/components/schemas/case_file_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
    put:
      tags:
        - Case Management
      summary: Update the script file for a case by its key
      description: Update the script file for a case by its key. This API is only applicable to cases registered through script uploads.
      operationId: updateCaseCodeByKey
      parameters:
        - name: key
          in: path
          description: key of the test case on the Testany platform
          required: true
          schema:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'
      requestBody:
        description: Update the script file for a case by its key. It allows .zip file only, and empty payload is not allowed.
        content:
          application/zip:
            schema:
              $ref: '#/components/schemas/case_file_base_string'
        required: true
      responses:
        '200':
          description: Successful operation
          content: 
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  dry_run_ready:
                    $ref: '#/components/schemas/case_dry_run_ready_base_boolean'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'


          
  /case/fetchSecureUUID:
    get:
      tags:
        - Case Management
      summary: Get case secure uuid
      description: Get case secure uuid
      operationId: getCaseSecureUUID
      parameters:
        - name: key
          in: query
          description: the case key
          required: false
          schema:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  secureUUID:
                    allOf:
                      - $ref: '#/components/schemas/tssm_credential_uuid_base_string'
                    description: 'The secure uuid of credential used by the case'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/importHistory:
    post:
      tags:
        - Case Management
      summary: Create an importHistory
      description: Create an importHistory to import scripts from a git repository
      operationId: importCaseFromGit
      requestBody:
        description: Import a case from a git repository
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/case_import_history_list_full_object'
      responses:
        '200': 
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/case_import_history_list_base_object'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
                
    get:
      tags:
        - Case Management
      summary: Get case import history list
      description: Get case import history list
      operationId: getCaseImportHistoryList
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 1000
                items:
                  $ref: '#/components/schemas/case_import_history_list_base_object'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
                
  /case/importHistory/{id}:
    get:
      tags:
        - Case Management
      summary: Get case import history by id
      description: Get case import history by id
      operationId: getCaseImportHistoryById
      parameters:
        - name: id
          in: path
          description: the id of the case import history
          required: true
          schema:
            $ref: '#/components/schemas/case_import_history_id_base_string'
        - name: include
          in: query
          description: |
            Pass `deletion_impact` to also get the deletion impact: which Cases the import history owns and what each one
            allows (`RETAIN_LOCAL`, `DELETE`, `BLOCKED`). The impact carries the `source` and `source_etag` that
            `POST /case/source-detachments` needs. The response then has an extra `deletion_impact` object.
          required: false
          schema:
            type: string
            enum: [deletion_impact]
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/case_import_history_with_deletion_impact'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
                
    delete:
      tags:
        - Case Management
      summary: Delete a case import history by id (confirm a prepared source detachment)
      description: |
        Deleting a case import history is a two-step operation. First read the deletion impact
        (`GET /case/importHistory/{id}?include=deletion_impact`) and prepare a source detachment with
        `POST /case/source-detachments` (choose the Cases to keep; an empty selection deletes them all). When the
        prepared operation is `READY`, confirm it with this request, sending the operation id in
        `X-Case-Detachment-Id` and its `ready_etag` in `If-Match`.

        A request without `X-Case-Detachment-Id` is rejected with `400` and deletes nothing: the former
        one-step delete is no longer available.
      operationId: deleteCaseImportHistoryById
      parameters:
        - name: id
          in: path
          description: the id of the case import history
          required: true
          schema:
            $ref: '#/components/schemas/case_import_history_id_base_string'
        - name: X-Case-Detachment-Id
          in: header
          description: the id of the prepared source detachment operation (state `READY`)
          required: true
          schema:
            type: string
            format: uuid
        - name: If-Match
          in: header
          description: the `ready_etag` of the prepared source detachment operation
          required: true
          schema:
            type: string
      responses:
        '204':
          description: No content, the import history and the Cases that were not kept are deleted
        '202':
          description: Accepted, the final deletion is not finished yet; read the source detachment operation to follow it
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/source-detachments:
    post:
      tags:
        - Case Management
      summary: Prepare removing a case source (import history) and its Cases
      description: |
        Step one of removing a Git import history: choose which of its Cases to keep as local Cases (`retain_cases`; an
        empty array keeps none and removes them all). The request deletes nothing. It returns an operation; when it is
        `READY`, confirm it with `DELETE /case/importHistory/{id}` (headers `X-Case-Detachment-Id` and `If-Match`).
        Read the impact first with `GET /case/importHistory/{id}?include=deletion_impact` and send its `source` and
        `source_etag` unchanged. A `READY` operation that is not confirmed within 15 minutes expires (confirming it then
        answers `410 CSD_EXPIRED`); prepare again with a new `Idempotency-Key`.
      operationId: prepareCaseSourceDetachment
      parameters:
        - name: Idempotency-Key
          in: header
          description: a UUID chosen by the caller; the same key with the same body returns the same operation
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/case_source_detachment_prepare_request'
      responses:
        '202':
          description: Accepted. The operation is in the body; `Location` points to it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/case_source_detachment_operation'
        default:
          $ref: '#/components/responses/DefaultResponse'
        '400':
          $ref: '#/components/responses/BadRequestResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedResponse'
        '403':
          $ref: '#/components/responses/ForbiddenResponse'
        '404':
          $ref: '#/components/responses/NotFoundResponse'
        '409':
          $ref: '#/components/responses/ConflictResponse'
        '429':
          $ref: '#/components/responses/TooManyRequestsResponse'

  /case/source-detachments/{id}:
    get:
      tags:
        - Case Management
      summary: Read a source detachment operation
      description: Read the operation back (state, per-Case progress, `ready_etag`, last error).
      operationId: getCaseSourceDetachment
      parameters:
        - name: id
          in: path
          description: the `operation_id` returned by the prepare request
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/case_source_detachment_operation'
        default:
          $ref: '#/components/responses/DefaultResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedResponse'
        '403':
          $ref: '#/components/responses/ForbiddenResponse'
        '404':
          $ref: '#/components/responses/NotFoundResponse'
        '429':
          $ref: '#/components/responses/TooManyRequestsResponse'
    delete:
      tags:
        - Case Management
      summary: Cancel a source detachment operation
      description: |
        Abandon a prepared operation. Nothing was deleted by preparing, and nothing is deleted by cancelling. An operation
        whose final deletion has started cannot be cancelled (`409`).
      operationId: cancelCaseSourceDetachment
      parameters:
        - name: id
          in: path
          description: the `operation_id` returned by the prepare request
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: the cancelled operation (`CANCELLED`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/case_source_detachment_operation'
        default:
          $ref: '#/components/responses/DefaultResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedResponse'
        '403':
          $ref: '#/components/responses/ForbiddenResponse'
        '404':
          $ref: '#/components/responses/NotFoundResponse'
        '409':
          $ref: '#/components/responses/ConflictResponse'
        '429':
          $ref: '#/components/responses/TooManyRequestsResponse'

  /case/importHistory/validatePayload:
    post:
      tags:
        - Case Management
      summary: Validate the payload of  a case import history
      description: Validate the payload of a case import history
      operationId: validateCaseImportHistoryPayload
      requestBody:
        description: Validate the payload of a case import history
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/case_import_history_payload_full_array'
      responses:
        '200':
          description: "checked payload"
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  valid:
                    type: boolean
                  checked_payload:
                    type: array
                    maxItems: 1000
                    items:
                      $ref: '#/components/schemas/case_import_history_payload_full_object'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/importHistory/{id}/payload:
    get:
      tags:
        - Case Management
      summary: Get the payload of a case import history by id
      description: Get the payload of a case import history by id
      operationId: getCaseImportHistoryPayloadById
      parameters:
        - name: id
          in: path
          description: the id of the case import history
          required: true
          schema:
            $ref: '#/components/schemas/case_import_history_id_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/case_import_history_payload_full_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'  
                
    put:
      tags:
        - Case Management
      summary: Update the payload of a case import history by id
      description: Update the payload of a case import history by id
      operationId: updateCaseImportHistoryPayloadById
      parameters:
        - name: id
          in: path
          description: the id of the case import history
          required: true
          schema:
            $ref: '#/components/schemas/case_import_history_id_base_string'
      requestBody:
        description: Update the payload of a case import history by id
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/case_import_history_payload_full_array'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/bulkUpdate:
    patch:
      tags:
        - Case Management
      summary: Bulk update cases
      description: Bulk update cases
      operationId: bulkUpdateCases
      requestBody:
        description: Bulk update cases
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                case_keys:
                  type: array
                  maxItems: 10000
                  items:
                    $ref: '#/components/schemas/unit_layer_object_key_base_string'
                case_version:
                  $ref: '#/components/schemas/case_version_base_string'
                  nullable: true
                is_private:
                  $ref: '#/components/schemas/is_private_base_boolean'
                  nullable: false
                workspace_keys:
                  $ref: '#/components/schemas/workspace_key_base_array'
                  nullable: true
                environments:
                  $ref: '#/components/schemas/object_environments_base_array'
                  nullable: true
                environment_variables:
                  type: array
                  maxItems: 1000
                  items:
                    $ref: '#/components/schemas/case_environment_variable_base_object'
                  nullable: true
                case_labels:
                  $ref: '#/components/schemas/object_labels_base_array'
                  nullable: true
              required:
                - case_keys
      responses:
        '204':
          description: No content
        default:
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /case/bulkAppend:
    post:
      tags:
        - Case Management
      summary: Bulk append cases
      description: Bulk append cases
      operationId: bulkAppendCases
      requestBody:
        description: Bulk append cases
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                case_keys:
                  type: array
                  maxItems: 10000
                  items:
                    $ref: '#/components/schemas/unit_layer_object_key_base_string'
                workspace_keys:
                  $ref: '#/components/schemas/workspace_key_base_array'
                  nullable: false
                environments:
                  $ref: '#/components/schemas/object_environments_base_array'
                  nullable: false
                environment_variables:
                  type: array
                  maxItems: 1000
                  items:
                    $ref: '#/components/schemas/case_environment_variable_base_object'
                  nullable: false
                case_labels:
                  $ref: '#/components/schemas/object_labels_base_array'
                  nullable: false
              required:
                - case_keys
      responses:
        '204':
          description: No content
        default:
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
  
  /case/bulkDelete:
    post:
      tags:
        - Case Management
      summary: Bulk delete cases
      description: Bulk delete cases
      operationId: bulkDeleteCases
      requestBody:
        description: Bulk delete cases
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                case_keys:
                  type: array
                  maxItems: 10000
                  items:
                    $ref: '#/components/schemas/unit_layer_object_key_base_string'
              required:
                - case_keys
      responses:
        '204':
          description: No content
        default:
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
              
  /case/bulkCheck:
    post:
      tags:
        - Case Management
      summary: Bulk check cases
      description: |
        Check if the bulk cases are valid for the bulk operation. The response is always HTTP 200; read each check object.
        When a check fails (`valid` is false), `message` is the human-readable text and `reason_code` plus `case_keys` give the stable, machine-readable cause and the cases involved. A passing check has neither key.
      operationId: bulkCheckCases
      requestBody:
        description: Bulk check cases
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                case_keys:
                  type: array
                  maxItems: 10000
                  items:
                    $ref: '#/components/schemas/unit_layer_object_key_base_string'
              required:
                - case_keys
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  delete_check:
                    type: object
                    additionalProperties: false
                    properties:
                      valid:
                        type: boolean
                      message:
                        $ref: '#/components/schemas/long_text_base_string'
                      reason_code:
                        type: string
                        pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                        maxLength: 64
                        description: "Present only when valid is false. Why the check failed: READ_FORBIDDEN, CASE_NOT_FOUND, PERMISSION_SERVICE_ERROR, WORKSPACE_ACCESS_DENIED, RUNTIME_MISMATCH, NOT_PRIVATE, NOT_OWNER, GIT_IMPORTED_CANNOT_DELETE or IN_USE_BY_PIPELINE. When several reasons apply, only the first one the service checks is reported. New values may be added."
                      case_keys:
                        type: array
                        maxItems: 10000
                        description: "Present only when valid is false and the service knows which cases caused it (absent for PERMISSION_SERVICE_ERROR)."
                        items:
                          $ref: '#/components/schemas/unit_layer_object_key_base_string'
                  update_check:
                    type: object
                    additionalProperties: false
                    properties:
                      valid:
                        type: boolean
                      message:
                        $ref: '#/components/schemas/long_text_base_string'
                      reason_code:
                        type: string
                        pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                        maxLength: 64
                        description: "Present only when valid is false. Why the check failed: READ_FORBIDDEN, CASE_NOT_FOUND, PERMISSION_SERVICE_ERROR, WORKSPACE_ACCESS_DENIED, RUNTIME_MISMATCH, NOT_PRIVATE, NOT_OWNER, GIT_IMPORTED_CANNOT_DELETE or IN_USE_BY_PIPELINE. When several reasons apply, only the first one the service checks is reported. New values may be added."
                      case_keys:
                        type: array
                        maxItems: 10000
                        description: "Present only when valid is false and the service knows which cases caused it (absent for PERMISSION_SERVICE_ERROR)."
                        items:
                          $ref: '#/components/schemas/unit_layer_object_key_base_string'
                  read_check:
                    type: object
                    additionalProperties: false
                    properties:
                      valid:
                        type: boolean
                      message:
                        $ref: '#/components/schemas/long_text_base_string'
                      reason_code:
                        type: string
                        pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                        maxLength: 64
                        description: "Present only when valid is false. Why the check failed: READ_FORBIDDEN, CASE_NOT_FOUND, PERMISSION_SERVICE_ERROR, WORKSPACE_ACCESS_DENIED, RUNTIME_MISMATCH, NOT_PRIVATE, NOT_OWNER, GIT_IMPORTED_CANNOT_DELETE or IN_USE_BY_PIPELINE. When several reasons apply, only the first one the service checks is reported. New values may be added."
                      case_keys:
                        type: array
                        maxItems: 10000
                        description: "Present only when valid is false and the service knows which cases caused it (absent for PERMISSION_SERVICE_ERROR)."
                        items:
                          $ref: '#/components/schemas/unit_layer_object_key_base_string'
                  private_case_check:
                    type: object
                    additionalProperties: false
                    properties:
                      valid:
                        type: boolean
                      message:
                        $ref: '#/components/schemas/long_text_base_string'
                      reason_code:
                        type: string
                        pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                        maxLength: 64
                        description: "Present only when valid is false. Why the check failed: READ_FORBIDDEN, CASE_NOT_FOUND, PERMISSION_SERVICE_ERROR, WORKSPACE_ACCESS_DENIED, RUNTIME_MISMATCH, NOT_PRIVATE, NOT_OWNER, GIT_IMPORTED_CANNOT_DELETE or IN_USE_BY_PIPELINE. When several reasons apply, only the first one the service checks is reported. New values may be added."
                      case_keys:
                        type: array
                        maxItems: 10000
                        description: "Present only when valid is false and the service knows which cases caused it (absent for PERMISSION_SERVICE_ERROR)."
                        items:
                          $ref: '#/components/schemas/unit_layer_object_key_base_string'
                  same_runtime_check:
                    type: object
                    additionalProperties: false
                    properties:
                      valid:
                        type: boolean
                      runtime_uuid:
                        $ref: '#/components/schemas/runtime_uuid_base_string'
                      message:
                        $ref: '#/components/schemas/long_text_base_string'
                      reason_code:
                        type: string
                        pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                        maxLength: 64
                        description: "Present only when valid is false. Why the check failed: READ_FORBIDDEN, CASE_NOT_FOUND, PERMISSION_SERVICE_ERROR, WORKSPACE_ACCESS_DENIED, RUNTIME_MISMATCH, NOT_PRIVATE, NOT_OWNER, GIT_IMPORTED_CANNOT_DELETE or IN_USE_BY_PIPELINE. When several reasons apply, only the first one the service checks is reported. New values may be added."
                      case_keys:
                        type: array
                        maxItems: 10000
                        description: "Present only when valid is false and the service knows which cases caused it (absent for PERMISSION_SERVICE_ERROR)."
                        items:
                          $ref: '#/components/schemas/unit_layer_object_key_base_string'
                      groups:
                        type: object
                        additionalProperties:
                          type: array
                          maxItems: 10000
                          items:
                            $ref: '#/components/schemas/unit_layer_object_key_base_string'
                        description: "Only on a failed same_runtime_check (reason_code RUNTIME_MISMATCH). Maps each runtime id to the case keys that use it. Cases without a runtime are grouped under the empty string."
        default:
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
                
                
  /pipeline/myPipelines:
    get:
      deprecated: true
      tags:
        - Pipeline Management
      summary: Retrieve pipelines owned by the current user across the tenant
      description: DEPRECATED REASON -- No use in frontend for now. And it can be replaced by /pipeline/findPipelines/version2
      operationId: findMyPipelines
      parameters:
        - name: uid
          in: query
          description: the uid which inner join with current user data
          required: false
          schema:
            $ref: '#/components/schemas/object_owner_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/PipelineForMyList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/verify:
    post:
      tags:
        - Pipeline Management
      summary: Validate Pipeline definition file compliance
      description: |
        Validate whether the Pipeline definition file (.yaml) complies with Testany platform requirements.

        A failed validation answers with an error body that adds a stable `reason` and, where it helps, `details` to `code` and `message`. `code` is unchanged and coarse; use `reason` to tell failures apart. `reason` values are never renamed once published; new values may be added.

        | code | reason | details |
        |---|---|---|
        | E400001 | `DATA_REQUIRED` (the request has no `data` field) | `field: "data"` |
        | E400001 | `V1_1_WRITE_DENIED` | none |
        | E400002 | `V1_3_WRITE_NOT_ENABLED` | none |
        | E201001 | `YAML_PARSE_ERROR`, `UNKNOWN_KIND`, `NO_RULES` | none |
        | E201001 | `RULE_MISSING_RUN`, `RULE_DUPLICATE_RUN`, `RULE_MULTIPLE_PRECONDITION`, `RULE_PRECONDITION_UNDEFINED`, `RULE_RELAY_INCOMPLETE`, `RULE_RELAY_UNDEFINED`, `RULE_RELAY_DUPLICATE`, `RULE_RELAY_NEEDS_WHEN_PASSED`, `RULE_DEPENDENCY_CYCLE` | `rule_index` (0-based), `case_key` (the rule's `run`), `field` (`run`, `precondition` or `relay`), and `ref_key` for `RULE_RELAY_UNDEFINED` when known |
        | E201002 | `CASE_NOT_FOUND` | `case_key` (the first case that does not exist) |
        | E201003 | `CASE_COUNT_EXCEEDED` | `count`, `limit` |
        | E201005 | `RELAY_UNSAFE_IN_PARALLEL` | `rule_index`, `case_key` |

        Use `rule_index` to locate a rule. For pipeline definitions of version 1.2 and 1.3, the rule number written inside `message` can differ from `rule_index` for `RULE_DUPLICATE_RUN`; the message text is kept as it always was. Validation stops at the first error found.

        A request without `data` used to answer HTTP 503 and now answers HTTP 400 with `DATA_REQUIRED`. An empty or blank `data` string still answers 400 E201001 `UNKNOWN_KIND`.
      operationId: ValidatePipelineGramma
      requestBody:
        description: |
          Check the pipeline data
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                data:
                  $ref: '#/components/schemas/pipeline_yaml_base_string'
        required: true
      responses:
        '204': 
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/dryRun:
    post:
      deprecated: true
      tags:
        - Pipeline Management
      summary: initiate Dry run for a Pipeline
      description: DEPRECATED REASON -- current DryRun is not a REAL dryRun. And the rendering work will be replaced by the new Pipeline Assembler component in frontend.
      operationId: dryRunPipeline
      requestBody:
        description: |
          Dry run the pipeline
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/PipelineForValidate'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineDryRunResult'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/dryRun/{key}:
    get:
      deprecated: true
      tags:
        - Pipeline Management
      summary: Get Dry run Pipeline result
      description: DEPRECATED REASON -- same as /pipeline/dryRun
      operationId: getDryRunPipeline
      parameters:
        - name: key
          in: path
          description: key of pipeline to return
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineDryRunResultDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline:
    post:
      deprecated: true
      tags:
        - Pipeline Management
      summary: Create a test pipeline
      description: DEPRECATED REASON -- will be replaced by POST /pipeline/version2
      operationId: addPipeline
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PipelineForCreate'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineOptResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/version2:
    post:
      tags:
        - Pipeline Management
      summary: Create a test pipeline
      description: Create a test pipeline
      operationId: addPipelineV2
      requestBody:
        description: Create a test pipeline
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PipelineForCreateV2'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineOptResponseV2'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'  
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
                
  /pipeline/{key}:
    get:
      deprecated: true
      tags:
        - Pipeline Management
      summary: Get detailed information about a pipeline
      description: DEPRECATED REASON -- will be replaced by GET /pipeline/{key}/version2
      operationId: getPipelineByKey
      parameters:
        - name: key
          in: path
          description: The key of the pipeline to get information
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      deprecated: true
      tags:
        - Pipeline Management
      summary: Update an existing Pipeline
      description: DEPRECATED REASON -- will be replaced by PATCH /pipeline/{key}/version2
      operationId: updatePipeline
      parameters:
        - name: key
          in: path
          description: The key of the pipeline to update
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      requestBody:
        description: Update an existent Pipeline
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PipelineForCreate'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineOptResponseV2'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - Pipeline Management
      summary: Deletes a Pipeline
      description: Delete a Pipeline by its key --- this endpoint will be kept as is.
      operationId: deletePipeline
      parameters:
        - name: key
          in: path
          description: The key of the Pipeline to delete
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      responses:
        '204': 
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/{key}/version2:
    get:
      tags:
        - Pipeline Management
      summary: Get detailed information about a pipeline
      description: Get detailed information about a pipeline by its key
      operationId: getPipelineByKeyV2
      parameters:
        - name: key
          in: path
          description: The key of the pipeline to get information
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineForDetailV2'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - Pipeline Management
      summary: Update an existing Pipeline
      description: Update an existing Pipeline by its key
      operationId: updatePipelineV2
      parameters:
        - name: key
          in: path
          description: The key of the pipeline to update
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      requestBody:
        description: Update an existent Pipeline
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PipelineForUpdateV2'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'



  /pipeline/{key}/execute:
    post:
      tags:
        - Pipeline Management
      summary: Trigger a pipeline execution by key
      description: Trigger a pipeline execution by its key
      operationId: executePipelineByKey
      parameters:
        - name: key
          in: path
          description: the key of pipeline to execute
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineExecuteResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/pipeline/{key}/executeByPlan:
    post:
      tags:
        - Internal API      
      summary: Execute Pipeline by key, triggered by plan
      description: Returns a Pipeline Execution Key
      operationId: executePipelineByKeyWithPlan
      parameters:
        - name: key
          in: path
          description: key of pipeline to return
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      requestBody:
        description: Plan related information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PipelineExecuteByPlan'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PipelineExecuteResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/pipeline/group/{group_key}:
    get:
      tags:
        - Internal API
      summary: Find Pipelines by group key
      description: Returns a single Pipeline
      operationId: getPipelinesByGroupKey
      parameters:
        - name: group_key
          in: path
          description: key of pipeline group
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_group_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  type:
                    $ref: '#/components/schemas/trigger_method_type_base_string'
                    example: 'gatekeeper'
                  pipelines: 
                    type: array
                    maxItems: 10000
                    items:
                      $ref: '#/components/schemas/PipelineForDetailInList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    put:
      tags:
        - Internal API      
      summary: Update an existing group or create a group pipeline list
      description: Update an existing group pipeline list
      operationId: updateGroupPipelines
      parameters:
        - name: group_key
          in: path
          description: key of pipeline group
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_group_key_base_string'
      requestBody:
        description: Update an existing pipeline group or create a pipeline group, for gatekeeper the type is gatekeeper, for plan the type is plan.
          needs to check if the {goup_key} with pipelines is valid (in the same workspace with gatekeeper and key is valid).
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                type:
                  $ref: '#/components/schemas/trigger_method_type_base_string'
                  example: 'gatekeeper'
                pipelines:
                  $ref: '#/components/schemas/pipelines_key_base_array'
        required: true
      responses:
        '204':
          description: Successful operation
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /internal/trigger/plan/{plan_key}:
    post:
      tags:
        - Internal API
      summary: Execute Pipeline by Plan key, triggered by plan
      description: Returns a Pipeline Execution Key List
      operationId: executePipelineByPlanKey
      parameters:
        - name: plan_key
          in: path
          description: the key of the plan to trigger
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'P-WKS-0001'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  executions:
                    type: array
                    maxItems: 10000
                    items:
                      additionalProperties: false
                      type: object
                      properties:
                        exectuion:
                          $ref: '#/components/schemas/pipeline_execution_key_base_string'
                        pipeline:
                          $ref: '#/components/schemas/pipeline_key_base_string'
                        error:
                          $ref: '#/components/schemas/CustomizedErrorResponse'
                  watchers:
                    $ref: '#/components/schemas/object_watcher_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/filterListPipelines:
    get:
      deprecated: true
      tags:
        - Pipeline Management
      summary: List Pipelines with limited fields
      description: DEPRECATED REASON -- No use in frontend for now.
      operationId: filterListPipelines
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/PipelineFilter'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'


  /pipeline/filterListOwnerUids:
    get:
      tags:
        - Pipeline Management
      summary: List Pipeline owners with user uids
      description: For Pre query, list a lite Pipeline owner uids to find out a specific Pipeline owner uid
      operationId: filterListActivePipelineOwnerUids
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/object_owner_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/filterListEnvs:
    get:
      tags:
        - Pipeline Management
      summary: List Pipeline with specific environments
      description: For Pre query, list a lite Pipeline with specific environments to find out specific Pipelines
      operationId: filterListActivePipelineEnvironments
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/object_environments_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'


  /pipeline/filterListUsedCases:
    get:
      tags:
        - Pipeline Management
      summary: List Pipeline with specific used cases
      description: For Pre query, list a lite Pipeline with specific used cases to find out specific Pipelines
      operationId: filterListActivePipelineUsedCases
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/unit_layer_object_key_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse' 
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/findPipelinesV2:
    get:
      deprecated: true
      tags:
        - Pipeline Management
      summary: List Pipelines
      description: DEPRECATED REASON -- replaced by GET /pipeline/findPipelines/version2
      operationId: findPipelinesV2
      parameters:
        - name: next_page_token
          in: query
          description: if no value then return first 50 records
          required: false
          schema:
            $ref: '#/components/schemas/page_next_page_token_base_string'
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
        - name: page
          in: query
          description: page index, start from 1, defaut value is 1
          required: false
          schema:
            $ref: '#/components/schemas/page_page_number_base_integer'
        - name: page_size
          in: query
          description: page size, records in one page defaut value is 50
          required: false
          schema:
            $ref: '#/components/schemas/page_page_size_base_integer'
        - name: owner
          in: query
          description: Multiple owners can be specified by using repeated query parameters (e.g., owner=xxx&owner=yyy&owner=zzz)
          required: false
          schema:
            $ref: '#/components/schemas/object_owner_base_string'
          style: form
          explode: true
        - name: keyword
          in: query
          description: using pipeline key or pipeline name as the query parameter, it is a 'like' match
          required: false
          schema:
            $ref: '#/components/schemas/long_text_base_string'
        - name: environments
          in: query
          description: Multiple environments can be specified by using repeated query parameters (e.g., env=xxx&env=yyy&env=zzz)
          required: false
          schema:
            $ref: '#/components/schemas/object_environments_base_array'
          style: form
          explode: true
      responses:
        '200':
          description: successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/PipelineForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/findPipelines/version2:
    post:
      tags:
        - Pipeline Management
      summary: List Pipelines
      description: List pipelines
      operationId: findPipelinesVersion2
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                next_page_token:
                  $ref: '#/components/schemas/page_next_page_token_base_string'
                page:
                  $ref: '#/components/schemas/page_page_number_base_integer'
                page_size:
                  $ref: '#/components/schemas/page_page_size_base_integer'
                workspace:
                  $ref: '#/components/schemas/workspace_key_base_string'
                owned_by:
                    $ref: '#/components/schemas/object_owner_base_array'
                keyword:
                  $ref: '#/components/schemas/long_text_base_string'
                environments:
                    $ref: '#/components/schemas/object_environments_base_array'
                pipeline_labels:
                    $ref: '#/components/schemas/object_labels_base_array'
                case_keys:
                  type: array
                  maxItems: 128
                  items:
                    $ref: '#/components/schemas/unit_layer_object_key_base_string'
                created_at_from:
                  $ref: '#/components/schemas/date_time_base_string'
                created_at_to:
                  $ref: '#/components/schemas/date_time_base_string'
                updated_at_from:
                  $ref: '#/components/schemas/date_time_base_string'
                updated_at_to:
                  $ref: '#/components/schemas/date_time_base_string'
              required:
                - workspace
      responses:
        '200':
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string'
            x-Total-Items:
              description: |
                total items in the result set
              schema:
                type: integer
                format: int32
                example: 1000
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/PipelineForListV3'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /pipeline/{key}/usedByV2:
    get:
      tags:
        - Pipeline Management
      summary: Get pipeline used by information
      description: List pipeline used by information
      operationId: findPipelineUsedbyV2
      parameters:
        - name: key
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  additionalProperties: false
                  type: object
                  properties:
                    key: 
                      $ref: '#/components/schemas/trigger_method_object_key_base_string'
                    type:
                      allOf:
                        - $ref: '#/components/schemas/trigger_method_type_base_string'
                      example: 'Manual'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /pipeline/{key}/assign:
    put:
      deprecated: true
      tags:
        - Pipeline Management
      summary: Change pipeline owner by key
      description: Assign owner to a specific pipeline
      operationId: assignOwnerWithUidForPipeline
      parameters:
        - name: key
          in: path
          description: key of pipeline to return
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
      requestBody:
        description: Assign pipeline owner
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/object_owner_base_array'
            examples:
              test:
                summary: Demo example
                value: ["xxx@testany.io"]
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  

  /execution/findExecutionsV2:
    get:
      tags:
        - Execution Management
      summary: List Executions by filters
      description: List Executions by PipelineKey, ExecutionStatus, ExecutonTime, ExecutionEnvs,  PipelineCreator and PlanCreator
      operationId: findExecutionsV2
      parameters:
        - name: next_page_token
          in: query
          description: A base64 string, if no value then return first 50 records.
          required: false
          schema:
            $ref: '#/components/schemas/page_next_page_token_base_string'
        - name: page
          in: query
          description: The page number of the result set. Default is 1.
          required: false
          schema:
            $ref: '#/components/schemas/page_page_number_base_integer'
        - name: page_size
          in: query
          description: The number of records per page. Default is 50.
          required: false
          schema:
            $ref: '#/components/schemas/page_page_size_base_integer'
        - name: workspace
          in: query
          description: the key of the workspace which the executions belong to.
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
        - name: pipeline_key
          in: query
          description: key of pipeline to return
          required: false
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
        - name: status
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/execution_status_code_base_integer'
          style: form
          explode: true
          description: |
            Status:
             * `-1` - Not started
             * `0` - Running
             * `1` - Passed
             * `2` - Failed
             * `5` - Cancelled
             * `99` - Error
             * Support multiple status, like status=1&status=2
        - name: exe_start_time_from
          in: query
          description: |
            execution happened after this time include the start_time value
            2023-08-15 00:00:00 UTC time, if timezone is Asia/Shanghai, it should be 2023-08-14 16:00:00
          required: false
          schema:
            $ref: '#/components/schemas/date_time_base_string'
        - name: exe_start_time_to
          in: query
          description: |
            execution happened before this time exclude the finish_time
            2023-08-15 16:00:00 UTC time, if timezone is Asia/Shanghai, it should be 2023-08-15 16:00:00
          required: false
          schema:
            $ref: '#/components/schemas/date_time_base_string' 
        - name: env
          in: query
          description: |
            env strings, support multiple values like env=PROD&env=STAGING
          required: false
          schema:
            $ref: '#/components/schemas/object_environment_base_string'
          style: form
          explode: true
        - name: triggered_by
          in: query
          description: |
            group keys, support multiple groups, like triggered_by=P-WKS-0001&triggered_by=G-WKS-0002&triggered_by=MANUAL
            support P-XXX-XXXX, G-XXX-XXXX and MANUAL
          required: false
          schema:
            $ref: '#/components/schemas/trigger_method_object_key_base_string'
          style: form
          explode: true
      responses:
        '200':
          description: successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/ExecutionForListV2'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /execution/filterListStatus:
    get:
      tags:
        - Execution Management
      summary: List Executions by filters
      description: List Executions by PipelineKey, ExecutionStatus, ExecutonTime, ExecutionEnvs,  PipelineCreator and PlanCreator
      operationId: filterListExecutionStatus
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: |
            execution may have following Status:
             * `-1` - Not started
             * `0` - Running
             * `1` - Passed
             * `2` - Failed
             * `5` - Cancelled
             * `99` - Error
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  type: object
                  additionalProperties: false
                  properties:
                    status_code:
                      $ref: '#/components/schemas/execution_status_code_base_integer'
                    status_message:
                      $ref: '#/components/schemas/execution_status_message_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /execution/filterListPipelines:
    get:
      tags:
        - Execution Management
      summary: List Executions by filters
      description: List Executions by PipelineKey, ExecutionStatus, ExecutonTime, ExecutionEnvs,  PipelineCreator and PlanCreator
      operationId: filterListExecutionPipeline
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
        - name: status
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/execution_status_code_base_integer'          
          description: |
            Status:
             * `-1` - Not started
             * `0` - Running
             * `1` - Passed
             * `2` - Failed
             * `5` - Cancelled
             * `99` - Error
             * Support multiple status, like status=1&status=2
        - name: exe_start_time_from
          in: query
          description: |
            execution happened after this time include the start_time value
            2023-08-15 00:00:00 UTC time, if timezone is Asia/Shanghai, it should be 2023-08-14 16:00:00
          required: false
          schema:
            $ref: '#/components/schemas/date_time_base_string'
        - name: exe_start_time_to
          in: query
          description: |
            execution happened before this time exclude the finish_time
            2023-08-15 16:00:00 UTC time, if timezone is Asia/Shanghai, it should be 2023-08-15 16:00:00
          required: false
          schema:
            $ref: '#/components/schemas/date_time_base_string'
        - name: env
          in: query
          description: |
            env strings, support multiple values like env=PROD&env=STAGING
          required: false
          schema:
            $ref: '#/components/schemas/object_environment_base_string'
          style: form
          explode: true
        - name: triggered_by
          in: query
          description: |
            group keys, support multiple groups, like triggered_by=P-WKS-0001&triggered_by=G-WKS-0002&triggered_by=MANUAL
            support P-XXX-XXXX, G-XXX-XXXX and MANUAL
          required: false
          schema:
            $ref: '#/components/schemas/trigger_method_object_key_base_string'
          style: form
          explode: true
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  type: object
                  additionalProperties: false
                  properties:
                    key:
                      $ref: '#/components/schemas/pipeline_key_base_string'
                    name:
                      allOf:
                        - $ref: '#/components/schemas/object_name_base_string'
                      example: 'This is my third pipeline.'           
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /execution/filterListTriggeredBy:
    get:
      tags:
        - Execution Management
      summary: List Executions by filters
      description: List Executions by PipelineKey, ExecutionStatus, ExecutonTime, ExecutionEnvs,  PipelineCreator and PlanCreator
      operationId: filterListExecutionTriggers
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
        - name: pipeline_key
          in: query
          description: |
            key of pipeline to return
            support multiple pipeline_key, like pipeline_key=WKS-0001&pipeline_key=WKS-0002
          required: false
          schema:
            $ref: '#/components/schemas/pipeline_key_base_string'
        - name: status
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/execution_status_code_base_integer'
          style: form
          explode: true
          description: |
            Status:
             * `-1` - Not started
             * `0` - Running
             * `1` - Passed
             * `2` - Failed
             * `5` - Cancelled
             * `99` - Error
             * Support multiple status, like status=1&status=2
        - name: exe_start_time_from
          in: query
          description: |
            execution happened after this time include the start_time value
            2023-08-15 00:00:00 UTC time, if timezone is Asia/Shanghai, it should be 2023-08-14 16:00:00
          required: false
          schema:
            $ref: '#/components/schemas/date_time_base_string'
        - name: exe_start_time_to
          in: query
          description: |
            execution happened before this time exclude the finish_time
            2023-08-15 16:00:00 UTC time, if timezone is Asia/Shanghai, it should be 2023-08-15 16:00:00
          required: false
          schema:
            $ref: '#/components/schemas/date_time_base_string'
        - name: env
          in: query
          description: |
            env strings, support multiple values like env=PROD&env=STAGING
          required: false
          schema:
            $ref: '#/components/schemas/object_environment_base_string'
          style: form
          explode: true
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  plan:
                    type: array
                    maxItems: 10000
                    items:
                      type: string
                      example: 'P-WKS-0001'
                  gatekeeper:
                    type: array
                    maxItems: 10000
                    items:
                      type: string
                      example: 'G-WKS-0001'
                  manual:
                    type: array
                    maxItems: 10000
                    items:
                      type: string
                      example: 'MANUAL'         
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /execution/filterListEnvs:
    get:
      tags:
        - Execution Management
      summary: List Executions by filters
      description: List Executions by PipelineKey, ExecutionStatus, ExecutonTime, ExecutionEnvs,  PipelineCreator and PlanCreator
      operationId: filterListExecutionEnvs
      parameters:
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'

      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/object_environments_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /execution/{execution_key}/refresh:
    get:
      tags:
        - Execution Management
      summary: Refresh Execution Status
      description: List Executions by PipelineKey, ExecutionStatus, ExecutonTime, ExecutionEnvs,  PipelineCreator and PlanCreator
      operationId: refreshExecutionStatus
      parameters:
        - name: execution_key
          in: path
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecutionForRefresh'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /execution/{execution_key}:
    get:
      tags:
        - Execution Management
      summary: Get Execution Detail
      description: Get Execution Detail information
      operationId: getExecutionDetail
      parameters:
        - name: execution_key
          in: path
          description: key of execution to return
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_execution_key_base_string'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExecutionDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - Execution Management
      summary: Cancel one specific Execution
      description: Cancel one specific Execution
      operationId: cancelExecution
      parameters:
        - name: execution_key
          in: path
          description: key of execution to return
          required: true
          schema:
            type: string
            example: 'NNN-0002-000A7'
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /execution/{execution_key}/case/{index}:
    get:
      tags:
        - Execution Management
      summary: Get Execution Detail
      description: Get Execution Detail information
      operationId: getCaseExecutionDetail
      parameters:
        - name: execution_key
          in: path
          description: key of execution
          required: true
          schema:
            $ref: '#/components/schemas/pipeline_execution_key_base_string'
        - name: index
          in: path
          description: index of case
          required: true
          schema:
            $ref: '#/components/schemas/index_base_integer'
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  result:
                    $ref: '#/components/schemas/CaseResult'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'





  /workspace/findWorkspacesByKeys:
    post:
      tags:
        - Workspace Management
      summary: Bulk retrieve base information of workspaces by keys
      description: Bulk retrieve a group of workspace's basic information based on the workspace key, including its `name`, `description`, and `status`
      operationId: findWorkspacesByKeys
      requestBody:
        description: Provide the workspace keys to be queried in the form of an array.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/workspace_key_base_array'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/WorkspaceForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

        

        
  /workspace/{key}/executionStatus:
    get:
      tags:
        - Workspace Management
      summary: check workspace execution status
      description: show the specific workspace exeuction status
      operationId: workspaceExecutionStatus
      parameters:
        - name: key
          in: path
          description: The key of the Workspace
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
          required: true
      responses:
        '200':
          description: Successful get result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorksapceExecutionStatus'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /workspace/check:
    get:
      tags:
        - Workspace Management
      summary: Check a Workspace is unique or not
      description: Check a Workspace is unique or not
      operationId: checkWorkspace
      parameters:
        - name: key
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  result:
                    type: integer
                    example: 1
                    description: |
                      1 -> unique
                      2 -> duplicate
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /workspace:
    post:
      tags:
        - Workspace Management
      summary: Add a new Workspace
      description: Add a new Workspace to the tenant, this operation is only available for the global admin.
      operationId: addWorkspace
      requestBody:
        description: Create a new Workspace
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkspaceBaseInfo'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceBaseInfo'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /workspace/request:
    post:
      tags:
        - Workspace Management
      summary: Request a new Workspace
      description: >
        Send a request to global admin to create a new Workspace. The global admin will review the request and approve or reject it.
      operationId: requestWorkspace
      requestBody:
        description: Request a new Workspace
        content:
          application/json:
            schema:
              type: object
              allOf: 
                - $ref: '#/components/schemas/WorkspaceBaseInfo'
                - type: object
                  properties:
                    referral_id:
                      $ref: '#/components/schemas/referral_id_base_string'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /workspace/{key}/approve:
    patch:
      tags:
        - Workspace Management
      summary: Approve a Workspace request
      description: Approve a Workspace request, this operation is only available for the global admin.
      operationId: approveWorkspace
      parameters:
        - name: key
          in: path
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /workspace/{key}/reject:
    patch:
      tags:
        - Workspace Management
      summary: Reject a Workspace request
      description: Reject a Workspace request, this operation is only available for the global admin.
      operationId: rejectWorkspace
      parameters:
        - name: key
          in: path
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /workspace/{key}:
    get:
      tags:
        - Workspace Management
      summary: Retrieve detailed information about a specific workspace
      description: Retrieve detailed information about a specific workspace
      operationId: getWorkspace 
      parameters:
        - name: key
          in: path
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - Workspace Management
      summary: Update a Workspace
      description: Update a Workspace
      operationId: updateWorkspace
      parameters:
        - name: key
          in: path
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      requestBody:
        description: Update a Workspace
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkspaceForUpdate'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceBaseInfo'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /workspace/findWorkspaces:
    get:
      tags:
        - Workspace Management
      summary: List workspaces
      description: List workspaces
      operationId: listWorkspace
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/WorkspaceForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /plan/myPlans:
    get:
      tags:
        - Plan Management
      summary: List current user owned plans, multiple workspaces
      description: List current user owned plans
      operationId: listMyPlans
      parameters:
        - name: uid
          in: query
          description: the uid which inner join with current user data
          required: false
          schema:
            $ref: '#/components/schemas/object_owner_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/PlanForMyList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /plan:
    post:
      tags:
        - Plan Management
      summary: Add a new Plan
      description: Add a new Plan
      operationId: addPlan
      requestBody:
        description: Create a new Plan
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanForOptCreate'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /plan/{key}:
    get:
      tags:
        - Plan Management
      summary: Get a Plan Detail
      description: Get a Plan Detail
      operationId: getPlan
      parameters:
        - name: key
          in: path
          description: The key of the Plan
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'P-ABC-01D31'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanForDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - Plan Management
      summary: Update a Plan
      description: Update a Plan
      operationId: updatePlan
      parameters:
        - name: key
          in: path
          description: key of workspace to return
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'P-ABC-01D31'
      requestBody:
        description: Update a Plan
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanForOpt'
        required: true
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - Plan Management
      summary: Deletes a Plan
      description: delete a Plan
      operationId: deletePlan
      parameters:
        - name: key
          in: path
          description: Plan key to delete
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'P-ABC-01D31'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  
  /plan/findPlans:
    get:
      tags:
        - Plan Management
      summary: Get a Plan List
      description: Get a Plan List
      operationId: listPlan
      parameters:
        - name: next_page_token
          in: query
          description: if no value then return first 50 records
          required: false
          schema:
            $ref: '#/components/schemas/page_next_page_token_base_string'
        - name: page
          in: query
          description: page index, start from 1, defaut value is 1
          required: false
          schema:
            $ref: '#/components/schemas/page_page_number_base_integer'
        - name: page_size
          in: query
          description: page size, records in one page defaut value is 50
          required: false
          schema:
            $ref: '#/components/schemas/page_page_size_base_integer'
        - name: workspace
          in: query
          description: key of workspace to return
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: Successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/PlanForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /plan/{key}/assign:
    put:
      tags:
        - Plan Management
      summary: Change plan owner by key
      description: Assign owner to a specific plan
      operationId: assignOwnerWithUidForPlan
      parameters:
        - name: key
          in: path
          description: key of plan to return
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'P-ABC-01D31'
      requestBody:
        description: Assign plan owner(s)
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/object_owner_base_array'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'



  /gatekeeper/webhook/{hook_token}:
    post:
      tags:
        - Gatekeeper Management
      summary: trigger gatekeeper by webhook
      description: trigger gatekeeper by webhook
      operationId: gatekeeperTriggerByHook
      parameters:
        - name: hook_token
          in: path
          description: string
          schema:
            type: string
            pattern: ^[A-Za-z0-9_%-]{4,}$
            maxLength: 100
            example: 'Ry1UU1XXXXXXXXM3%2B%2B3KXXXXXXXXuxQfDKg%3D'
            description: 'urlEncoded base64 string'
          required: true
      requestBody:
        description: the customized payload in gatekeeper webhook 
        content:
          "*/*":
            schema:
              type: object
              additionalProperties: false  # 防止传入未定义的字段
              properties:
                example1:
                  type: string  # 明确指定每个字段的类型
                  example: "xxxx"
                example2:
                  type: string
                  example: "yyy"
              description: any object you want to set in the request body
        required: false
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /gatekeeper:
    post:
      tags:
        - Gatekeeper Management
      summary: Add a new Gatekeeper
      description: |
        Add a new Gatekeeper.

        Failures add a stable `reason` (and, where noted, `details`) to `code` and `message`:

        | HTTP | code | reason | details |
        |---|---|---|---|
        | 400 | E701400 | `GATEKEEPER_NAME_INVALID`, `GATEKEEPER_DESCRIPTION_TOO_LONG` | `field` (`name` or `description`) |
        | 400 | E201002 | `PIPELINE_NOT_FOUND`, `PIPELINE_NOT_IN_WORKSPACE` | `pipeline_key` |
        | 409 | E409001 | `WORKSPACE_GENERATION_NOT_CURRENT` | none |

        A 409 here means the workspace is not in its current generation (for example while it is being purged and re-created). It does not mean the name is taken: Gatekeeper names are not required to be unique.
      operationId: addGatekeeper
      requestBody:
        description: Create a new Gatekeeper
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GatekeeperForOptCreate'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatekeeperCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /gatekeeper/{key}:
    get:
      tags:
        - Gatekeeper Management
      summary: Get a Gatekeeper Detail
      description: Get a Gatekeeper Detail
      operationId: getGatekeeper
      parameters:
        - name: key
          in: path
          description: The key of the Gatekeeper
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'G-ABC-01D31'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatekeeperForDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - Gatekeeper Management
      summary: Update a Gatekeeper
      description: Update a Gatekeeper, patch according the field value, if the payload only has name and description, then only patch name and description
      operationId: updateGatekeeper
      parameters:
        - name: key
          in: path
          description: The key of the Gatekeeper
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'G-ABC-01D31'
      requestBody:
        description: Update a Gatekeeper
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GatekeeperForOpt'
        required: true
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - Gatekeeper Management
      summary: Deletes a Gatekeeper
      description: delete a Gatekeeper
      operationId: deleteGatekeeper
      parameters:
        - name: key
          in: path
          description: Gatekeeper key to delete
          required: true
          schema:
            allOf:
              - $ref: '#/components/schemas/trigger_method_object_key_base_string'
            example: 'G-ABC-01D31'
      responses:
        '204': 
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    
  
  /gatekeeper/findGatekeepers:
    get:
      tags:
        - Gatekeeper Management
      summary: Get a Gatekeeper List
      description: Get a Gatekeeper List
      operationId: listGatekeeper
      parameters:
        - name: next_page_token
          in: query
          description: if no value then return first 50 records
          required: false
          schema:
            $ref: '#/components/schemas/page_next_page_token_base_string'
        - name: page
          in: query
          description: page index, start from 1, defaut value is 1
          required: false
          schema:
            $ref: '#/components/schemas/page_page_number_base_integer'
        - name: page_size
          in: query
          description: page size, records in one page defaut value is 50
          required: false
          schema:
            $ref: '#/components/schemas/page_page_size_base_integer'
        - name: workspace
          in: query
          description: THe key of the workspace which the gatekeepers belong to
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: Successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string' 
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/GatekeeperForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  
  /user/filterListWatchers:
    get:
      deprecated: true
      tags:
        - User Management
      summary: List users
      description: |
        List Users, List workspace key in user.workspace_member_list user data with logged is true, and suspended is false, and disabled is false
      operationId: listUsers
      parameters:
        - name: workspace
          in: query
          description: workspace key
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'       
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForFilter'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/filterListWatchersV2:
    get:
      tags:
        - User Management
      summary: List users
      description: |
        List Users, List workspace key in user.workspace_member_list user data with logged is true, and suspended is false, and disabled is false
      operationId: listUsersV2
      parameters:
        - name: workspace
          in: query
          description: workspace key
          required: false
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'      
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForFilter'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/findUsers:
    get:
      tags:
        - User Management
      summary: List all users
      description: |
        List Users, any active user could use this API to query all the user data with suspended is false, and disabled is false
      operationId: listAllUsersByActiveUser
      parameters:
        - name: next_page_token
          in: query
          description: if no value then return first 50 records
          required: false
          schema:
            $ref: '#/components/schemas/page_next_page_token_base_string'
        - name: page_size
          in: query
          description: page size, records in one page defaut value is 50
          required: false
          schema:
            $ref: '#/components/schemas/page_page_size_base_integer'
        - name: uid
          in: query
          description: query user with id, UI already filter all the user data, then return one user id, this is the user uid
          required: false
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
        - name: keyword
          in: query
          description: query user with a name or email, not exact match (use 'like %name%' or 'like %email%')
          required: false
          schema:
            $ref: '#/components/schemas/mid_text_base_string'
      responses:
        '200':
          description: Successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /user/findAllUsers:
    get:
      tags:
        - User Management
      summary: List all users
      description: |
        List Users, global admin use this API to query all the user data.
      operationId: listAllUsersByGlobalAdmin
      parameters:
        - name: next_page_token
          in: query
          description: if no value then return first 50 records
          required: false
          schema:
            $ref: '#/components/schemas/page_next_page_token_base_string'
        - name: page_size
          in: query
          description: page size, records in one page defaut value is 50
          required: false
          schema:
            $ref: '#/components/schemas/page_page_size_base_integer'
        - name: uid
          in: query
          description: query user with id, UI already filter all the user data, then return one user id, this is the user uid
          required: false
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
        - name: keyword
          in: query
          description: query user with a name or email, not exact match (use 'like %name%' or 'like %email%')
          required: false
          schema:
            $ref: '#/components/schemas/mid_text_base_string'
      responses:
        '200':
          description: Successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                $ref: '#/components/schemas/page_next_page_token_base_string'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /user/filterListAllUsers:
    get:
      tags:
        - User Management
      summary: List all users
      description: |
        List Users, global admin use this API to query all the user data.
      operationId: filterListAllUsersByGlobalAdmin
      parameters:
        - name: uid
          in: query
          description: query user with id, UI already filter all the user data, then return one user id, this is the user uid
          required: false
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
        - name: keyword
          in: query
          description: query user with a name or email, not exact match (use 'like %name%' or 'like %email%')
          required: false
          schema:
            $ref: '#/components/schemas/mid_text_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForFilter'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /user/findUserByIds:
    post:
      tags:
        - User Management
      summary: List all related users
      description: |
        List Users, user data with logged is true, and disabled is false
      operationId: listKeysUsers
      requestBody:
        description: List user basic information by user uid
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/user_uid_base_array'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForIdQuery'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

 
      
  /user/workspace/myWorkspaces:
    get:
      tags:
        - User Management
      summary: List workspaces which current user belong to workspace member or workspace admin
      description: |
        List workspace keys of current user, the workspace member list keys.
      operationId: listUserRelatedWorkspaces
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/workspace_key_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/workspace/myWorkspacesWithAdmin:
    get:
      tags:
        - User Management
      summary: List workspaces which current user belong to workspace member or workspace admin
      description: |
        List workspace keys of current user, the workspace member or workspace admin list keys.
      operationId: listUserRelatedWorkspacesAndAdminList
      parameters:
      - name: uid
        in: query
        description: the uid which inner join with current user data
        required: false
        schema:
          $ref: '#/components/schemas/user_uid_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  additionalProperties: false
                  type: object
                  properties:
                    key: 
                      $ref: '#/components/schemas/workspace_key_base_string'
                    workspace_admins:
                      type: array
                      maxItems: 10000
                      items:
                        $ref: '#/components/schemas/UserForFilter'                       
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/workspace/myWorkspacesWithRoles:
    get:
      tags:
        - User Management
      summary: List workspaces which current user belong to workspace member or workspace admin
      description: |
        List workspace keys of current user, the workspace member or workspace admin list keys, and with workspace role information for the current user.
      operationId: listWorkspaceMemberOrWorkspaceAdmin
      parameters:
      - name: uid
        in: query
        description: the uid which inner join with current user data
        required: false
        schema:
          $ref: '#/components/schemas/user_uid_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  additionalProperties: false
                  type: object
                  properties:
                    key: 
                      $ref: '#/components/schemas/workspace_key_base_string'
                    workspace_member:
                      type: boolean
                      example: false
                    workspace_admin:
                      type: boolean
                      example: true     
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/workspace/{workspace}/findUsers:
    get:
      tags:
        - User Management
      summary: List workspace related users
      description: |
        List Users, List workspace key in user.workspace_member_list or user.workspace_admin list.
          user data with logged is true, and suspended is false, and disabled is false
      operationId: listWorkspaceRelatedUsers
      parameters:
        - name: workspace
          in: path
          description: query user with workspace key, list all the users which workspace member or workspace admin is belong to this user.
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
        - name: next_page_token
          in: query
          description: if no value then return first 50 records
          required: false
          schema:
            $ref: '#/components/schemas/page_next_page_token_base_string'
        - name: page_size
          in: query
          description: page size, records in one page defaut value is 50
          required: false
          schema:
            $ref: '#/components/schemas/page_page_size_base_integer'
        - name: uid
          in: query
          description: query user with id, UI already filter all the user data, then return one user id
          required: false
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
        - name: keyword
          in: query
          description: query user with a name or an email address, use not exact match ( 'like %name%' or like '%email%')
          required: false
          schema:
            $ref: '#/components/schemas/mid_text_base_string'
        - name: workspace_roles
          in: query
          description: query user with types
          required: false
          schema:
            type: string
            example: member,admin
            description: |
              two roles with `,` join, that means workspace member or workspace admin 
      responses:
        '200':
          description: Successful operation
          headers:
            X-Next-Page-Token:
              description: |
                return the current cursor,please set the value to http request header for next query
              schema:
                type: string
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForWorkspaceUserList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/workspace/{workspace}/assign:
    patch:
      tags:
        - User Management
      summary: Assign multiple users as specific workspace role
      description: |
         Assign multiple users as specific workspace role
      operationId: assignMultipleWorkspaceRelatedUsers
      parameters:
        - name: workspace
          in: path
          description: |
            bulk update users as workspace admin or workspace member
            only support bulk assign as member or admin, not support bulk revoke admin and bulk revoke member
            if the workspace_admin=false, it will ignore the request
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      requestBody:
        description: Assign role to multiple existing User
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                uids:
                  $ref: '#/components/schemas/user_uid_base_array'
                workspace_admin: 
                  type: boolean
                  example: false
                workspace_member:
                  type: boolean
                  example: false
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForWorkspaceUserList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/memberCount:
    get:
      tags:
        - User Management
      summary: List member count
      description: |
        count all the users. if provide the workspace, then return the user count which belong to the specific workspace as the workspace_member or workspace_admin
      operationId: listmemberCount
      parameters:
        - name: workspace
          in: query
          description: If not provide this parameter, then return all the member count. workspace key which asigned to user as workspace_member_list or workspace_admin_list
          required: false
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  member_count:
                    type: integer
                    example: 10     
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/{uid}:
    get:
      tags:
        - User Management
      summary: Get users detail
      description: Get User Detail
      operationId: getUserDetail
      parameters:
        - name: uid
          in: path
          description: key of user, get from AccessToken
          required: true
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/UserForDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - User Management
      summary: Update an existing User
      description: Update an existing User
      operationId: updateUser
      parameters:
        - name: uid
          in: path
          description: uid of user, get from AccessToken
          required: true
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
      requestBody:
        description: Update an existing User. Currently, `timezone` is not allowed to be updated.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserForUpdate'
        required: true
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /user/{uid}/attributes:
    patch:
      tags:
        - User Management
      summary: Update an existing User for attributes
      description: Update an existing User for attributes
      operationId: updateUserAttributes
      parameters:
        - name: uid
          in: path
          description: uid of user, get from AccessToken
          required: true
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
      requestBody:
        description: Update an existing User
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserForUpdateAttributes'
        required: true
      responses:
        '204':
          description: Successful operation
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /user/{uid}/workspace/{workspace}/assign:
    patch:
      tags:
        - User Management
      summary: Update an existing User for attributes
      description: Assign the {uid} user for workspace {workspace} to the workspace admin or workspace member
      operationId: updateUserOwnedWorkspacePermission
      parameters:
        - name: uid
          in: path
          description: key of user, get from AccessToken
          required: true
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
        - name: workspace
          in: path
          description: key of the workspace which the user will be assigned role(s) to.
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      requestBody:
        description: Update an existing User
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                workspace_admin: 
                  type: boolean
                  example: false
                workspace_member: 
                  type: boolean
                  example: false
        required: true
      responses:
        '204':
          description: Successful operation
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - User Management
      summary: delete an existing User for role
      description: delete all the workspace related roles from one specific user for one specific workspace
      operationId: removeUserOwnedWorkspacePermission
      parameters:
        - name: uid
          in: path
          description: key of user, get from AccessToken
          required: true
          schema:
            $ref: '#/components/schemas/user_uid_base_string'
        - name: workspace
          in: path
          description: key of the workspace which the user will be unassigned role(s) to.
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/workspace/{workspace}/admin:
    put:
      tags:
        - User Management
      summary: Update an existing User for attributes
      description: Assign the {id} user for workspace {workspace} to the workspace admin
      operationId: updateUserOwnedWorkspace
      parameters:
        - name: workspace
          in: path
          description: key of user, get from AccessToken
          required: true
          schema:
            $ref: '#/components/schemas/workspace_key_base_string'
      requestBody:
        description: Update an existing User
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserForAssignWorkspace'
        required: true
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user:
    put:
      tags:
        - User Management
      summary: Add or update an User
      description: Add a new User
      operationId: addUser
      requestBody:
        description: Create a new User
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserForCreate'
        required: true
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/invite:
    put:
      tags:
        - User Management
      summary: Invite some users
      description: Invite multiple Users
      operationId: inviteUser
      requestBody:
        description: Invite a new User
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserForInvite'
        required: true
      responses:
        '204':
          description: No Content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /user/avatar:
    put:
      tags:
        - User Management
      summary: Upload a user icon in the user profile page
      description: Upload a user avatar
      operationId: uploadUserAvatar
      requestBody:
        description: Upload a new avatar for user
        required: true
        content:
          image/png:
            schema:
              $ref: '#/components/schemas/user_avatar_base_string'
          image/jpeg:
            schema:
              $ref: '#/components/schemas/user_avatar_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                properties:
                  url:
                    $ref: '#/components/schemas/url_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'



  /metering/assets:
    get:
      tags:
        - Metering Query
      summary: List assets count of an entire tenant
      description: List assets count of an entire tenant, this endpoint is for global admin use only
      operationId: listAssetsCount
      parameters:
        - name: tenant_uuid
          in: query
          description: tenant uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
      responses:
        '200':
          description: Successful operation. please note `workspace_key` will always be empty because the returned data covers the entire tenant.
          content:
            application/json:
              schema:
                additionalProperties: false
                type: object
                $ref: '#/components/schemas/AssetsMeteringResponse'
              example:
                workspace_key: ""
                workspace_count: 9
                member_count: 205
                case_count: 1887
                pipeline_count: 893
                plan_count: 340
                gatekeeper_count: 559
                tee_limit_count: 17
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /metering/workspace/assets:
    get:
      tags:
        - Metering Query
      summary: List assets count of specific workspace(s) within a tenant
      description: List assets count of specific workspace(s) within a tenant
      operationId: listWorkspaceAssetsCount
      parameters:
        - name: tenant_uuid
          in: query
          description: tenant uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
        - name: workspace_key
          in: query
          description: workspace key. Multiple entries can be provided, and the returned value will be the respective asset counts of each specified workspaces.
          schema:
            $ref: '#/components/schemas/workspace_key_base_array'
          required: true
      responses:
        '200':
          description: Successful operation. Please note `case_count` will be displayed as 0 because cases are considered tenant assets and do not belong to any workspace.
          content:
            application/json:
              schema:
                additionalProperties: false
                type: array
                maxItems: 1000
                items:
                  type: object
                  $ref: '#/components/schemas/AssetsMeteringResponse'
              example:
                - workspace_key: Y2K
                  workspace_count: 1
                  member_count: 10
                  case_count: 0
                  pipeline_count: 100
                  plan_count: 50
                  gatekeeper_count: 30
                  tee_limit_count: 3
                - workspace_key: ABC
                  workspace_count: 1
                  member_count: 8
                  case_count: 0
                  pipeline_count: 74
                  plan_count: 0
                  gatekeeper_count: 50
                  tee_limit_count: 1

        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /metering/usage:
    get:
      tags:
        - Metering Query
      summary: List tenant wide usage count
      description: List tenant wide usage count for a specific time period, this endpoint is for Global Admin use only.
      operationId: listUsageCount
      parameters:
        - name: tenant_uuid
          in: query
          description: tenant uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
        - name: begin_date_time
          in: query
          description: begin date time for usage query, leave both begin & end blank to return month-to-date usage data.
          schema:
            $ref: '#/components/schemas/date_time_base_string'
        - name: end_date_time
          in: query
          description: end date time for usage query, leave both begin & end blank to return month-to-date usage data.
          schema:
            $ref: '#/components/schemas/date_time_base_string'
      responses:
        '200':
          description: Successful operation. Please note `workspace_key` will always be empty because the returned data covers the entire tenant.
          content:
            application/json:
              schema:
               additionalProperties: false
               type: object
               $ref: '#/components/schemas/UsageMeteringResponse'
              example:
                workspace_key: ""
                case_execution_count: 423484
                pipeline_execution_count: 223431
                plan_execution_count: 84722
                gatekeeper_execution_count: 33898
                manual_execution_count: 3127
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /metering/workspace/usage:
    get:
      tags:
        - Metering Query
      summary: List usage count of specific workspace(s) within a tenant
      description: List usage count of specific workspace(s) within a tenant.  Users who use this API must be a member or admin of the specified workspace(s). 
      operationId: listWorkspaceUsageCount
      parameters:
        - name: tenant_uuid
          in: query
          description: tenant uuid
          required: true
          schema:
            $ref: '#/components/schemas/tenant_uuid_base_string'
        - name: workspace_key
          in: query
          description: workspace key. Multiple entries can be provided, and the returned value will be the respective asset counts of each specified workspaces.
          schema:
            $ref: '#/components/schemas/workspace_key_base_array'
          required: true
        - name: begin_date_time
          in: query
          description: begin date time for usage query, leave both begin & end blank to return month-to-date usage data.
          schema:
            $ref: '#/components/schemas/date_time_base_string'
        - name: end_date_time
          in: query
          description: end date time for usage query, leave both begin & end blank to return month-to-date usage data.
          schema:
            $ref: '#/components/schemas/date_time_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
               additionalProperties: false
               type: array
               maxItems: 1000
               items:
                 type: object
                 $ref: '#/components/schemas/UsageMeteringResponse'
              example:
                - workspace_key: "Y2K"
                  case_execution_count: 43484
                  pipeline_execution_count: 23431
                  plan_execution_count: 8472
                  gatekeeper_execution_count: 3389
                  manual_execution_count: 312
                - workspace_key: "ABC"
                  case_execution_count: 43487
                  pipeline_execution_count: 23041
                  plan_execution_count: 3847
                  gatekeeper_execution_count: 7338
                  manual_execution_count: 831
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /tssmgmt/credentialSafe/findSafes:
    get:
      tags:
        - Testany Secrets Service Management
      summary: List credential safe instances
      description: List credential safe instances
      operationId: listAllCredentialSafes
      parameters:
      - name: workspace
        in: query
        schema:
          type: string
          $ref: '#/components/schemas/workspace_key_base_string'
        required: true
      - name: X-Sign
        in: header
        description: |
           - The input here shall be the payload ```{"workspace_key": "YOUR-WORKSPACE-KEY"}``` with sign. 
           You may get those payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/TSSCredentialSafeList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /tssmgmt/credentialSafe/filterListWorkspaces:
    get:
      tags:
        - Testany Secrets Service Management
      summary: List all the workspaces which has credentialSafe data
      description: | 
        List all the workspaces which the current user has access permission to the creadential safe(s) underneath. 
      operationId: listAllCredentialSafeWorkspace
      parameters:
        - name: X-Sign
          in: header
          description: |
            - The payload `{}` with sign. You may get the payload signed with /permission/signForTSSM .
          required: true
          schema:
            $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/workspace_key_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /tssmgmt/credentialSafe/filterListSafes:
    get:
      tags:
        - Testany Secrets Service Management
      summary: List all the credential safe for one specific workspace
      description: | 
        List all the credential safe for one specific workspace
      operationId: listAllCredentialSafeForOneSpecificWorkspace
      parameters:
      - name: workspace
        in: query
        schema:
          $ref: '#/components/schemas/workspace_key_base_string'
        required: true
      - name: X-Sign
        in: header
        description: |
          Either payload bellow with sign is valid. You may get the payload signed with /permission/signForTSSM .
            - `{"workspace_key": "YOUR-WORKSPACE-KEY"}` with sign
            - `{}` with sign
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  additionalProperties: false
                  type: object
                  properties:
                    name:
                      allOf:
                        - $ref: '#/components/schemas/object_name_base_string'
                      example: "My Key Vault"
                    key:
                      $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
          
  /tssmgmt/credentialSafe:
    post:
      tags:
        - Testany Secrets Service Management
      summary: Create a credential safe instance
      description: Create a new credential safe instance
      operationId: createOneCredentialSafe
      parameters:
      - name: X-Sign
        in: header
        description: |
          - Payload `{"workspace_key": "YOUR-WORKSPACE-KEY"}` with sign. 
          You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      requestBody:
        description: credential safe related information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TSSCredentialSafeForCreateRequest'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TSSCredentialSafeForCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /tssmgmt/credentialSafe/{key}:
    get:
      tags:
        - Testany Secrets Service Management
      summary: Get a credential safe instance detail info
      description: Get a credential safe instance detail info
      operationId: getOneCredentialSafe
      parameters:
      - name: key
        in: path
        description: the key of the Credential Safe Instance
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
      - name: X-Sign
        in: header
        description: >
          - Payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign.  
            For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign. 
            You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TSSCredentialSafeDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - Testany Secrets Service Management
      summary: Update a credential safe instance
      description: |
        This method is to update a Credential Safe instance. Please note: 
        - Credential Safe key is not allow to be updated. The workaround is to delete the original one and create a new one.
        - Any change to Credential Safe type or Credential will trigger the validation to the value of both Credential Safe type and credential. 
      operationId: updateOneCredentialSafe
      parameters:
      - name: key
        in: path
        description: the key of the Credential Safe Instance
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
      - name: X-Sign
        in: header
        description: |
          - The input shall be the signed payload of `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}`.  For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      requestBody:
        description: credential safe related information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TSSCredentialSafeOPT'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - Testany Secrets Service Management
      summary: Delete an exists credential safe instance
      description: Delete an exists credential safe instance
      operationId: deleteOneCredentialSafe
      parameters:
      - name: key
        in: path
        description: the key of the Credential Safe Instance
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
      - name: X-Sign
        in: header
        description: |
          - The input shall be the payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign. For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          type: string
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /tssmgmt/credential/findCredentials:
    get:
      tags:
        - Testany Secrets Service Management
      summary: List credential keys
      description: List credential keys
      operationId: listAllCredentialKeys
      parameters:
      - name: safe_key
        in: query
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
        required: true
      - name: X-Sign
        in: header
        description: |
          - The input shall be the payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign. For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/TSSCredentialList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  
  /tssmgmt/credential/filterListCredentials:
    get:
      tags:
        - Testany Secrets Service Management
      summary: List all the credentials for one specific credential safe
      description: | 
        List all the credentials for one specific credential safe
      operationId: listAllCredentialsForOneSpecificSafe
      parameters:
      - name: safe_key
        in: query
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
        required: true
      - name: X-Sign
        in: header
        description: |
          The input shall be either one of bellow. You may get the payload signed with /permission/signForTSSM .
            - payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign
            - payload `{}` with sign
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  additionalProperties: false
                  type: object
                  properties:
                    uuid:
                      $ref: '#/components/schemas/tssm_credential_uuid_base_string'
                    name:
                      $ref: '#/components/schemas/object_name_base_string'
                    key:
                      $ref: '#/components/schemas/tssm_credential_key_base_string'  
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /tssmgmt/credential:
    post:
      tags:
        - Testany Secrets Service Management
      summary: Create a credential in a Credential Safe instance
      description: Create a credential in a Credential Safe instance
      operationId: createOneCredentialInCredentialSafe
      parameters:
      - name: X-Sign
        in: header
        description: |
          - The input shall be the payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign. For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      requestBody:
        description: credential related information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TSSCredentialKeyForCreateRequest'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TSSCredentialKeyForCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

          
  /tssmgmt/credential/{uuid}:
    get:
      tags:
        - Testany Secrets Service Management
      summary: Get a credential detail info
      description: Get a credential detail info
      operationId: getOneCredentialDetail
      parameters:
      - name: uuid
        in: path
        description: Credential UUID
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credential_uuid_base_string'
      - name: safe_key
        in: query
        description: key of the credential safe which the credential belongs to
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
      - name: X-Sign
        in: header
        description: |
          - The input shall be the payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign. For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TSSCredentialKeyDetail'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    patch:
      tags:
        - Testany Secrets Service Management
      summary: Update a credential
      description: |
        This method is to update a Credential. Please note: 
        - Credential key is not allow to be updated. The workaround is to delete the original one and create a new one.
#        Update a credential, key is not allow to update, if user want to update key, please delete first and create a new one.
      operationId: updateOneCredential
      parameters:
      - name: uuid
        in: path
        description: uuid of the credential
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credential_uuid_base_string'
      - name: safe_key
        in: query
        description: key of the credential safe which the credential belongs to
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
      - name: X-Sign
        in: header
        description: |
          - The input shall be the signed payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}`. For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      requestBody:
        description: credential safe related information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TSSCredentialOPT'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      tags:
        - Testany Secrets Service Management
      summary: Delete an exists credential
      description: Delete an exists credential
      operationId: deleteOneCredential
      parameters:
      - name: uuid
        in: path
        description: uuid of the credential
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credential_uuid_base_string'
      - name: safe_key
        in: query
        description: the key of the credential safe which the current credential belongs to
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
      - name: X-Sign
        in: header
        description: |
          - This input shall be the payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign. For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /tssmgmt/credential/{uuid}/usedBy:
    get:
      tags:
        - Testany Secrets Service Management
      summary: Get a credential be used by cases list
      description: Get a credential be used by cases list
      operationId: getOneCredentialUsedByList
      parameters:
      - name: uuid
        in: path
        description: uuid of the current credential
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credential_uuid_base_string'
      - name: safe_key
        in: query
        description: The key of the credential safe which the current credential belongs to
        required: true
        schema:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
      - name: X-Sign
        in: header
        description: |
          - This input shall be the payload `{"credentialsafe_key": "RuntimeUUID.YOUR-CS-KEY"}` with sign. For example, `{"credentialsafe_key": "123e4567-e89b-12d3-a456-426614174000.ABC-CS-0001"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: The response is the list of secure_uuid (1:1 mapping with test case key) which the current credential be used.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/case_secure_uuid_base_array'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    
  /tssmgmt/credential/assign/{case_secure_uuid}:
    put:
      tags:
        - Testany Secrets Service Management
      summary: Assign multiple credentials to a case
      description: |
        Assign multiple credentials to a case, it will replace the specific case linked credentials list.
        If the payload is [], means remove all the keys from this specific case.
      operationId: assignMultipleCredentialsToOneCase
      parameters:
      - name: case_secure_uuid
        in: path
        schema:
          $ref: '#/components/schemas/case_secure_uuid_base_string'
        required: true
      - name: X-Sign
        in: header
        description: |
          - The input shall be the signed payload `{"secure_uuid": "YOUR-SECURE-UUID"}`. For example, `{"secure_uuid": "123e4567-e89b-12d3-a456-426614174000"}` with sign.  You may get the payload signed with /permission/signForTSSM .
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      requestBody:
        description: credential related information
        content:
          application/json:
            schema:
              type: array
              maxItems: 10000
              items:
                $ref: '#/components/schemas/TSSCredentialAssignOPT'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
    
          
  /tssmgmt/credential/assign/{case_secure_uuid_or_case_key}/findAll:
    get:
      tags:
        - Testany Secrets Service Management
      summary: Find all credentials from one case
      description: |
        Find all credentials from one case
        valid_flag:
        - false: data with deleted status or no related workspace reading_settings permssion 
        - true: active data
      operationId: findAllCredentialsFromOneCase
      parameters:
      - name: case_secure_uuid_or_case_key
        in: path
        description: |
          The input here can be either case_secure_uuid or case_key        
        schema:
          anyOf:
            - $ref: '#/components/schemas/tssm_credential_uuid_base_string'
            - $ref: '#/components/schemas/unit_layer_object_key_base_string'
          example: 7c2b9f71-09a0-4d33-9c3a-4b7c2926e47a
        required: true
      - name: X-Sign
        in: header
        description: |
          The input shall be either of the following:
          - Payload `{"secure_uuid": "YOUR-SECURE-UUID"}` with sign
          - Payload `{"case_key": "YOUR-CASE-KEY"}` with sign
        required: true
        schema:
          $ref: '#/components/schemas/tssm_x_sign_base_string'
      responses:
        '200':
          description: assigned key list
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/TSSCredentialAssignList'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'




  /partner:
    post:
      tags:
        - Partner Management
      summary: Create a partner
      description: Create a new partner, this API is only available for global admin
      operationId: createOnePartner
      requestBody:
        description: partner related information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerInfoForCreate'
        required: true
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

  /partner/{key}/byAdmin:
    patch:
      tags:
        - Partner Management
      summary: Update partner information by global admin
      description: Update partner information by global admin, this API is only available for global admin
      operationId: updateOnePartnerByAdmin
      parameters:
      - name: key
        in: path
        description: the key of the partner
        required: true
        schema:
          $ref: '#/components/schemas/partner_key_base_string'
      requestBody:
        description: partner related information
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerInfoForUpdateByGlobalAdmin'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    get:
      tags:
        - Partner Management
      summary: Get detail info of a partner by global admin
      description: Get detail info of a partner by global admin, this API is only available for global admin
      operationId: getOnePartnerByAdmin
      parameters:
      - name: key
        in: path
        description: the key of the partner
        required: true
        schema:
          $ref: '#/components/schemas/partner_key_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerInfoForReadByGlobalAdmin'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'      

  /partner/{key}/byPartner:
    patch:
      tags:
        - Partner Management
      summary: Update partner information by partner itself
      description: Update partner information by partner itself, this API is only available for partner
      operationId: updateOnePartnerByPartner
      parameters:
      - name: key
        in: path
        description: the key of the partner
        required: true
        schema:
          $ref: '#/components/schemas/partner_key_base_string'
      requestBody:
        description: partner related information can be updated by partner
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerInfoForUpdateByPartner'
      responses:
        '204':
          description: No content
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    get:
      tags:
        - Partner Management
      summary: Get detail info of a partner by partner itself
      description: Get detail info of a partner by partner itself, this API is only available for partner
      operationId: getOnePartner
      parameters:
      - name: key
        in: path
        description: the key of the partner
        required: true
        schema:
          $ref: '#/components/schemas/partner_key_base_string'
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                allOf:
                - $ref: '#/components/schemas/PartnerInfoForReadByPartner'
                - type: object
                  properties:
                    uid:
                      $ref: '#/components/schemas/partner_uid_base_string'
                    referral_id:
                      $ref: '#/components/schemas/partner_referral_id_base_string'
        default:
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'


#########################
#  below are unrefined NG APIs
#########################
  /notification/method:
    get:
      summary: List notification methods
      description: |-
        - `GET /method` will return a list of methods in the form of an array when invoked.
        - `managed` means the method is managed by testany platform and cannot be changed.
        - `enabled` reflects the current status of the method.
      tags: 
      - NG Management APIs
      operationId: listNotificationMethods
      security:
      - bearerAuth: []
      responses:
        '200':
          description: 'Successful Operation'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/Method'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  /notification/method/{method_id}:
    patch:
      tags: 
      - NG Management APIs
      summary: Enable or disable a notification method.
      description: Global Admin use only.
      operationId: updateNotificationMethod
      security:
      - bearerAuth: []
      parameters:
      - $ref: '#/components/parameters/method_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/boolean_base_boolean'
            examples:
              toggle on:
                value: true
              toggle off:
                value: false
      responses:
        '204':
          description: 'Operation performed successfully'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  /notification/receiver:
    get:
      summary: List receivers
      description: |-
        `GET /receiver` will return list of receivers when invoked.
        - When have both or other combinations, return `400` as workspace, uid, resource_key can not present at same time (AND operator).
        - When invoking with `resource_type` & `resource_key`, a resource related list of receivers will be returned.
        - When invoking with `worksapce`, a workspace related list of receivers will be returned.
        - When invoking with `user`, an user related list of receivers will be returned.
        - When lacking all of them, return all user receivers.
      tags:
      - NG Receiver APIs
      operationId: listReceivers
      parameters:
        - in: query
          name: ListReceiversBy
          description: |
            - 4 types of filter combinations are allowed here:
              - a single workspace_key
              - a single user
              - a single resource (resource_type & resource_key)
              - none
            - When have both or other combinations, return `400` as workspace, uid, resource_key can not present at same time (AND operator).
          schema:
            oneOf:
              - $ref: '#/components/schemas/NGResourceObject'
              - $ref: '#/components/schemas/NGWorkspaceObject'
              - $ref: '#/components/schemas/NGUserObject'
              - $ref: '#/components/schemas/NGEmptyObject'
      security:
      - bearerAuth: []
      responses:
        '200':
          description: 'Successful Operation'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/Receiver'
              examples:
                list for a resource:
                  value:
                    - id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                      name: dev team
                      workspace: WKS
                      method: email
                      target: dev@acme.tld
                      rules_uuid: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
                    - id: 70a7afb9-e9d1-405c-83e4-6cdd632e9eaa
                      name: dev team webex
                      workspace: WKS
                      method: webex_webhook
                      target: "https://webexapis.com/v1/webhooks/incoming/<incoming_webhook_url>"
                      link: "https://webex.acme.tld/room/1234567890"
                      rules_uuid: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
                list all users:
                  value:
                    [{
                      id: 851ce252-8183-4a97-8d7e-f3f5f023da97,
                      name: "John Doe",
                      method: "email",
                      target: "john.doe@acme.tld",
                      rules_uuid: [f3c79114-825d-426c-b8d5-1849d962175d]
                    }, {
                      id: 490999a4-6f3e-40ca-b332-4ba81a0ecd8d,
                      name: "Joe Doe",
                      method: "email",
                      target: "joe.doe@acme.tld",
                      rules_uuid: []
                    },  {
                      id: 04475859-4903-4c86-9121-79e061401b92,
                      name: "Jerry Doe",
                      method: "email",
                      target: "jerry.doe@acme.tld",
                      rules_uuid: []
                    }]
                list an user:
                  value:
                    [{
                      id: 851ce252-8183-4a97-8d7e-f3f5f023da97,
                      name: "John Doe",
                      method: "email",
                      target: "john.doe@acme.tld",
                      rules_uuid: [f3c79114-825d-426c-b8d5-1849d962175d]
                    }, {
                      id: 1007,
                      name: "John Doe",
                      method: "webex_webhook",
                      target: "https://webexapis.com/v1/webhooks/incoming/john-doe-12345678",
                      rules_uuid: []
                    }]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

    post:
      summary: Create a new receiver
      description: |-
        **Ignore request schema**
        - Reject when creating an user receiver. (If request contains user, reject since user onboarding is handled by UMS event)
      operationId: createReceiver
      tags: 
      - NG Receiver APIs
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Receiver'
            examples:
              'workspace webex hook':
                value:
                  name: "dev team"
                  workspace: "WKS"
                  method: "webex_webhook"
                  target: "https://webexapis.com/v1/webhooks/incoming/<incoming_webhook_url>"
                  link: "https://webex.acme.tld/room/1234567890"
              'workspace generic hook':
                value:
                  name: "dev team"
                  workspace: "WKS"
                  method: "webex_webhook"
                  target: "https://hook.acme.tld/v1/webhooks/incoming/<incoming_webhook_url>"
                  link: "https://wiki.acme.tld/runbooks/123456"
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Receiver'
              examples:
                new receiver:
                  value:
                    id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    name: dev team
                    workspace: WKS
                    method: email
                    target: dev@acme.tld
                    rules: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  '/notification/receiver/{receiver_id}/assignRule':
    put:
      summary: Assign a rule to a receiver
      description: |-
        workspace, resource_key, resource_type, used to find out resource related rules
        rule_type used to identity which rule, currently the rule supports any or fail
        - `ANY` means send notification for every execution, system not check execution status.
        - `FAIL` means only execution status with not success, then send notification
        
        when `rule_type` set as ANY, means current receiver move to ANY, if the current receiver has rule FAIL, the receiver need delete from the FAIL and add to the ANY
        
        when `rule_type` set as FAIL, means current receiver move to FAIL, if the current receiver has rule ANY, the receiver need delete from the ANY and add to the FAIL
      operationId: assignRuleToReceiver
      tags: 
      - NG Receiver APIs
      parameters:
      - $ref: '#/components/parameters/receiver_id'
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                resource_type:
                  type: string
                  $ref: '#/components/schemas/trigger_method_type_base_string'
                  nullable: false
                resource_key:
                  type: string
                  $ref: '#/components/schemas/trigger_method_object_key_base_string'
                  nullable: false
                workspace:
                  type: string
                  allOf:
                    - $ref: '#/components/schemas/workspace_key_base_string'
                  description: |
                    the workspace key which the resource belongs to
                role_type:
                  type: string
                  enum:
                    - ANY
                    - FAIL
              required:
                - resource_type
                - resource_key
                - workspace
                - role_type          
      responses:
        '200':
          description: 'Operation performed successfully, returned up-to-date result'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Receiver'
              examples:
                'change name':
                  value:
                    id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    name: ops team
                    workspace: WKS
                    method: email
                    target: dev@acme.tld
                    link: "https://webex.acme.tld/room/1234567890"
                    rules: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
                'change type and target':
                  value:
                    id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    name: dev team
                    workspace: WKS
                    method: webex_webhook
                    target: "https://webexapis.com/v1/webhooks/incoming/<incoming_webhook_url>"
                    link: "https://webex.acme.tld/room/1234567890"
                    rules: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  '/notification/receiver/{receiver_id}/unassignRule':
    put:
      summary: Unassign a rule from a receiver
      description: |-
        workspace, resource_key, resource_type, used to find out resource related rules
        
        remove current receiver from Any or Fail rules
        
        if user which is the resource owner, the user is not allow to be unassigned
      operationId: unassignRuleFromReceiver
      tags: 
      - NG Receiver APIs
      parameters:
      - $ref: '#/components/parameters/receiver_id'
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                resource_type:
                  type: string
                  $ref: '#/components/schemas/trigger_method_type_base_string'
                  nullable: false
                resource_key:
                  type: string
                  $ref: '#/components/schemas/trigger_method_object_key_base_string'
                  nullable: false
                workspace:
                  type: string
                  allOf:
                    - $ref: '#/components/schemas/workspace_key_base_string'
                  description: |
                    the workspace key which the resource belongs to
              required:
                - resource_type
                - resource_key
                - workspace
      responses:
        '200':
          description: 'Operation performed successfully, returned up-to-date result'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Receiver'
              examples:
                'change name':
                  value:
                    id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    name: ops team
                    workspace: WKS
                    method: email
                    target: dev@acme.tld
                    link: "https://webex.acme.tld/room/1234567890"
                    rules: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
                'change type and target':
                  value:
                    id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    name: dev team
                    workspace: WKS
                    method: webex_webhook
                    target: "https://webexapis.com/v1/webhooks/incoming/<incoming_webhook_url>"
                    link: "https://webex.acme.tld/room/1234567890"
                    rules: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  '/notification/receiver/{receiver_id}':
    patch:
      summary: Update a receiver
      description: |-
        **Ignore request schema**
        - Reject all update on `uuid`, `workspace`, `user`, `method` parameter
      operationId: updateReceiver
      tags: 
      - NG Receiver APIs
      parameters:
      - $ref: '#/components/parameters/receiver_id'
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Receiver'
            examples:
              'update name':
                value: 
                  name: "ops team"
              'update type and target':
                value: 
                  method: "webex_webhook"
                  target: "https://webexapis.com/v1/webhooks/incoming/<incoming_webhook_url>"
      responses:
        '200':
          description: 'Operation performed successfully, returned up-to-date result'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Receiver'
              examples:
                'change name':
                  value:
                    id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    name: ops team
                    workspace: WKS
                    method: email
                    target: dev@acme.tld
                    link: "https://webex.acme.tld/room/1234567890"
                    rules: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
                'change type and target':
                  value:
                    id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    name: dev team
                    workspace: WKS
                    method: webex_webhook
                    target: "https://webexapis.com/v1/webhooks/incoming/<incoming_webhook_url>"
                    link: "https://webex.acme.tld/room/1234567890"
                    rules: [357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4, f3c79114-825d-426c-b8d5-1849d962175d, 681bc5df-7b26-4259-a506-009d0d9acf17]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'
    
    delete:
      summary: Delete a receiver
      description: |-
        **Ignore request schema**
        - Reject when deleting an user receiver. (If deleting an user receiver, reject since user offboarding is not supported)
      operationId: deleteReceiver
      tags: 
      - NG Receiver APIs
      parameters:
      - $ref: '#/components/parameters/receiver_id'
      security:
      - bearerAuth: []
      responses:
        '204':
          description: 'Operation performed successfully'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  '/notification/receiver/{receiver_id}/relations':
    get:
      summary: List receiver's relations
      description: |-
        `GET /receiver/{receiver_id}/relations` will return list of receiver's binding.
      operationId: listReceiverRelations
      tags:
      - NG Receiver APIs
      parameters:
      - $ref: '#/components/parameters/receiver_id'
      security:
      - bearerAuth: []
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/ReceiverRelations'
              examples:
                'list all for a receiver':
                  value:
                  - id: 8fcc29d5-f175-4738-9699-9cd089c8b5ca
                    workspace: WKS
                    resource_type: plan
                    resource_key: P-WKS-0001
                  - id: 70a7afb9-e9d1-405c-83e4-6cdd632e9eaa
                    workspace: WKS
                    resource_type: gatekeeper
                    resource_key: G-WKS-0001  
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'
  '/notification/rule':
    get:
      summary: List rules
      description: |-
        `GET /rule` will return list of rules when invoked with following conditions:
        - When invoking with `workspace` and `resource_type`, list of resource type of the workspace's rules will be returned. E.g. :
          - `workspace=WKS&resource_type=plan` will return the platform managed rule for plan of WKS workspace.
          - `workspace=WKS&resource_type=pipeline` will return the platform managed rule when a pipeline was triggered manually
        - When invoking with `resource_type` only, return list of specific resource_type's rules. (No examples since design is not included in current stage)
        - When invoking with `worksapce`, `resource_type` and `resource_key`, rules of the specific resource will be returned. E.g. :
          - `workspace=WKS&resource_type=plan&resource_key=P-WKS-0001` will return the rules for plan `P-WKS-0001` under the `WKS` workspace.
        - When invoking with `resource_type` and `resource_key`, rules of the specific resource will be returned. (No examples since design is not included in current stage)
        - When lacking all of them, a 400 error will retruned indicating request is invalid.
      operationId: listRules  
      tags:
      - NG Rule APIs
      parameters:
      - $ref: '#/components/parameters/resource_type'
      - $ref: '#/components/parameters/workspace'
      - $ref: '#/components/parameters/resource_key'
      - $ref: '#/components/parameters/user'
      security:
      - bearerAuth: []
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/Rule'
              examples:
                'list for plan WKS-0001':
                  value:
                  - id: 357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4
                    name: notify dev team no matter result
                    resource_type: plan
                    resource_key: P-WKS-0001
                    workspace: WKS
                    active: true
                    rule: {
                      name: "pipeline execution failed",
                      attributes: [
                        {
                          name: "type",
                          type: "string"
                        }
                      ],
                      decisions: [{
                        conditions: {
                          any: [{
                            fact: "event",
                            operator: "in",
                            value: ["pipeline.execution.succeed", "pipeline.execution.failed"],
                            path: "$.type"
                          }]
                        }
                      }]
                    }
                    receivers: [70a7afb9-e9d1-405c-83e4-6cdd632e9eaa, 69a37a3d-61c0-41c4-bed3-07ac2c2b17e7, 851ce252-8183-4a97-8d7e-f3f5f023da97]
                  - id: f3c79114-825d-426c-b8d5-1849d962175d
                    name: dev team when fails only
                    resource_type: plan
                    resource_key: P-WKS-0001
                    workspace: WKS
                    active: true
                    rule: {
                      name: "pipeline execution failed",
                      attributes: [
                        {
                          name: "type",
                          type: "string"
                        }
                      ],
                      decisions: [{
                        conditions: {
                          any: [{
                            fact: "event",
                            operator: "in",
                            value: ["pipeline.execution.failed"],
                            path: "$.type"
                          }]
                        }
                      }]
                    }
                    receivers: [70a7afb9-e9d1-405c-83e4-6cdd632e9eaa, 69a37a3d-61c0-41c4-bed3-07ac2c2b17e7]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

    post:
      tags: 
      - NG Rule APIs
      summary: Create a new rule
      operationId: createRule
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RuleOpt'
            examples:
              'create rule for plan WKS-0001':
                value:
                  name: notify dev team no matter result
                  resource_type: plan
                  resource_key: P-WKS-0001
                  workspace: WKS
                  active: true
                  receivers: [70a7afb9-e9d1-405c-83e4-6cdd632e9eaa, 69a37a3d-61c0-41c4-bed3-07ac2c2b17e7, 851ce252-8183-4a97-8d7e-f3f5f023da97]
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Receiver'
              examples:
                'list for plan WKS-0001':
                  value:
                    id: 357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4
                    name: notify dev team no matter result
                    resource_type: plan
                    resource_key: P-WKS-0001
                    workspace: WKS
                    active: true
                    rule: {
                      name: "pipeline execution failed",
                      attributes: [
                        {
                          name: "type",
                          type: "string"
                        }
                      ],
                      decisions: [{
                        conditions: {
                          any: [{
                            fact: "event",
                            operator: "in",
                            value: ["pipeline.execution.succeed", "pipeline.execution.failed"],
                            path: "$.type"
                          }]
                        }
                      }]
                    }
                    receivers: [70a7afb9-e9d1-405c-83e4-6cdd632e9eaa, 69a37a3d-61c0-41c4-bed3-07ac2c2b17e7, 851ce252-8183-4a97-8d7e-f3f5f023da97]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  '/notification/rule/{rule_id}':
    patch:
      summary: Update a rule
      deprecated: true
      description: |-
        **Ignore request schema**
        - Reject all update on `uuid`, `resource_type`, `resource_key`, `workspace` parameter
      operationId: updateRule
      tags: 
      - NG Rule APIs
      parameters:
      - $ref: '#/components/parameters/rule_id'
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RuleOpt'
            examples:
              'update linked receiver':
                value: 
                  receiver: [70a7afb9-e9d1-405c-83e4-6cdd632e9eaa, 69a37a3d-61c0-41c4-bed3-07ac2c2b17e7, 851ce252-8183-4a97-8d7e-f3f5f023da97]
      responses:
        '200':
          description: 'Operation performed successfully, returned up-to-date result'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Rule'
              examples:
                'update linked receiver':
                  value:
                    id: 357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4
                    name: notify dev team no matter result
                    resource_type: plan
                    resource_key: P-WKS-0001
                    workspace: WKS
                    active: true
                    rule: {
                      name: "pipeline execution failed",
                      attributes: [
                        {
                          name: "type",
                          type: "string"
                        }
                      ],
                      decisions: [{
                        conditions: {
                          any: [{
                            fact: "event",
                            operator: "in",
                            value: ["pipeline.execution.succeed", "pipeline.execution.failed"],
                            path: "$.type"
                          }]
                        }
                      }]
                    }
                    email_group: true
                    receivers: [70a7afb9-e9d1-405c-83e4-6cdd632e9eaa, 69a37a3d-61c0-41c4-bed3-07ac2c2b17e7, 851ce252-8183-4a97-8d7e-f3f5f023da97]
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

    delete:
      summary: Delete a rule
      operationId: deleteRule
      tags: 
      - NG Rule APIs
      parameters:
      - $ref: '#/components/parameters/rule_id'
      security:
      - bearerAuth: []
      responses:
        '204':
          description: 'Operation performed successfully'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

  '/notification/utility/email_group':
    get:
      summary: Check if email grouping is enabled for a resource
      operationId: checkEmailGroup
      tags:
      - NG Utility APIs
      parameters:
      - $ref: '#/components/parameters/resource_type'
      - $ref: '#/components/parameters/resource_key'
      security:
      - bearerAuth: []
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                type: array
                maxItems: 10000
                items:
                  $ref: '#/components/schemas/EmailGroupPayload'
              examples:
                'result for plan WKS-1234':
                  value:
                    resource_type: plan
                    resource_key: P-WKS-1234
                    email_group: true
                'result for gatekeeper WKS-4321':
                  value:
                    resource_type: gatekeeper
                    resource_key: G-WKS-4321
                    email_group: false
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'

    patch:
      summary: Enable or disable email grouping for a resource
      operationId: toggleEmailGroup
      tags:
      - NG Utility APIs
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmailGroupPayload'
            examples:
              'enable email grouping for plan WKS-1234':
                value: 
                  resource_type: plan
                  resource_key: P-WKS-1234
                  email_group: true
              'disable email grouping for gatekeeper WKS-4321':
                value: 
                  resource_type: gatekeeper
                  resource_key: G-WKS-4321
                  email_group: false
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailGroupPayload'
              examples:
                'result for plan WKS-1234':
                  value:
                    resource_type: plan
                    resource_key: P-WKS-1234
                    email_group: true
                'result for gatekeeper WKS-4321':
                  value:
                    resource_type: gatekeeper
                    resource_key: G-WKS-4321
                    email_group: false
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '406':
          $ref: '#/components/responses/406'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
        'default':
          $ref: '#/components/responses/default'


######################################
# Unrefined NG APIs end
######################################

  /directory:
    post:
      summary: Create a directory view
      operationId: createDirectoryView
      tags:
      - Directory View Management APIs
      security:
      - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DirectoryViewForCreate'
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DirectoryViewForCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
    
  /directory/{key}:
    put: 
      summary: Update a directory view
      operationId: updateDirectoryView
      tags:
      - Directory View Management APIs
      security:
      - bearerAuth: []
      parameters:
        - name: key
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/directory_key_base_string'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DirectoryViewForCreateResponse'
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DirectoryViewForCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '409':
                $ref: '#/components/responses/ConflictResponse'
        '415':
                $ref: '#/components/responses/UnsupportedMediaTypeResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    get:
      summary: Get whole details of a specific directory view
      operationId: getDirectoryView
      tags:
      - Directory View Management APIs
      security:
      - bearerAuth: []
      parameters:
        - name: key
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/directory_key_base_string'
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DirectoryViewForCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'

    delete:
      summary: Delete a directory view
      operationId: deleteDirectoryView
      tags:
      - Directory View Management APIs
      security:
      - bearerAuth: []
      parameters:
        - name: key
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/directory_key_base_string'
      responses:
        '204':
          description: 'No content'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
    
  /directory/findDirectoryViews:
    get:
      summary: List all directory views available to current user
      operationId: ListDirectoryViews
      tags:
      - Directory View Management APIs
      security:
      - bearerAuth: []
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                type: array
                maxItems: 1000
                items:
                  $ref: '#/components/schemas/DirectoryViewForCreateResponse'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
                
                
  /directory/{key}/setActiveDirectoryView:
    put: 
      summary: Set the active directory view
      operationId: SetActiveDirectoryView
      tags:
      - Directory View Management APIs
      security:
      - bearerAuth: []
      parameters:
        - name: key
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/directory_key_base_string'
      responses:
        '204':  
          description: 'No content'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
    
  /directory/getActiveDirectoryView:  
    get:
      summary: Get the active directory view
      operationId: GetActiveDirectoryView
      tags:
      - Directory View Management APIs
      security:
      - bearerAuth: []
      responses:
        '200':
          description: 'Operation performed successfully'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/directory_structure_key_base_string'
        default: 
                $ref: '#/components/responses/DefaultResponse'
        '400':
                $ref: '#/components/responses/BadRequestResponse'
        '401':
                $ref: '#/components/responses/UnauthorizedResponse'
        '403':
                $ref: '#/components/responses/ForbiddenResponse'
        '404':
                $ref: '#/components/responses/NotFoundResponse'
        '405':
                $ref: '#/components/responses/MethodNotAllowedResponse'
        '406':
                $ref: '#/components/responses/NotAcceptableResponse'
        '429':
                $ref: '#/components/responses/TooManyRequestsResponse'
                
                
                
                




























components:
  schemas:
    case_source_deletion_impact:
      type: object
      description: returned as `deletion_impact` by `GET /case/importHistory/{id}?include=deletion_impact`; send `source` and `source_etag` unchanged in the prepare request
      required: [source, source_etag, items, limits]
      properties:
        source:
          $ref: '#/components/schemas/case_source_detachment_source'
        source_etag:
          type: string
        items:
          type: array
          description: one entry per Case the import history owns
          items:
            $ref: '#/components/schemas/case_source_deletion_impact_item'
        limits:
          type: object
          description: the size limits that apply when Cases are kept
          properties:
            max_cases:
              type: integer
            max_archive_bytes:
              type: integer
            max_unpacked_bytes:
              type: integer
            max_files:
              type: integer
        active_operation:
          type: object
          description: your own unfinished operation on this source, if there is one (so that a lost response does not leave it without an id)
          properties:
            operation_id:
              type: string
              format: uuid
            state:
              type: string
              enum: [PREPARING, READY, FINALIZING]
    case_source_deletion_impact_item:
      type: object
      required: [case_id, case_key, case_etag, occupied, dependent_execution_count, allowed_dispositions]
      properties:
        case_id:
          type: integer
        case_key:
          type: string
        case_etag:
          type: string
          description: send it in `retain_cases[]` when you keep this Case
        occupied:
          type: boolean
          description: whether a pipeline uses the Case; an occupied Case cannot be deleted
        dependent_execution_count:
          type: integer
        allowed_dispositions:
          type: array
          description: "`RETAIN_LOCAL` the Case can be kept as a local Case, `DELETE` it can be deleted, `BLOCKED` neither (see `blocked_reason`)"
          items:
            type: string
            enum: [RETAIN_LOCAL, DELETE, BLOCKED]
        blocked_reason:
          type: string
          description: present with `BLOCKED`
    case_source_detachment_source:
      type: object
      description: the case source, copied unchanged from `deletion_impact.source`
      required: [kind, mode, id, runtime_uuid]
      properties:
        kind:
          type: string
          enum: [ATTACHED_SOURCE]
        mode:
          type: string
          enum: [OPENAPI, V2_MANAGED_IMPORT, V2_SYNC_LINK, V1]
        id:
          type: string
          format: uuid
        runtime_uuid:
          type: string
          format: uuid
    case_source_detachment_case_ref:
      type: object
      description: a Case to keep, copied unchanged from `deletion_impact.items[]`
      required: [case_id, case_key, case_etag]
      properties:
        case_id:
          type: integer
          minimum: 1
        case_key:
          type: string
        case_etag:
          type: string
    case_source_detachment_prepare_request:
      type: object
      required: [source, source_etag, retain_cases]
      properties:
        source:
          $ref: '#/components/schemas/case_source_detachment_source'
        source_etag:
          type: string
          description: "`deletion_impact.source_etag`; a source that changed since is rejected (`CSD_STALE`)"
        retain_cases:
          type: array
          description: the Cases to keep as local Cases; an empty array keeps none
          items:
            $ref: '#/components/schemas/case_source_detachment_case_ref'
    case_source_detachment_error:
      type: object
      required: [code, message, retryable]
      properties:
        code:
          type: string
          description: for example `CSD_SOURCE_UNAVAILABLE`, `CSD_STALE`, `CSD_EXPIRED`, `CSD_BUSY`
        message:
          type: string
        retryable:
          type: boolean
        reason_code:
          type: string
          description: "only with `CSD_SOURCE_UNAVAILABLE`; why the source could not be read, for example `V1_PRIVATE_REPOSITORY` (a Git V1 repository that cannot be read anonymously), `MIRROR_REF_NOT_FOUND`, `MIRROR_AUTH_FAILED`"
    case_source_detachment_item:
      type: object
      required: [case_id, case_key, state]
      properties:
        case_id:
          type: integer
        case_key:
          type: string
        state:
          type: string
          enum: [PENDING, READY, FAILED, DETACHED]
        package_version:
          type: string
          format: uuid
        last_error:
          $ref: '#/components/schemas/case_source_detachment_error'
    case_source_detachment_operation:
      type: object
      required: [operation_id, source, state, items, source_delete_pending]
      properties:
        operation_id:
          type: string
          format: uuid
        source:
          $ref: '#/components/schemas/case_source_detachment_source'
        source_etag:
          type: string
        state:
          type: string
          description: confirm only when `READY`
          enum: [PREPARING, READY, FINALIZING, COMPLETED, CANCELLED, FAILED, STALE]
        items:
          type: array
          items:
            $ref: '#/components/schemas/case_source_detachment_item'
        ready_etag:
          type: string
          description: send it in `If-Match` when confirming (present from `READY`)
        source_delete_pending:
          type: boolean
        last_error:
          $ref: '#/components/schemas/case_source_detachment_error'
######################################
# Schema被分成了如下几个部分：
# Part 1: Globally applicable field schema - 全都是基础的，可被复用的基本字段，包括string,integer, boolean
# Part 2: Resource-level field schema - 包括了所有可以直接在parameters, requestbody 和response 中被引用的字段，包括string, integer, object, array
######################################
# Globally applicable field schema
# 这部分规定了最基础的properties以及它们的属性，包括了type, format, pattern, min/max Length
# 同时给出了example，但使用中如需要进一步澄清，请在parameters, reqeust body, response里另写example。渲染时会自动覆盖本部分的example。
# 本部分包含了string, integer类型，不包括object, array, boolean和format: binary类型的字段
# 本部分的字段名称关系，禁止直接在parameters, requestbody 和response 中引用本部分的字段，以免造成混乱。
######################################

# Part 1-1: Globally reusable fields
    email_base_string:
      type: string
      format: email
      description: "email address"
      pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
      minLength: 5
      maxLength: 1024
      example: sample.email@testany.io

    uuid_base_string:
      type: string
      format: uuid
      description: "Universal properties for all places use UUID."
      pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
       # 验证UUID的正则，不解释
      minLength: 36
      maxLength: 36
      example: "d4e8a3e0-8e4e-4e7d-9a6a-3e8b7c9d2f1a"

    short_text_base_string:
      type: string
      description: "short text (length <80) field with input rules"
      pattern: ^[A-Za-z0-9][A-Za-z0-9 ._-]{0,78}[A-Za-z0-9._-]$
       # 第一个字符，必须是字母（大小写都可以）或数字
       # 中间的字符，可以是字母、数字、空格、点 (.)、下划线 (_) 或连字符 (-)，长度在 0 到 78 个字符之间（保证总长度在 2 到 80 之间）
       # 最后一个字符，必须是字母、数字、点 (.)、下划线 (_) 或连字符 (-)，但 不能是空格
      minLength: 2
      maxLength: 80      
      example: "Testany-Demo"

    url_base_string:
      type: string
      format: url
      description: "Universal properties for all place use URL."
      pattern: ^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$
      minLength: 1
      maxLength: 8192
       # (https?|ftp):\/\/：匹配以 http、https 或 ftp 开头的 URL 协议，并且必须有 ://
       # [^\s/$.?#]：匹配域名的第一部分，确保它不是空白字符，也不是 /、.、$、? 或 # 的特殊字符。
       # .[^\s]*：匹配 URL 的其余部分，可以包含任意字符，但不能包含空格。
      example: "https://www.testany.io"

    mid_text_base_string:
      type: string
      description: "mid text (length <256) field with input rules"
      pattern: ^[^\s"%\/\\*][^\s"%\/\\]{0,254}$
      minLength: 1
      maxLength: 256
       # 最短1个字符，最长255个字符
       # 不允许包含空格、引号 (")、百分号 (%)、斜杠 (/)、反斜杠 (\) 和星号 (*)
       # 第一个字符必须是有效字符，不能是上述禁止的字符
       # 后续的字符（最多254个）也必须是有效字符，不能包含上述禁止的字符
      example: "Hello_World"

    long_text_base_string:
      type: string
      description: "long text (length <1000) field with input rules"
      pattern: ^(?! )[^\u0000-\u001F]{1,999}[^\u0000-\u001F]?$|^(?! )[^\u0000-\u001F]{1,1000}$|^[^\u0000-\u001F][\s\S]{0,999}$
       # 第一个字符不为空格
       # 长度不超过1000字符，不包含unicode控制字符
       # 最后一个字符不能为控制字符
      minLength: 1
      maxLength: 32767
      example: "This is the description for an object."

    extra_long_text_base_string:
      type: string
      description: "extra long text (length <10000) field with input rules"
      pattern: ^(?! )[^\u0000-\u001F]{1,9999}[^\u0000-\u001F]?$|^(?! )[^\u0000-\u001F]{1,10000}$|^[^\u0000-\u001F][\s\S]{0,9999}$
      minLength: 1
      maxLength: 32767
      example: "This is the description for an object."

    phone_base_string:
      type: string
      description: "phone number"
      pattern: ^\+?[0-9]{1,15}$
      minLength: 1
      maxLength: 16
      example: "+1234567890"

    free_short_text_base_string:
      type: string
      description: "free text (length <2^8) field without input rules"
      pattern: ^[^\u0000-\u001F]*$
      maxLength: 256
      example: "This is free text"

    free_long_text_base_string:
      type: string
      description: "free text (length <2^20) field without input rules"
      pattern: ^[^\u0000-\u001F]*$
      maxLength: 1048576
      example: "This is free text"

    date_time_base_string:
      type: string
      format: date-time
      description: "The timestamp in ISO 8601 format: YYYY-MM-DDThh:mm:ssZ"
      pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d:[0-5]\d(\.\d+)?(Z|[+-][01]\d:[0-5]\d)?$
      maxLength: 64
      example: "2024-10-05T10:11:12Z"

    date_base_string:
      type: string
      format: date
      description: "The date in ISO 8601 format: YYYY-MM-DD"
      pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
      example: "2024-10-05"

    timezone_base_string:
      type: string
      pattern: ^[A-Za-z]+/[A-Za-z_]+$ 
      minLength: 3
      maxLength: 64
      example: "Asia/Shanghai"
      description: "IANA time zone identifier, e.g., 'Asia/Shanghai', 'America/New_York'"

    binary_base_string:
      type: string
      format: binary
      maxLength: 1048576
      description: "The binary data representing a file (e.g., image, PDF)."
    
    base64_base_string:
      type: string
      format: byte
      pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$
      maxLength: 1048576
      description: "A string in Base64 format."
      example: "dGVzdGFueQ=="

    id_base_integer:  # boyi: 请注意，有些地方（例如 'User:' 里 ID 你用的是string，我建议改成integer
      type: integer
      format: int32
      minimum: 1
      maximum: 2147483647
      example: 100

    count_base_integer:
      type: integer
      format: int64
      minimum: 0
      maximum: 9223372036854775807
      example: 100

    index_base_integer:
      type: integer
      format: int32
      minimum: 0
      maximum: 1024
      example: 0

    boolean_base_boolean:
      type: boolean
      default: false
      example: true


# part 1-2: Domain Specific reusable fields

  # part 1-2-0 : across product base fields
    object_environment_base_string:
      type: string
      pattern: ^[A-Z0-9][A-Z0-9 ._-]{0,78}[A-Z0-9._-]$
      minLength: 2
      maxLength: 80
       # 第一个字符，必须是大写字母或数字
       # 中间的字符，可以是大写字母、数字、空格、点 (.)、下划线 (_) 或连字符 (-)，长度在 0 到 78 个字符之间（保证总长度在 2 到 80 之间）
       # 最后一个字符，必须是大写字母、数字、点 (.)、下划线 (_) 或连字符 (-)，但不能是空格
      description: "Used to indicate the environment of the software under test for this test case."
      example: "Testany-Demo"
      nullable: false

    object_environments_base_array:
      type: array
      maxItems: 100
      items:
        $ref: '#/components/schemas/object_environment_base_string'
      example: ["Testany-Demo", "Testany-Prod"]

    object_name_base_string:
      $ref: '#/components/schemas/short_text_base_string'
      description: "The name for the object."
      example: "My first test case"
      nullable: false

    object_description_base_string:
      $ref: '#/components/schemas/extra_long_text_base_string'
      description: "The description for the object."
      example: "This is the description for an object."
      nullable: true

    object_status_code_base_integer:
      type: integer
      enum:
        - 0
        - 1
        - 2
        - 3
        - 4
      example: 1
      description: "The status code for the object. `deleted` is 0, `active` is 1, `paused` is 2, `archived` is 3, `requested` is 4."

    #object_status_message_base_string:
    #  type: string
    #  enum:
    #    - "Deleted"
    #    - "Active"
    #    - "Paused" # boyi: 暂时只想到以后暂停Plan用到。
    #    - “Archived" # boyi: 暂时只有Workspace会用到。
    #    - "Requested" # boyi: 暂时只有Workspace会用到。
    #  example: "Active"

    object_creator_base_string:
      $ref: '#/components/schemas/user_uid_base_string'
      description: "The owner of the object."
      nullable: false

    object_owner_base_string:
      $ref: '#/components/schemas/user_uid_base_string'
      description: "The owner of the object."
      nullable: false

    object_owner_base_array:
      $ref: '#/components/schemas/user_uid_base_array'
      description: "The owner(s) of the object."
      nullable: false

    object_watcher_base_string:
      $ref: '#/components/schemas/user_uid_base_string'
      description: "The watcher of the object."
      nullable: true

    object_watcher_base_array:
      $ref: '#/components/schemas/user_uid_base_array'
      description: "The watcher(s) of the object."

    object_label_base_string:
      $ref: '#/components/schemas/mid_text_base_string'
      description: "label for the object"
      example: "Hello_World"
      nullable: false

    object_labels_base_array:
      type: array
      maxItems: 100
      items:
        $ref: '#/components/schemas/object_label_base_string'
      example: ["Hello_World", "Testany"]

    page_next_page_token_base_string:
      $ref: '#/components/schemas/base64_base_string'
      description: "A base64 string, if no value then return first 50 records."
      example: "dGVzdGFueQ=="
      nullable: false

    page_page_number_base_integer:
      $ref: '#/components/schemas/id_base_integer'
      description: "The page number of the result set. Default is 1."
      minimum: 1
      example: 1
      nullable: false

    page_page_size_base_integer:
      $ref: '#/components/schemas/id_base_integer'
      description: "The number of records per page. Default is 50."
      example: 50
      minimum: 1
      maximum: 100
      nullable: false

    referral_id_base_string:
      type: string
      description: "The promotion code which represent promotion channel, source and type."
      pattern: ^[A-Z0-9]{8}$ # 8位大写字母和数字
      minLength: 8
      maxLength: 8
      example: "TEST1234"

    environment_variable_key_base_string:
      type: string
      description: "The key of the environment variable."
      pattern: ^[A-Z][A-Z0-9_]{0,79}$
      minLength: 1
      maxLength: 80
      example: "TEST_VARIABLE"
    
    environment_variable_value_base_string:
      allOf:
        - $ref: '#/components/schemas/long_text_base_string'
      description: "The value of the environment variable."

    environment_variable_description_base_string:
      allOf:
        - $ref: '#/components/schemas/long_text_base_string'
      description: "The description of the environment variable."
      


    error_code_base_string:
      type: string
      description: "The Testany Platform customized error code."
      pattern: ^E\d{6}$
      maxLength: 7
      example: "E400001"

    error_message_base_string:
      type: string
      description: "The Testany Platform customized error message."
      $ref: '#/components/schemas/long_text_base_string'
      maxLength: 1024
      example: "The request is invalid."

    CustomizedErrorResponse:
      description: "A customized error response for specific errors"
      type: object
      additionalProperties: false
      properties:
        code:
          $ref: '#/components/schemas/error_code_base_string'
        message:
          allOf:
            - $ref: '#/components/schemas/error_message_base_string'
          example: "The request is invalid."


  # part 1-2-1: TSSM fields
    tssm_credentialsafe_key_base_string:
      type: string
      description: "key for Credential Safe"
      pattern: ^[A-Z][A-Z0-9]{2}-CS-[0-9A-F]{4}$
       # -[A-Z][A-Z0-9]{2}: 表示中间的部分第一个字符必须是大写字母，第二第三个字符可以是大写字母或0-9的数字
       # -CS: 第二部分必须为大写字母CS，代表Credential Safe
       # -[0-9A-F]{4}$: 代表4位16进制数，范围在0-9和A-F之间
      example: "XYZ-CS-0001"

    tssm_credentialsafe_type_base_string:
      type: string
      description: "type for Credential Safe"
      enum:
        - "azure-key-vault"
        - "aws-secrets-manager"
      example: "azure-key-vault"

    tssm_credential_key_base_string:
      type: string
      description: "key for credential"
      pattern: ^[a-zA-Z][a-zA-Z0-9-]{0,126}$
       # [a-zA-Z]: 表示第一个字符必须是一个英文字母（大写或小写）。范围为 A-Z 和 a-z。
       # [a-zA-Z0-9-]{0,126}: 表示后续的字符可以是字母（大写或小写）、数字（0-9）或者连字符（-），总长度为 0 到 126 个字符。
      example: "This-is-a-credential-key"

    tssm_credential_type_base_string:
      type: string
      description: "type of credential"
      enum:
        - key
        - secret
        - credential
      example: "key"

    tssm_x_sign_base_string:
      type: string
      $ref: '#/components/schemas/base64_base_string'
      description: "sign with payload"
      example: "dGVzdGFueQ=="
      nullable: false

    tssm_credential_uuid_base_string:
      $ref: '#/components/schemas/uuid_base_string'
      description: "uuid of credential"
      nullable: false

    tssm_credentialsafe_vendor_base_string:
      type: string
      description: "vendor name for Credential Safe"
      enum:
        - "Azure"
        - "AWS"
      example: "Azure"

    tssm_credentialsafe_aws_region_id_base_string:
      type: string
      description: "AWS Region identifier, such as us-east-1 or cn-northwest-1"
      pattern: ^[a-z]{2}-[a-z]+-[0-9]$
      minLength: 5
      maxLength: 20
      example: "us-east-1"

    tssm_credentialsafe_aws_access_key_id_base_string:
      type: string
      description: "The AWS Access Key ID, a 20-character alphanumeric string beginning with 'AKIA'."
      pattern: ^AKIA[0-9A-Z]{16}$
      minLength: 20
      maxLength: 20
      example: "AKIAIOSFODNN7EXAMPLE"

    tssm_credentialsafe_aws_asm_secret_access_key_base_string:
      type: string
      description: "The AWS Secret Access Key, a 40-character alphanumeric string that should be kept confidential."
      pattern: ^[0-9A-Za-z/+=]{40}$
      minLength: 40
      maxLength: 40
      example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY"




    

  # part 1-2-2: backend fields


    #trigger_execution_object_key_base_string:
    #  type: string
    #  description: "key for executions of Plan/Gatekeeper/Manual"
    #  pattern: ^[MGP]-[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}-[0-9A-F]{5}$
    #   # ^[MGP]: 表示第一个字母必须是M, G或P
    #   # -[A-Z][A-Z0-9]{2}：表示中间的部分第一个字符必须是大写字母，第二第三个字符可以是大写字母或0-9的数字
    #   # -[0-9A-F]{4,5}：表示这一部分可以是 4 或 5 位的十六进制数，范围在 0-9 和 A-F 之间
    #   # -[0-9A-F]{5} 表示这一部分是5位的16进制数，范围在0-9和A-F之间
    #  example: "M-ABC-1D31-1122A"

    pipeline_execution_key_base_string:
      type: string
      description: "key for pipeline execution only"
      pattern: ^[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}-[0-9A-F]{5}$
       # -[A-Z][A-Z0-9]{2}：表示中间的部分第一个字符必须是大写字母，第二第三个字符可以是大写字母或0-9的数字
       # -[0-9A-F]{4,5}：表示这一部分可以是 4 或 5 位的十六进制数，范围在 0-9 和 A-F 之间
       # -[0-9A-F]{5} 表示这一部分是5位的16进制数，范围在0-9和A-F之间
      example: "ABC-A1D9-13F33"

    #pipeline_execution_key_base_array:
    #  type: array
    #  maxItems: 10000
    #  items:
    #    $ref: '#/components/schemas/pipeline_execution_key_base_string'

    execution_status_code_base_integer:
      type: integer
      enum:
        - -1
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        - 99
      example: -1

    execution_status_message_base_string:
      type: string
      enum:
        - Not started
        - Running
        - Passed/Success
        - Failed/Failure
        - Skipped
        - Fail as expected
        - Cancelled
        - Error
      example: "Running"

    trigger_method_object_key_base_string:
      type: string
      description: "the key for the Execution Trigger"
      pattern: ^[MGP]-[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}$
       # ^[MGP]: 表示第一个字母必须是M, G或P
       # -[A-Z][A-Z0-9]{2}：表示中间的部分第一个字符必须是大写字母，第二第三个字符可以是大写字母或0-9的数字
       # -[0-9A-F]{4,5}：表示最后一部分可以是 4 或 5 位的十六进制数，范围在 0-9 和 A-F 之间
      example: "M-ABC-01D31"

    trigger_method_type_base_string:
      type: string
      description: "test execution trigger type"
      enum:
        - plan
        - gatekeeper
        - manual
      example: plan

    schedule_expr_base_string: # boyi: 我看我们界面上的cron是有星期几的，所以应该是6个数字。 原来schema里的example是5个数字，我觉得是有歧义的。
      type: string
      description: "A cron expression to define the schedule (e.g., '0 0 * * *' for daily execution at midnight)."
      example: "0 0 * * * ?"
      maxLength: 11
      pattern: ^((((\d+,)+\d+|(\d+(\/|-|#)\d+)|\d+L?|\*(\/\d+)?|L(-\d+)?|\?|[A-Z]{3}(-[A-Z]{3})?) ?){5,7})$  # 用于匹配一般的 cron 表达式

    schedule_str_base_string:
      $ref: '#/components/schemas/long_text_base_string'
      description: "A human-readable string to define the schedule."
      example: "Every hour of every Monday"
      nullable: false

    pipeline_key_base_string:
      type: string
      description: "key for pipeline"  # If pipeline group need key in the future, use this format too.
      pattern: ^[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}$ 
       # -[A-Z][A-Z0-9]{2}：表示中间的部分第一个字符必须是大写字母，第二第三个字符可以是大写字母或0-9的数字
       # -[0-9A-F]{4,5}：匹配 4 位或 5 位的16进制数，且必须为大写（范围是 0-9 和 A-F）
      minLength: 9
      maxLength: 10
      example: "ABC-A1D49"

    pipelines_key_base_array:
      type: array
      maxItems: 100
      items:
        $ref: '#/components/schemas/pipeline_key_base_string'
      example: ["ABC-A1D49", "WKS-A1D50"]
    
    is_private_base_boolean:
      type: boolean
      description: "Mark whether this test case is global(tenant-wide) visible. `true` means NOT global visible, `false` means global visible."
      example: true

    pipeline_group_key_base_string:
      type: string
      description: "key for pipeline group"
      pattern: ^[MGP]-[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}$
       # ^[MGP]: 表示第一个字母必须是M, G或P
       # -[A-Z][A-Z0-9]{2}：表示中间的部分第一个字符必须是大写字母，第二第三个字符可以是大写字母或0-9的数字
       # -[0-9A-F]{4,5}：表示最后一部分可以是 4 或 5 位的十六进制数，范围在 0-9 和 A-F 之间
      example: "M-ABC-01D31"

    pipeline_yaml_base_string:
      type: string
      description: "The YAML content of the pipeline."
      pattern: ^kind:\s{1}rule
      minLength: 14
      maxLength: 1048576
      example: "This is the YAML content of the pipeline."
      nullable: false

    unit_layer_object_key_base_string:
      type: string
      description: "Key for test case." # If there would be other unit layer object added, use this format too.
      pattern: ^[0-9A-F]{8}$
       # [0-9A-F]{8}：匹配 8位16进制数，每一位可以是数字 0-9 或字母 A-F，且字母必须为大写
      minLength: 8
      maxLength: 8
      example: "A1B2C3D4"

    workspace_key_base_string:
      type: string
      description: "key for workspace"
      pattern: ^[A-Z][A-Z0-9]{2}$
       # [A-Z][A-Z0-9]{2}：表示中间的部分第一个字符必须是大写字母，第二第三个字符可以是大写字母或0-9的数字
      minLength: 3
      maxLength: 3
      example: "Y2K"


    workspace_key_base_array:
      type: array
      minItems: 1
      maxItems: 100
      items:
        $ref: '#/components/schemas/workspace_key_base_string'
      example: ["Y2K", "ABC"]

    #workspace_is_referred_base_boolean:
    #  type: boolean
    #  description: "Mark whether this workspace is referred by partner. `true` means referred, `false` means not referred."
    #  example: true

    workspace_referral_start_date:
      allOf:
        - $ref: '#/components/schemas/date_base_string'
      description: "The start date of the referral."
      example: "2024-10-05"

    workspace_referral_end_date:
      allOf:
        - $ref: '#/components/schemas/date_base_string'
      description: "The end date of the referral."
      example: "2024-10-05"
      

    case_meta_base_string:
      type: string
      format: JSON
      $ref: '#/components/schemas/free_long_text_base_string'
      maxLength: 1048576
      description: "A JSON string that contains meta information about the test configuration"
      example: |
        [{
          "framework": "postman",
          "envs": [
              {
                "id": "0",
                "envProfileName": "DEV",
                "path": "xxxxx-postman-collection.json",
                "command": [
                  "xxx.py"
                ],
                "environmentVariables": [
                  {
                    "name": "URL",
                    "value": "www.baidu.com"
                  }
                ],
                "secureUUID": "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"
              }
            ]
        }]
      nullable: false

    case_secure_uuid_base_string:
      $ref: '#/components/schemas/uuid_base_string'
      description: "The secure UUID of the test case."
      nullable: false

    case_secure_uuid_base_array:
      type: array
      maxItems: 10000
      items:
        $ref: '#/components/schemas/case_secure_uuid_base_string'
      example: ["d4e8a3e0-8e4e-4e7d-9a6a-3e8b7c9d2f1a", "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"]
    
    case_relay_flag_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "Mark whether this case has parameters passed externally. "
      example: true
      nullable: false

    case_dry_run_flag_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "Mark whether this case has even been DryRun since last edit."
      example: true
      nullable: false

    case_dry_run_ready_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "Indicates whether this case satisfies the DryRun conditions based on data completeness."
      example: true
      nullable: false

    case_dry_run_id_base_string:
      type: string
      description: |
            This value is generated when the system creates a Case DryRun request. It is used for save test case, it contains case meta and dryrun result
            If dry_run_id is null, that means updated successfully, just forward to detail
      pattern: ^case-dry-run-[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
      example: case-dry-run-d4e8a3e0-8e4e-4e7d-9a6a-3e8b7c9d2f1a

    case_executor_base_string:
      type: string
      description: "The executor used by the test script."
      enum:
        - postman
        - playwright
        - pyres
        - python
        - jmeter

    case_sign_base_string:
      $ref: '#/components/schemas/long_text_base_string'
      description: "JWT format String"
      example: "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
      nullable: false

    case_output_base_string:
      $ref: '#/components/schemas/free_long_text_base_string'
      description: "The output of the test case."
      example: "This is the output of the test case."
      nullable: false

    case_file_base_string:
      type: string
      allOf:
        - $ref: '#/components/schemas/binary_base_string'
      description: "the test script in a zip file"
      nullable: false

    case_file_url_base_string:
      $ref: '#/components/schemas/url_base_string'
      description: "The URL of the test script."
      example: "https://www.testany.io/test_script.zip"
      nullable: false

    case_environment_variable_type_base_string:
      type: string
      enum:
        - output
        - env
      description: "The type of the environment variable. `output` is the environment variable which can be relayed to other case in the same pipeline, `env` is the ordinary environment variable for current test case."

    case_environment_variable_base_object:
      type: object
      description: "The environment variable for the test case."
      additionalProperties: false
      properties:
        type:
          $ref: '#/components/schemas/case_environment_variable_type_base_string'
        name:
          $ref: '#/components/schemas/environment_variable_key_base_string'
        value:
          $ref: '#/components/schemas/environment_variable_value_base_string'
        description:
          $ref: '#/components/schemas/environment_variable_description_base_string'
      required:
        - name
        - value

    case_execution_path_base_string:
      $ref: '#/components/schemas/long_text_base_string'
      description: "The execution path of the test case."
      example: "Testany.awesome.succeeded-Meta.postman_collection.json"

    playwright_config_path_base_string:
      $ref: '#/components/schemas/long_text_base_string'
      description: "The playwright config file path of the test case."
      example: "Testany.awesome.succeeded-Meta.playwright_config.js"

    case_execution_command_base_string:
      $ref: '#/components/schemas/long_text_base_string'
      description: "The execution command of the test case."
      example: "python3 awesome_testany.py"
      
    case_import_history_id_base_string:
      type: string
      description: "The id of the import history."
      $ref: '#/components/schemas/uuid_base_string'
      example: "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"
      nullable: false
      
    case_import_history_name_base_string:
      type: string
      description: "The name of the import history."
      $ref: '#/components/schemas/long_text_base_string'
      example: "integration_test in ecommerce_app_test_scripts from Github"
      nullable: false
    
    case_import_history_scm_type_base_string:
      type: string
      description: "The git repository type of the import history."
      enum:
        - github
        - bitbucket

    case_import_history_scm_url_base_string:
      type: string
      description: "The SCM URL of the import history."
      pattern: "^https://(www\\.)?(github\\.com|gitlab\\.com|bitbucket\\.org|dev\\.azure\\.com|([a-zA-Z0-9_.-]+\\.[a-zA-Z0-9_.-]+))/([\\w.-]+)/([\\w.-]+)(\\.git)?(/)?$"
      example: "https://github.com/testany/ecommerce_app_test_scripts"
      nullable: false

    case_import_history_scm_branch_base_string:
      type: string
      description: "The SCM branch of the import history."
      pattern: "^(?!/)(?!.*//)[^\\x00-\\x20~^:?*\\[\\]\\\\@{}]+(?:/[^\\x00-\\x20~^:?*\\[\\]\\\\@{}]+)*$"
      maxLength: 1024
      example: "main"
      nullable: false
    
    case_import_history_scm_commit_id_base_string:
      type: string
      description: "The SCM commit id of the import history."
      pattern: "^[0-9a-fA-F]{40}|[0-9a-fA-F]{64}$"
      example: "a25dba3d7ccbd531611639135fdb04876fd27b6c"
      nullable: false
    
    case_import_history_folder_path_base_string:
      type: string
      description: "The path of the 'root' folder of the import history."
      $ref: '#/components/schemas/long_text_base_string'
      example: "ecommerce_app_test_scripts/integration_test"
      nullable: false
      
    case_version_base_string:
      type: string
      description: "The version of the case."
      $ref: '#/components/schemas/object_label_base_string'
      example: "1.0.0"
      nullable: true
    
    

  # part 1-2-3: user management fields
    user_name_base_string:
      $ref: '#/components/schemas/short_text_base_string'
      description: "user name in the sequence of 'first name, last name (without comma)'"
      example: "John Doe"
      nullable: false
    
    user_email_base_string:
      $ref: '#/components/schemas/email_base_string'
      description: "email address for user"
      example: example.user_email@testany.io
      nullable: false

    user_email_base_array:
      type: array
      maxItems: 100
      items:
        $ref: '#/components/schemas/email_base_string'
      example: ["sample1.user@testany.io", "sample2.user@testany.io"]

    user_uid_base_string:
      $ref: '#/components/schemas/email_base_string'
      description: "unique identifier for user"
      example: example.uid@testany.io
      nullable: false

    user_uid_base_array:
      type: array
      maxItems: 100
      items:
        $ref: '#/components/schemas/user_uid_base_string'
      example: ["sample3.user@testany.io", "sample4.user@testany.io"]

    user_avatar_base_string:
      $ref: '#/components/schemas/url_base_string'
      description: "web address of user avatar"
      example: https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80
      nullable: true

    user_logged_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "whether the user has ever been logged in."
      example: true
      nullable: false

    user_global_admin_flag_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "whether the user is a global admin."
      example: false
      nullable: false

    user_disabled_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "whether the user is disabled."
      example: false
      nullable: false

    user_suspended_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "whether the user is suspended."
      example: false
      nullable: false

    user_status_base_string:
      type: string
      enum:
        - invited
        - active
        - suspended
        - disabled
      example: active

    user_last_login_date_time_base_string:
      $ref: '#/components/schemas/date_time_base_string'
      description: "The last login date and time of the user."
      example: "2024-10-05T10:11:12Z"
      nullable: false

    user_workspace_member_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "whether the user is a member of the workspace."
      example: true
      nullable: false

    user_workspace_member_list_base_array:
      type: array
      maxItems: 100
      items:
        $ref: '#/components/schemas/workspace_key_base_string'
      example: ["WKS", "ABC"]

    user_workspace_admin_base_boolean:
      $ref: '#/components/schemas/boolean_base_boolean'
      description: "whether the user is an admin of the workspace."
      example: false
      nullable: false
      
    user_workspace_admin_list_base_array:
      type: array
      maxItems: 100
      items:
        $ref: '#/components/schemas/workspace_key_base_string'
      example: ["DEM", "XYZ"]

    user_job_title_base_string:
      $ref: '#/components/schemas/short_text_base_string'
      description: "The job title of the user."
      example: "Software Engineer"
      nullable: true

    user_department_base_string:
      $ref: '#/components/schemas/short_text_base_string'
      description: "The department of the user."
      example: "Engineering"
      nullable: true

    user_organization_base_string:
      $ref: '#/components/schemas/short_text_base_string'
      description: "The organization of the user."
      example: "Testany"
      nullable: true

    user_location_base_string:
      $ref: '#/components/schemas/short_text_base_string'
      description: "The location (city) of the user."
      example: "San Francisco"
      nullable: true 

    user_timezone_base_string:
      $ref: '#/components/schemas/timezone_base_string'
      description: "The timezone which the user preferred.  It's IANA time zone identifier, e.g., 'Asia/Shanghai', 'America/New_York'"
      example: "America/Los_Angeles"
      nullable: true

 
  # part 1-2-4: authorization management fields
    action_base_string:
      type: string
      description: "user action for permission check"
      enum:
        - access
        - add
        - add_runtime
        - archive
        - assign_global_admin
        - assign_owner
        - assign_workspace_owner
        - create
        - create_credential
        - create_credential_safe
        - create_gatekeeper
        - create_keyvault
        - create_label
        - create_pipeline
        - create_plan
        - disable
        - delete
        - delete_credential
        - edit
        - edit_credential
        - edit_follower_list
        - edit_group_receiver
        - edit_individual_receiver
        - edit_label
        - edit_notification_method_status
        - edit_notification_rule
        - edit_runtime_status
        - edit_watcher_list
        - edit_webhook_receiver
        - follow
        - grant_access
        - grant_workspace_access
        - list
        - list_all
        - list_case
        - list_credential
        - list_credential_safe
        - list_gatekeeper
        - list_group_receiver
        - list_individual_receiver
        - list_label
        - list_notification_method
        - list_notification_rule
        - list_pipeline
        - list_plan
        - list_webhook_receiver
        - list_user
        - manual_trigger_execution
        - read
        - read_case
        - read_credential
        - read_pipeline_execution_detail
        - read_settings
        - request_access
        - revoke_access
        - revoke_workspace_access
        - suspend
        - watch
      example: create

    resource_type_base_string:
      type: string
      description: "resource type for permission check"
      enum:
        - case
        - credential_safe
        - gatekeeper
        - pipeline
        - plan
        - tenant_as_resource
        - user_as_resource
        - workspace
      example: case

    resource_key_base_string:
      type: string
      description: "resource key for permission check"
      pattern: ^(?:[A-Z][A-Z0-9]{2}|[0-9A-F]{8}|[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}|[MGP]-[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}|[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}-[0-9A-F]{5}|[MGP]-[A-Z][A-Z0-9]{2}-[0-9A-F]{4,5}-[0-9A-F]{5}|[A-Z][A-Z0-9]{2}-CS-[0-9A-F]{4})$
       # 将workspace, case, pipeline, plan/gatekeeper, pipeline execution, plan/gatekeeper/manual execution, credential safe 的正则用 | 符号连起来。
      example: WKS-AB123-CD456

    permission_sign_request_base_string:
      type: string
      allOf:
        - $ref: '#/components/schemas/free_long_text_base_string'
      format: JSON
      pattern: ^[^\u0000-\u001F]*$
      description: "A JSON string that contains the payload(s) need to be signed."
      example: "{\"data1\":\"1111\",\"data2\":\"2222\"}"

    permission_sign_response_base_string:
      type: string
      format: JSON
      $ref: '#/components/schemas/base64_base_string'
      description: "The signature of the payload(s) need to be signed."
      example: "dGVzdGFueQ=="

  # part 1-2-5 Runtime Management fields
    runtime_uuid_base_string:
      $ref: '#/components/schemas/uuid_base_string'
      description: "The uuid of the runtime which the case belongs to."
      example: "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"
      nullable: false

    runtime_name_base_string:
      $ref: '#/components/schemas/object_name_base_string'
      description: "name for runtime"
      example: "CloudPrime-Default"
      nullable: false
      

  # part 1-2-6 Tenant Management fields

    org_domain_prefix_base_string:
      $ref: "#/components/schemas/short_text_base_string"
      description: "The prefix of the organization domain."
      example: "testany-demo"
      nullable: false

    tenant_uuid_base_string:
      $ref: '#/components/schemas/uuid_base_string'
      description: "uuid for tenant"
      example: "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"
      nullable: false

    tenant_label_base_string:
      $ref: '#/components/schemas/object_label_base_string'
      description: "label for tenant"
      example: "Hello_World"
      nullable: false
    
    tenant_labels_base_array:
      $ref: '#/components/schemas/object_labels_base_array'
      description: "labels for tenant"
      example: ["Hello_World", "Testany"]
      nullable: false

    tenant_timezone_base_string:
      $ref: '#/components/schemas/timezone_base_string'
      description: "timezone for the whole tenant, it's managed by tenant global admins."
      example: "America/Los_Angeles"
      nullable: false

    tenant_deployment_type_base_integer:
      type: integer
      enum:
        - 1
        - 2
      description: |
        1: Single-Tenant Instance
        2: Multi-Tenant instance
      example: 1
    
    tenant_payment_method_base_integer:
      type: integer
      enum:
        - 1
        - 2
      description: |
        1: Prepaid
        2: Postpaid
      example: 1
    
    tenant_credit_topup_base_integer:
      allOf:
        - $ref: '#/components/schemas/count_base_integer'
      description: "The credit topup for the tenant."
      minimum: 1

    tenant_grace_credit_base_integer:
      type: integer
      description: "The grace credit for the tenant."
      $ref: '#/components/schemas/count_base_integer'
      minimum: 0

    tenant_credit_balance_base_integer:
      type: integer
      description: "The remaining credit for the tenant."
      $ref: '#/components/schemas/count_base_integer'
      minimum: 0

    tenant_time_to_depletion_base_integer:
      type: integer
      description: "The time to depletion for the tenant."
      $ref: '#/components/schemas/count_base_integer'
      minimum: 0



  # part 1-2-7 Notification Gateway fields
    ng_method_id_base_string:
      type: string
      description: "The identifiler of the notification method."
      $ref: '#/components/schemas/short_text_base_string'
      enum:
        - email
        - webex_webhook
        - ms_teams_webhook
        - generic_webhook
      nullable: false
      example: "email"

    ng_method_name_base_string:
      type: string
      description: "The display name of the notification method."
      $ref: '#/components/schemas/short_text_base_string'
      enum:
        - E-mail
        - Cisco Webex Webhook
        - Microsoft Teams Webhook
        - Generic Webhook
      nullable: false
      example: "E-mail"

    ng_receiver_uuid_base_string:
      $ref: '#/components/schemas/uuid_base_string'
      description: "The uuid of the receiver."
      example: "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"
      nullable: false

    ng_receiver_name_base_string:
      type: string
      description: "The display name of the receiver."
      $ref: '#/components/schemas/short_text_base_string'
      nullable: false
      example: "John Doe"

    ng_workspace_key_base_string:
      type: string
      description: "The key of the workspace the receiver (group / webhook) belongs to."
      $ref: '#/components/schemas/workspace_key_base_string'
      nullable: false
      example: "ABC"
    
    ng_user_uid_base_string:
      $ref: '#/components/schemas/user_uid_base_string'
      description: "The uid of the user in Notification Gateway Service."
      example: "john.doe@testany.io"
      nullable: false

    ng_receiver_target_base_string:
      type: string
      description: "The address (email / webhook url) of the receiver."
      pattern: ^(https?:\/\/[a-zA-Z0-9.-]+(?:\/[a-zA-Z0-9._-]+)*|[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$
      maxLength: 10000
      oneOf:
        - $ref: '#/components/schemas/ng_user_uid_base_string'
        - $ref: '#/components/schemas/url_base_string'

    ng_receiver_link_base_string:
      type: string
      description: "The link of the (group) receiver.  e.g. MS Team Channel address. Please note this address is NOT the webhook URL."
      $ref: '#/components/schemas/url_base_string'
      nullable: false

    ng_rules_uuid_base_string:
      type: string
      description: "The rules of a notification receiver applies to."
      $ref: '#/components/schemas/uuid_base_string'
      nullable: false
    
    ng_rules_uuid_base_array:
      type: array
      maxItems: 10000
      items:
        $ref: '#/components/schemas/ng_rules_uuid_base_string'
      example: ["e7b8a9a4-45f7-4c63-bf08-c6bb85963745", "6bxxfxxx-2xx1-4xx1-bxx0-dx3xxxxexxx7"]

    ng_resource_type_base_string:
      type: string
      description: "The resource type for the specific notification."
      $ref: '#/components/schemas/trigger_method_type_base_string'

    ng_resource_key_base_string:
      type: string
      description: "The resource key for the specific notification."
      $ref: '#/components/schemas/trigger_method_object_key_base_string'
      

  # part 1-2-8 Partner Management fields, include partner_type , partner_key, partner_uid, partner_name, email, phone, status, metadata, contract_start_date, contract_end_date, workspace_referral_protection_end_date, workspace_referral_period_length, active_referred_workspaces, total_referred_workspaces, created_at_date, updated_at_date
    partner_type_base_string: #Partner 类型（目前只有 11 = Priority KOL, 12 = Standard KOL）
      type: integer
      description: "The type of the partner. `11` means Priority KOL, `12` means Standard KOL."
      enum:
        - 11
        - 12
      example: 11

    partner_key_base_string: #Partner 对外唯一标识符（8位，只允许大写字母和数字，global admin 首次创建partner记录时填写，不可更改，不可重复）。  
      type: string
      description: "The key of the partner."
      pattern: ^[A-Z0-9]{8}$
      minLength: 8
      maxLength: 8
      example: "ABC12345"

    partner_referral_id_base_string:
      $ref: '#/components/schemas/partner_key_base_string'

    partner_uid_base_string: #Testany平台用户，关联到 UMS 的用户唯一标识符，缺省值等于 email。  
      allOf:
        - $ref: '#/components/schemas/user_uid_base_string'
      description: "The uid of the partner."
      example: "sample5.partner@testany.io"

    partner_name_base_string: #Partner 的名称或法人名称。  
      allOf:
        - $ref: '#/components/schemas/short_text_base_string'
      description: "The name of the partner."
      example: "Testany Partner"

    partner_email_base_string: #Partner 的联系邮箱。
      allOf:
        - $ref: '#/components/schemas/email_base_string'
      description: "The email of the partner."
      example: "sample6.partner@testany.io"

    partner_phone_base_string: #Partner 的联系电话。
      allOf:
        - $ref: '#/components/schemas/phone_base_string'
      description: "The phone of the partner. the format is area code + phone number. e.g. +11234567890 or +8612345678901"
      example: "+11234567890"

    partner_status_base_string: #Partner 的状态。
      type: string
      allOf:
        - $ref: '#/components/schemas/user_status_base_string'
      description: "The status of the partner."
      enum:
        - "active"
        - "suspended"
        - "disabled"
      example: "active"

    partner_metadata_base_string: #Partner 的元数据。
      allOf:
        - $ref: '#/components/schemas/free_long_text_base_string'
      description: "The metadata of the partner."
      example: "This is the metadata of the partner."

    partner_contract_start_date_base_string: #合作合同开始日期。
      allOf:
        - $ref: '#/components/schemas/date_base_string'
      description: "The start date of the contract."
      example: "2024-10-05"

    partner_contract_expiration_date_base_string: #合作合同结束日期。
      allOf:
        - $ref: '#/components/schemas/date_base_string'
      description: "The end date of the contract."
      example: "2026-10-04"

    partner_workspace_referral_protection_end_date_base_string: #推荐保护期结束日期（缺省为 contract_start_date + 90 天），具体参照协议附件“意向书”中的“先登激励”条款规定。 
      allOf:
        - $ref: '#/components/schemas/date_base_string'
      description: "The end date of the workspace referral protection."
      example: "2025-01-04"

    partner_workspace_referral_period_length_base_integer: #描述该KOL在签约时，签署的“先登激励”条款能享受的激励时长。缺省值为730天。
      type: integer
      format: int32
      description: "The length of the workspace referral period."
      minimum: 0
      maximum: 3650
      example: 730
      nullable: false

    partner_active_referred_workspaces_base_array:   #当前有效的通过此 KOL 推荐的工作区 key，数组。
      type: array
      description: "The keys of the active referred workspaces by the partner."
      maxItems: 10000
      items:
        $ref: '#/components/schemas/workspace_key_base_string'
      example: ["WKS", "Y2K"]

    partner_total_referred_workspaces_base_array: #所有通过此 KOL 推荐的工作区 key（包括已过保护期的），数组。  
      type: array
      description: "The keys of the total referred workspaces by the partner."
      maxItems: 10000
      items:
        $ref: '#/components/schemas/workspace_key_base_string'
      example: ["WKS", "Y2K"]

    partner_created_at_date_base_string: #记录创建时间。
      allOf:
        - $ref: '#/components/schemas/date_time_base_string'
      description: "The created date of the partner."
      example: "2024-10-05T10:11:12Z"

    partner_updated_at_date_base_string: #记录更新时间。
      allOf:
        - $ref: '#/components/schemas/date_time_base_string'
      description: "The updated date of the partner."
      example: "2024-10-05T10:11:12Z"



# part 1-2-9 Directory view management fields
    directory_structure_key_base_string:
      type: string
      pattern: ^DS-[0-9A-Fa-f]{5}$
      minLength: 8
      maxLength: 8
      description: "The key of the directory structure."
      example: "DS-12345"

    directory_structure_name_base_string:
      type: string
      description: "The name of the directory structure."
      $ref: '#/components/schemas/object_name_base_string'
      example: "Testany Directory"

    directory_structure_description_base_string:
      type: string
      description: "The description of the directory structure."
      $ref: '#/components/schemas/object_description_base_string'
      example: "This is the directory structure for Testany."
    
    directory_structure_owner_base_string:
      type: string
      description: "The owner of the directory structure."
      $ref: '#/components/schemas/user_uid_base_string'
      example: "john.doe@testany.io"
    
    directory_structure_subscribers_base_array:
      type: array
      description: "The subscribers of the directory structure."
      maxItems: 10000
      items:
        $ref: '#/components/schemas/user_uid_base_string'
      example: ["john.doe@testany.io", "jane.doe@testany.io"]

    directory_structure_is_private_base_boolean:
      type: boolean
      description: "Whether the directory structure is NOT listed for search and subscription."
      example: true

    directory_structure_created_at_date_base_string:
      type: string
      description: "The created date of the directory structure."
      $ref: '#/components/schemas/date_time_base_string'
      example: "2024-10-05T10:11:12Z"

    directory_structure_updated_at_date_base_string:
      type: string
      description: "The updated date of the directory structure."
      $ref: '#/components/schemas/date_time_base_string'
      example: "2024-10-05T10:11:12Z"
    
    directory_key_base_string:
      type: string
      description: "The key of the directory."
      $ref: '#/components/schemas/object_label_base_string'
      minLength: 1
      example: "Testany-Directory"

    directory_name_base_string:
      type: string
      description: "The name of the directory."
      $ref: '#/components/schemas/object_label_base_string'
      example: "Testany-Directory"

    directory_order_base_integer:
      type: integer
      description: "The order of the directory."
      minimum: 1
      maximum: 1000000
      example: 1

      
      
      










##################################
# Resource-level field schema
# 以下根据每个Resource (tag)的不同情况从 "Globally applicable field schema" 中取出对应的字段进行包装或拼装
# 下列properties的引用没有业务意义，只是为了方便跳转查看。
    Bookmarks_for_Resource_level_Schemas:
      allOf:
        - $ref: '#/components/schemas/bookmark_for_authorization_management_section'
        - $ref: '#/components/schemas/bookmark_for_workspace_management_section'
        - $ref: '#/components/schemas/bookmark_for_case_management_section'
        - $ref: '#/components/schemas/bookmark_for_pipeline_management_section'
        - $ref: '#/components/schemas/bookmark_for_gatekeeper_management_section'
        - $ref: '#/components/schemas/bookmark_for_user_management_section'
        - $ref: '#/components/schemas/bookmark_for_plan_management_section'
        - $ref: '#/components/schemas/bookmark_for_execution_management_section'
        - $ref: '#/components/schemas/bookmark_for_tenant_management_section'
        - $ref: '#/components/schemas/bookmark_for_metering_query_section'
        - $ref: '#/components/schemas/bookmark_for_TSSM_and_TSS_section'
        - $ref: '#/components/schemas/bookmark_for_Directory_View_Management_section'
# 本部分包括了string, integer, object, array 类型，不包括 boolean 和format: binary 类型
# 强烈建议本部分的field都写上specific的example，用来覆盖从Part 1部分继承的example
##################################
  # Authorization Management
    bookmark_for_authorization_management_section:
      type: string
      # The bookmark for user management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    permission_check_object:
      type: object
      additionalProperties: true
      properties:
        action:
          $ref: '#/components/schemas/action_base_string'
        resource_type:
          $ref: '#/components/schemas/resource_type_base_string'
        resource_key:
          $ref: '#/components/schemas/resource_key_base_string'
      required:
        - action
        - resource_type
        - resource_key

    sign_for_TSSM_permission_check_object:
      type: object
      additionalProperties: false
      oneOf:
        - properties:
            workspace_key:
              $ref: '#/components/schemas/workspace_key_base_string'
          required: 
            - workspace_key
        - properties:
            credentialsafe_key:
              $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
          required:
            - credentialsafe_key
        - properties:
            case_key:
              $ref: '#/components/schemas/unit_layer_object_key_base_string'
          required:
            - case_key
        - properties:
            secure_uuid:
              $ref: '#/components/schemas/uuid_base_string'
          required:
            - secure_uuid
    
    permission_internal_check_object:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/permission_check_object'  # 引用 permission_check_object 包含 action, resource_type, resource_key
        - type: object
          properties:
            user_uid:
              $ref: '#/components/schemas/user_uid_base_string'
          required:
            - user_uid

  # Workspace
    bookmark_for_workspace_management_section:
      type: string
      # The bookmark for user management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    WorkspaceBaseInfo:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/workspace_key_base_string'
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My First Workspace"
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is where your tests automated."
      required:
        - key
        - name

    WorkspaceForList:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/WorkspaceBaseInfo'
        - type: object
          additionalProperties: true
          properties:
            status:
              $ref: '#/components/schemas/object_status_code_base_integer'

    WorkspaceDetail:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/WorkspaceBaseInfo' # include key, name, description
        - type: object
          additionalProperties: false
          properties:
            workspace_admin:
              $ref: '#/components/schemas/user_uid_base_array'
            status:
              $ref: '#/components/schemas/object_status_code_base_integer'
      anyOf:
        - title: "Referred Workspace"
          properties:
            is_referred:
              type: boolean
              enum: [true]
            referral_id:
              $ref: '#/components/schemas/referral_id_base_string'
            referral_start_date:
              $ref: '#/components/schemas/workspace_referral_start_date'
            referral_end_date:
              $ref: '#/components/schemas/workspace_referral_end_date'
        - title: "Non-referred Workspace"
          properties:
            is_referred:
              type: boolean
              enum: [false]

    WorkspaceForUpdate:
      type: object
      additionalProperties: false
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My First Workspace"
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is where your tests automated."

    WorksapceExecutionStatus:
      type: object
      additionalProperties: false
      properties:
        claimed:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/pipeline_execution_key_base_string'
        limit:
          type: integer
          format: int32
          example: 1
        pending:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/pipeline_execution_key_base_string'
            
  
  # Case
    bookmark_for_case_management_section:
      type: string
      # The bookmark for case management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    CaseSharedFields:
      type: object
      additionalProperties: false
      required:
        - name
        - runtime_uuid
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My First Test Case"
        description:
          allOf: 
            -  $ref: '#/components/schemas/object_description_base_string'
          example: "This is a test case for the first time."
        runtime_uuid:
          allOf: 
            -  $ref: '#/components/schemas/runtime_uuid_base_string'
          example: "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"
        is_private:
          allOf: 
            -  $ref: '#/components/schemas/is_private_base_boolean'
          example: true
      anyOf:
        - title: "Private Case"
          type: object
          additionalProperties: false
          properties:
            is_private:
              type: boolean
              enum: [true]
            workspace_keys:
              type: array
              minItems: 1
              maxItems: 100
              items: 
                  type: string
                  description: "The key of the workspace the case associated with.Must be exactly 3 characters long, starting with an uppercase letter (A-Z), followed by two alphanumeric characters (A-Z, 0-9)."
                  example: "ABC"
                  pattern: ^[A-Z][A-Z0-9]{2}$
              description: "Required when `is_private` is `true`. Should not be included when `is_private` is `false."
              example: ["Y2K", "ABC"]
          required: 
            - is_private
            - workspace_keys
        - title: "Public Case"
          type: object
          additionalProperties: false
          properties:
            is_private:
              type: boolean
              enum: [false]
          required: 
            - is_private

#        workspace_keys:
#          allOf: 
#            -  $ref: '#/components/schemas/workspace_key_base_array'
#          description: "Required when `is_private` is `true`. Should not be included when `is_private` is `false`."
#          example: ["Y2K", "ABC"]
#      required: 
#        - name
#        - runtime_uuid
#        - is_private
            

            
          
#    CaseForCreate:
#      type: object
#      additionalProperties: false
#      properties:
#        name:
#          allOf:    
#            - $ref: '#/components/schemas/object_name_base_string'
#          example: "My First Test Case"
#        description:
#          allOf:
#            - $ref: '#/components/schemas/object_description_base_string'
#          example: "This is a test case for the first time."
#        dry_run_key:
#          allOf:    
#            - $ref: '#/components/schemas/uuid_base_string'
#          description: "The key for a DryRun execution of a particular test case. This value is generated when the system performs a DryRun."#

#    CaseOptResponse:
#      type: object
#      additionalProperties: false
#      properties:
#        key:
#          allOf:
#            - $ref: '#/components/schemas/unit_layer_object_key_base_string'
#          example: "A1B2C3D4"
#          description: "The key of the test case."
#        name:
#          allOf:
#            - $ref: '#/components/schemas/object_name_base_string'
#          example: "My First Test Case"
#          description: "The name of the test case."
#        description:
#          allOf:
#            - $ref: '#/components/schemas/object_description_base_string'
#          example: "This is a test case for the first time."
#          description: "The description of the test case."

#    CaseForValidate:
#      type: object
#      additionalProperties: true
#      properties:
#        name:
#          allOf:
#            - $ref: '#/components/schemas/object_name_base_string'
#          description: "The name of the test case."
#        description:
#          allOf:
#            - $ref: '#/components/schemas/object_description_base_string'
#          description: "The description of the test case."
#        file:
#          allOf:
#            - $ref: '#/components/schemas/case_file_base_string'
#          description: "The test script(s) packed in a zip file."#

#    CaseForValidateV2:
#      type: object
#      additionalProperties: true
#      allOf:
#        - $ref: '#/components/schemas/CaseForValidateUpdateV2' # include name, description, file, meta
#        - type: object
#          properties:
#            runtime_uuid:
#              allOf:
#                - $ref: '#/components/schemas/runtime_uuid_base_string'
#              description: "The uuid of the runtime which the case belongs to."
#              example: "e7b8a9a4-45f7-4c63-bf08-c6bb85963745"#

#    CaseForValidateUpdateV2:
#      type: object
#      additionalProperties: true
#      allOf:
#        - $ref: '#/components/schemas/CaseForValidate' # include name, description, file
#        - type: object
#          properties:
#            meta:
#              allOf:
#                - $ref: '#/components/schemas/case_meta_base_string'
#              description: "A JSON string that contains meta information about the test case configuration."

    CaseForMyList:
      type: object
      additionalProperties: true
      properties:
        key:
          allOf:
            - $ref: '#/components/schemas/unit_layer_object_key_base_string'
          example: "A1B2C3D4"
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My First Test Case"
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is a test case for the first time."
        environments:
          allOf:
            - $ref: '#/components/schemas/object_environments_base_array'
          example: ["QA", "Staging"]

    CaseForList:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/CaseForMyList'  # include key, name, description, environments
        - type: object
          additionalProperties: true
          properties:
            pipeline_number:          
              type: integer
              format: int64
              example: 8
              description: "The number of pipelines that use this case."
            runtime_uuid:
              $ref: '#/components/schemas/runtime_uuid_base_string'
            runtime_name:
              $ref: '#/components/schemas/runtime_name_base_string'
            relay_flag:
              $ref: '#/components/schemas/case_relay_flag_base_boolean'
            owned_by:
              $ref: '#/components/schemas/object_owner_base_string'
            creator:
                $ref: '#/components/schemas/object_creator_base_string'
            case_labels:
              $ref: '#/components/schemas/object_labels_base_array'
            case_version:
              $ref: '#/components/schemas/object_label_base_string'
            case_meta:
              type: object
              additionalProperties: true
              properties:
                environment_variables:
                  type: array
                  maxItems: 1000
                  items:
                    $ref: '#/components/schemas/case_environment_variable_base_object'
            created_at:
              $ref: '#/components/schemas/date_base_string'
            updated_at:
              $ref: '#/components/schemas/date_base_string'
            from_git:
              $ref: '#/components/schemas/boolean_base_boolean'
            locked:
              $ref: '#/components/schemas/boolean_base_boolean'
            script_url:
              $ref: '#/components/schemas/url_base_string'

    CaseDryRunID:
      type: object
      additionalProperties: false
      properties:
        dry_run_id:
          $ref: '#/components/schemas/case_dry_run_id_base_string'
          description: |
            This value is generated when the system creates a Case DryRun request. It is used for save test case, it contains case meta and dryrun result
            If dry_run_id is null, that means updated successfully, just forward to detail


    CaseForUpdate:
      type: object
      additionalProperties: false
      properties:  
        name:
          $ref: '#/components/schemas/object_name_base_string'
        description:
          $ref: '#/components/schemas/object_description_base_string'
        owned_by:
          $ref: '#/components/schemas/object_owner_base_string'
        environments:
          $ref: '#/components/schemas/object_environments_base_array'
        case_meta:
          $ref: '#/components/schemas/CaseMeta'
        case_labels:
          $ref: '#/components/schemas/object_labels_base_array'
        case_version:
          $ref: '#/components/schemas/object_label_base_string'
        is_private:
          allOf: 
            -  $ref: '#/components/schemas/is_private_base_boolean'
          example: true
      anyOf:
        - title: "Private Case"
          type: object
          additionalProperties: false
          properties:
            is_private:
              type: boolean
              enum: [true]
            workspace_keys:
              type: array
              minItems: 1
              maxItems: 100
              items: 
                  type: string
                  description: "The key of the workspace the case associated with.Must be exactly 3 characters long, starting with an uppercase letter (A-Z), followed by two alphanumeric characters (A-Z, 0-9)."
                  example: "ABC"
                  pattern: ^[A-Z][A-Z0-9]{2}$
              description: "Required when `is_private` is `true`. Should not be included when `is_private` is `false."
              example: ["Y2K", "ABC"]
        - title: "Public Case"
          type: object
          additionalProperties: false
          properties:
            is_private:
              type: boolean
              enum: [false]

    CaseMeta:
      type: object
      additionalProperties: false
      properties:
        environment_variables:
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/case_environment_variable_base_object'
        trigger_method:
          type: object
          additionalProperties: false
          discriminator:
            propertyName: executor
            mapping:
              postman: '#/components/schemas/CaseExecutorIsPostman'
              python: '#/components/schemas/CaseExecutorIsPython'
              pyres: '#/components/schemas/CaseExecutorIsPyRes'
              playwright: '#/components/schemas/CaseExecutorIsPlaywright'
              jmeter: '#/components/schemas/CaseExecutorIsJMeter'
          anyOf:
            - $ref: '#/components/schemas/CaseExecutorIsPostman'
            - $ref: '#/components/schemas/CaseExecutorIsPython'
            - $ref: '#/components/schemas/CaseExecutorIsPyRes'
            - $ref: '#/components/schemas/CaseExecutorIsPlaywright'
            - $ref: '#/components/schemas/CaseExecutorIsJMeter'

    CaseExecutorIsPostman:
      type: object
      additionalProperties: false
      properties:
        executor:
          type: string
          enum:
            - postman
          example: "postman"
        trigger_path:
          allOf:
            - $ref: '#/components/schemas/case_execution_path_base_string'
          example: "Testany.awesome.succeeded-Meta.postman_collection.json"
      required:
        - executor

    CaseExecutorIsPython:
      type: object
      additionalProperties: false
      properties:
        executor:
          type: string
          enum:
            - python
          example: "python"
        trigger_command:
          allOf:
            - $ref: '#/components/schemas/case_execution_command_base_string'
          example: "python3 awesome_testany.py"
      required:
        - executor

    CaseExecutorIsPyRes:
      type: object
      additionalProperties: false
      properties:
        executor:
          type: string
          enum:
            - pyres
          example: "pyres"
        trigger_command:
          allOf:
            - $ref: '#/components/schemas/case_execution_command_base_string'
          example: "python3 awesome_testany.py"
      required:
        - executor

    CaseExecutorIsPlaywright:
      type: object
      additionalProperties: false
      properties:
        executor:
          type: string
          enum:
            - playwright
          example: "playwright"
        trigger_path:
          allOf:
            - $ref: '#/components/schemas/case_execution_path_base_string'
          example: "Testany.awesome.succeeded-Meta.playwright"
        playwright_config_path:
          allOf:
            - $ref: '#/components/schemas/playwright_config_path_base_string'
          example: "Testany.awesome.succeeded-Meta.playwright_config.js"
      required:
        - executor

    CaseExecutorIsJMeter:
      type: object
      additionalProperties: false
      properties:
        executor:
          type: string
          enum:
            - jmeter
          example: "jmeter"
        trigger_path:
          allOf:
            - $ref: '#/components/schemas/case_execution_path_base_string'
          example: "test-plan.jmx"
      required:
        - executor

    Case:
      allOf:
        - $ref: '#/components/schemas/CaseForMyList'
        - type: object
          properties:
            runtime_uuid:
              $ref: '#/components/schemas/runtime_uuid_base_string'
            runtime_name:
              $ref: '#/components/schemas/runtime_name_base_string'
            relay_flag:
              $ref: '#/components/schemas/case_relay_flag_base_boolean'
            owned_by:
              $ref: '#/components/schemas/object_owner_base_string'
            used_by_workspace_keys:
              $ref: '#/components/schemas/workspace_key_base_array'
            creator:
              $ref: '#/components/schemas/object_creator_base_string' 
            case_labels:
              $ref: '#/components/schemas/object_labels_base_array'
            case_version:
              $ref: '#/components/schemas/object_label_base_string'
            case_meta:
              $ref: '#/components/schemas/CaseMeta'
            created_at:
              $ref: '#/components/schemas/date_base_string'
            updated_at:
              $ref: '#/components/schemas/date_base_string'
            from_git:
              $ref: '#/components/schemas/boolean_base_boolean'
            locked:
              $ref: '#/components/schemas/boolean_base_boolean'
            script_url:
              $ref: '#/components/schemas/url_base_string'
            download_ready:
              $ref: '#/components/schemas/boolean_base_boolean'
            dry_run_ready:
              $ref: '#/components/schemas/case_dry_run_ready_base_boolean'
            dry_run_flag:
              $ref: '#/components/schemas/case_dry_run_flag_base_boolean'
            dry_run_result:
              $ref: '#/components/schemas/CaseResult'
          anyOf:
            - title: "Private Case"
              type: object
              additionalProperties: false
              properties:
                is_private:
                  type: boolean
                  enum: [true]
                workspace_keys:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items: 
                    type: string
                    description: "The key of the workspace the case associated with. Must be exactly 3 characters long, starting with an uppercase letter (A-Z), followed by two alphanumeric characters (A-Z, 0-9)."
                    pattern: ^[A-Z][A-Z0-9]{2}$
                  description: "Required when `is_private` is `true`. Should not be included when `is_private` is `false`."
                  example: ["Y2K", "ABC"]
              required: 
                - is_private
                - workspace_keys
            - title: "Public Case"
              type: object
              additionalProperties: false
              properties:
                is_private:
                  type: boolean
                  enum: [false]
              required:
                - is_private

    

    CaseForDryRun:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/CaseForMyList'  # include key, name, description, environment
        - type: object
          additionalProperties: false
          properties:
            runtime_uuid:
              $ref: '#/components/schemas/runtime_uuid_base_string'
            runtime_name:
              $ref: '#/components/schemas/runtime_name_base_string'
            dry_run_key:
              $ref: '#/components/schemas/uuid_base_string'
            dry_run_result:
              $ref: '#/components/schemas/CaseResult'  # include output, sign, status
            dry_run_status:
              $ref: '#/components/schemas/execution_status_code_base_integer'

    CaseFilter:
      type: object
      additionalProperties: false
      properties:
        id:
          $ref: '#/components/schemas/id_base_integer'
        key:
          $ref: '#/components/schemas/unit_layer_object_key_base_string'
        name:
          $ref: '#/components/schemas/object_name_base_string'

    CaseResult: 
      type: object
      additionalProperties: true
      allOf:
        - type: object
          additionalProperties: true
          properties:
            output:
              allOf:
                - $ref: '#/components/schemas/case_output_base_string'
              example: Get xxxx.com suc
            sign:
              allOf:
                - $ref: '#/components/schemas/case_sign_base_string'
              example: SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
            status:
              $ref: '#/components/schemas/execution_status_code_base_integer'
            steps:
              type: array
              maxItems: 1000
              items:
                type: object
                additionalProperties: false
                properties:
                  name:
                    $ref: '#/components/schemas/long_text_base_string'
                    example: step1
                  duration:
                    $ref: '#/components/schemas/long_text_base_string'
                    example: 181ms
                  status:
                    type: integer
                    format: int64
                    description: |
                      engin_status: "passed" -> 1 Passed engin_status: "failed" -> 2 Failed
                  assertion_results:
                    type: array
                    maxItems: 1000
                    items:
                      type: object
                      additionalProperties: false
                      properties:
                        name:
                          $ref: '#/components/schemas/long_text_base_string'
                          example: status code is 200
                        status:
                          type: integer
                          format: int64
                          description: |
                            engin_status: "passed" -> 1 Passed engin_status: "failed" -> 2 Failed



    CaseForPipelineDryRunExecution:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/CaseForMyList'  # include key, name, description, environment
        - type: object
          additionalProperties: true
          properties:
            runtime_uuid:
              $ref: '#/components/schemas/runtime_uuid_base_string'
            runtime_name:
              $ref: '#/components/schemas/runtime_name_base_string'
            creator:
                $ref: '#/components/schemas/object_creator_base_string'

    CaseForExecution:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/CaseForPipelineDryRunExecution'  # include key, name, description, environment, runtime_uuid, runtime_name, creator
        - type: object
          additionalProperties: false
          properties:
            Status:
              allOf:
                - $ref: '#/components/schemas/execution_status_code_base_integer'
                - type: integer
                  enum:
                    - 0
                    - 1
                    - 2
              description: |
                0: Running
                1: Passed
                2: Failed

    case_import_history_list_full_array:
      type: array
      maxItems: 1000
      items:
        $ref: '#/components/schemas/case_import_history_list_full_object'
    
    case_import_history_list_full_object:
      type: object
      additionalProperties: false
      properties:
        id:
          $ref: '#/components/schemas/case_import_history_id_base_string'
        name:
          $ref: '#/components/schemas/case_import_history_name_base_string'
        created_at:
          $ref: '#/components/schemas/date_base_string'
        updated_at:
          $ref: '#/components/schemas/date_base_string'
        owner:
          $ref: '#/components/schemas/object_owner_base_string'
        scm_type:
          $ref: '#/components/schemas/case_import_history_scm_type_base_string'
        scm_url:
          $ref: '#/components/schemas/case_import_history_scm_url_base_string'
        branch:
          $ref: '#/components/schemas/case_import_history_scm_branch_base_string'
        commit_id:
          $ref: '#/components/schemas/case_import_history_scm_commit_id_base_string'
        runtime_uuid:
          $ref: '#/components/schemas/runtime_uuid_base_string'
        folder_path:
          $ref: '#/components/schemas/case_import_history_folder_path_base_string'
        scm_credential_safe_key:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
        scm_credential_key:
          $ref: '#/components/schemas/tssm_credential_key_base_string'
      required:
        - name
        - scm_type
        - scm_url
        - runtime_uuid
        - folder_path
    
    case_import_history_with_deletion_impact:
      type: object
      description: the import history, plus `deletion_impact` when `include=deletion_impact` is passed
      additionalProperties: false
      properties:
        deletion_impact:
          $ref: '#/components/schemas/case_source_deletion_impact'
        id:
          $ref: '#/components/schemas/case_import_history_id_base_string'
        name:
          $ref: '#/components/schemas/case_import_history_name_base_string'
        created_at:
          $ref: '#/components/schemas/date_base_string'
        updated_at:
          $ref: '#/components/schemas/date_base_string'
        owner:
          $ref: '#/components/schemas/object_owner_base_string'
        scm_type:
          $ref: '#/components/schemas/case_import_history_scm_type_base_string'
        scm_url:
          $ref: '#/components/schemas/case_import_history_scm_url_base_string'
        branch:
          $ref: '#/components/schemas/case_import_history_scm_branch_base_string'
        commit_id:
          $ref: '#/components/schemas/case_import_history_scm_commit_id_base_string'
        runtime_uuid:
          $ref: '#/components/schemas/runtime_uuid_base_string'
        folder_path:
          $ref: '#/components/schemas/case_import_history_folder_path_base_string'
        scm_credential_safe_key:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
        scm_credential_key:
          $ref: '#/components/schemas/tssm_credential_key_base_string'
      required:
        - name
        - scm_type
        - scm_url
        - runtime_uuid
        - folder_path
    
    case_import_history_list_base_array:
      type: array
      maxItems: 1000
      items:
        $ref: '#/components/schemas/case_import_history_list_base_object'
    
    case_import_history_list_base_object:
      type: object
      additionalProperties: false
      properties:
        id:
          $ref: '#/components/schemas/case_import_history_id_base_string'
        name:
          $ref: '#/components/schemas/case_import_history_name_base_string'
        runtime_uuid:
          $ref: '#/components/schemas/runtime_uuid_base_string'
    
    case_import_history_payload_full_array:
      type: array
      maxItems: 10000
      items:
        $ref: '#/components/schemas/case_import_history_payload_full_object'

    case_import_history_payload_full_object:  
      type: object
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/object_name_base_string'
        description:
          $ref: '#/components/schemas/object_description_base_string'
        runtime_uuid:
          $ref: '#/components/schemas/runtime_uuid_base_string'
        script_address:
          type: object
          additionalProperties: false
          properties:
            scm_url:
              $ref: '#/components/schemas/case_import_history_scm_url_base_string'
            branch:
              $ref: '#/components/schemas/case_import_history_scm_branch_base_string'
            commit_id:
              $ref: '#/components/schemas/case_import_history_scm_commit_id_base_string'
            script_name:
              $ref: '#/components/schemas/url_base_string'
            scm_csk:
              type: object
              additionalProperties: false
              properties:
                credential_safe_key:
                  $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
                credential_key:
                  $ref: '#/components/schemas/tssm_credential_key_base_string'
              required:
                - credential_safe_key
                - credential_key
          required:
            - scm_url
            - script_name
            - scm_csk
        case_meta:
            $ref: '#/components/schemas/CaseMeta'
        case_labels:
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/object_label_base_string'
        case_version:
          $ref: '#/components/schemas/object_label_base_string'
        is_private:
          $ref: '#/components/schemas/boolean_base_boolean'
        workspace_keys:
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/workspace_key_base_string'
        credentials:
          type: array
          maxItems: 1000
          items:
            type: object
            additionalProperties: false
            properties:
              credential_safe_key:
                $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
              credential_key:
                $ref: '#/components/schemas/tssm_credential_key_base_string'


  # pipeline
    bookmark_for_pipeline_management_section:
      type: string
      # The bookmark for pipeline management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    PipelineForPlan:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PipelineOptResponse'  # include key, name, description
        - type: object
          additionalProperties: true
          properties:
            environments:
              $ref: '#/components/schemas/object_environments_base_array'

    PipelineForCreate:
      type: object
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/object_name_base_string'
        description:
          $ref: '#/components/schemas/object_description_base_string'
        workspace:
          $ref: '#/components/schemas/workspace_key_base_string'
        dry_run_key:
          $ref: '#/components/schemas/uuid_base_string'
      


    PipelineForCreateV2:
      type: object
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/object_name_base_string'
        description:
          $ref: '#/components/schemas/object_description_base_string'
        workspace:
          $ref: '#/components/schemas/workspace_key_base_string'
      oneOf:
        - properties:
            definition:
              $ref: '#/components/schemas/pipeline_yaml_base_string'
        - properties:
            case_keys:
              type: array
              maxItems: 1000
              items:
                $ref: '#/components/schemas/unit_layer_object_key_base_string'
      required:
        - name
        - workspace


    PipelineOptResponse:
      type: object
      additionalProperties: true
      properties:
        key:
          $ref: '#/components/schemas/pipeline_key_base_string'
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My second Pipeline"
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is the description for my second Pipeline"

    PipelineOptResponseV2:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/pipeline_key_base_string'
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My second Pipeline"
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is the description for my second Pipeline"
        definition:
          $ref: '#/components/schemas/pipeline_yaml_base_string'
        case_keys:
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/unit_layer_object_key_base_string'

    PipelineForValidate:
      type: object
      additionalProperties: false
      properties:
        workspace_key:
          $ref: '#/components/schemas/workspace_key_base_string'
        name:
          $ref: '#/components/schemas/object_name_base_string'
        description:
          $ref: '#/components/schemas/object_description_base_string'
        file:
          $ref: '#/components/schemas/pipeline_yaml_base_string' 
          example: "kind rule/v1.2 ..."

    PipelineDryRunResult:
      type: object
      additionalProperties: false
      properties:
        dry_run_key:
          $ref: '#/components/schemas/uuid_base_string'
          description: Used for save test case, it contains case meta and dryrun result
        name:
          $ref: '#/components/schemas/object_name_base_string'
          example: My second Pipeline
        description:
          $ref: '#/components/schemas/object_description_base_string'
          example: This is the description for my second Pipeline
        environments:
          $ref: '#/components/schemas/object_environments_base_array'
          example: ["Testany-Demo"]
        result:
          $ref: '#/components/schemas/boolean_base_boolean'
          description: |
            true: valid
            false: invalid
        message:
          $ref: '#/components/schemas/free_long_text_base_string'
          example: "meta.json not found"

    PipelineDryRunResultDetail:
      type: object
      additionalProperties: false
      properties:
        dry_run_key:
          $ref: '#/components/schemas/uuid_base_string'
          description: Used for save test case, it contains case meta and dryrun result
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: My second Pipeline
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: This is the description for my second Pipeline
        environments:
          $ref: '#/components/schemas/object_environments_base_array'
          example: ["Testany-Demo"]
        dry_run_result:
          $ref: '#/components/schemas/PipelineDryrunExecutionDetail'        # include svg, cases

    PipelineDryrunExecutionDetail:
      type: object
      additionalProperties: false
      properties:
        svg:
          allOf:
            - $ref: '#/components/schemas/binary_base_string'
          description: "The SVG content of the pipeline."
          example: "<svg>xxxxx</svg>"
        cases:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/CaseForPipelineDryRunExecution'    # include key, name, description, environment, runtime_uuid, runtime_name, creator

    PipelineExecuteResponse:
      type: object
      additionalProperties: false
      properties:
        execution_key:
          $ref: '#/components/schemas/pipeline_execution_key_base_string'

    PipelineDetail:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PipelineForPlan' # include key, name, description, environments
        - type: object
          additionalProperties: true
          properties:
            creator:
              $ref: '#/components/schemas/object_creator_base_string'     
            owned_by:
              $ref: '#/components/schemas/object_owner_base_array'
            dry_run_result:
              $ref: '#/components/schemas/PipelineDryrunExecutionDetail'  # include svg, cases

    PipelineForDetailV2:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/PipelineForPlan' # include key, name, description, environments
        - type: object
          additionalProperties: true
          properties:
            creator:
              $ref: '#/components/schemas/object_creator_base_string'     
            owned_by:
              $ref: '#/components/schemas/object_owner_base_string'
            definition:
              $ref: '#/components/schemas/pipeline_yaml_base_string'
            case_keys:
              type: array
              maxItems: 1000
              items:
                $ref: '#/components/schemas/unit_layer_object_key_base_string'
            pipeline_labels:
              $ref: '#/components/schemas/object_labels_base_array'
            created_at:
              $ref: '#/components/schemas/date_time_base_string'
            updated_at:
              $ref: '#/components/schemas/date_time_base_string'

    PipelineForUpdateV2:
      oneOf:
        - properties:
            definition:
              $ref: '#/components/schemas/pipeline_yaml_base_string'
        - properties:
            case_keys:
              type: array
              maxItems: 1000
              items:
                $ref: '#/components/schemas/unit_layer_object_key_base_string'
      type: object
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/object_name_base_string'
        description:
          $ref: '#/components/schemas/object_description_base_string'
        environments:
          $ref: '#/components/schemas/object_environments_base_array'   
        owned_by:
          $ref: '#/components/schemas/object_owner_base_string'
        pipeline_labels:
          $ref: '#/components/schemas/object_labels_base_array'

    PipelineForDetailInList:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PipelineForPlan' # include key, name, description, environments
        - type: object
          additionalProperties: true
          properties:
            creator:
              $ref: '#/components/schemas/object_creator_base_string'  
              example: "sample.user@testany.io"     

    PipelineForMyList:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PipelineForPlan' # include key, name, description, environments
        - $ref: '#/components/schemas/PipelineLastExecutionWithoutExecutor'  # include start_time, finish_time, status

    PipelineForList:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PipelineForPlan'  # include key, name, description, environments
        - type: object
          additionalProperties: true
          properties:
            creator:
              $ref: '#/components/schemas/object_creator_base_string'  
            owned_by:
              $ref: '#/components/schemas/object_owner_base_array'
            last_execution:
              type: object
              allOf:
                - $ref: '#/components/schemas/PipelineLastExecutionWithoutExecutor'  # include start_time, finish_time, status
                - type: object
                  additionalProperties: false
                  properties:
                    executor:
                      $ref: '#/components/schemas/user_uid_base_string'
                    key:
                      $ref: '#/components/schemas/pipeline_execution_key_base_string'

    PipelineForListV2:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PipelineForPlan'  # include key, name, description, environments
        - type: object
          additionalProperties: true
          properties:
            creator:
              $ref: '#/components/schemas/object_creator_base_string'  
            owned_by:
              $ref: '#/components/schemas/object_owner_base_string'
            last_execution:
              type: object
              allOf:
                - $ref: '#/components/schemas/PipelineLastExecutionWithoutExecutor'  # include start_time, finish_time, status
                - type: object
                  additionalProperties: false
                  properties:
                    executor:
                      $ref: '#/components/schemas/user_uid_base_string'
                    key:
                      $ref: '#/components/schemas/pipeline_execution_key_base_string'

    PipelineForListV3:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/PipelineForPlan'  # include key, name, description, environments
        - type: object
          additionalProperties: false
          properties:
            creator:
              $ref: '#/components/schemas/object_creator_base_string'  
            owned_by:
              $ref: '#/components/schemas/object_owner_base_string'
            last_execution:
              type: object
              allOf:
                - $ref: '#/components/schemas/PipelineLastExecutionWithoutExecutor'  # include start_time, finish_time, status
                - type: object
                  additionalProperties: false
                  properties:
                    executor:
                      $ref: '#/components/schemas/user_uid_base_string'
                    key:
                      $ref: '#/components/schemas/pipeline_execution_key_base_string'
            case_keys:
              type: array
              maxItems: 1000
              items:
                $ref: '#/components/schemas/unit_layer_object_key_base_string'
            pipeline_labels:
              $ref: '#/components/schemas/object_labels_base_array'
            created_at:
              $ref: '#/components/schemas/date_time_base_string'
            updated_at:
              $ref: '#/components/schemas/date_time_base_string'


    PipelineFilter:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/pipeline_key_base_string'
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My second Pipeline"

    PipelineForExecution:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/PipelineOptResponse'  # include key, name, description
        - type: object
          additionalProperties: false
          properties:
            creator:
              $ref: '#/components/schemas/object_creator_base_string'   # boyi, 这里是uid还是User呢？

    PipelineForExecutionV2:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/pipeline_key_base_string'
        name:
          $ref: '#/components/schemas/object_name_base_string'
        owned_by:
          $ref: '#/components/schemas/object_owner_base_array'

    PipelineExecuteByPlan:
      type: object
      additionalProperties: false
      properties:
        plan_key:
          allOf:
            - $ref: '#/components/schemas/trigger_method_object_key_base_string'
          example: "P-WKS-12DE1"
        watchers:
          $ref: '#/components/schemas/object_watcher_base_array'      

    PipelineLastExecutionWithoutExecutor:   # 这是我新加的，因为在PipelineForMyList和PipelineForList中都有用到
      type: object
      additionalProperties: true
      properties:
        start_time:
          $ref: '#/components/schemas/date_time_base_string'
          type: string
        finish_time:
          $ref: '#/components/schemas/date_time_base_string'
          type: string
        status:
          $ref: '#/components/schemas/execution_status_code_base_integer'



  # Gatekeeper
    bookmark_for_gatekeeper_management_section:
      type: string
      # The bookmark for gatekeeper management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    GatekeeperForOptCreate:
      type: object
      additionalProperties: false
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My First Gatekeeper"
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is the description for my first Gatekeeper"
        workspace:
          $ref: '#/components/schemas/workspace_key_base_string'

    GatekeeperForOpt:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/GatekeeperUniversalInfoPack'  # include name, description, labels, trigger_method, trigger_condition, trigger_name, watchers, owned_by
      properties:
        notify_ignore_success:
          $ref: '#/components/schemas/boolean_base_boolean'
          example: true

    GatekeeperCreateResponse:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/trigger_method_object_key_base_string'
          example: "G-WKS-0001"

    GatekeeperForList:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/GatekeeperUniversalInfoPack'  # include name, description, labels, trigger_method, trigger_condition, trigger_name, watchers, owned_by
      properties:
        key:
          $ref: '#/components/schemas/trigger_method_object_key_base_string'
          example: "G-WKS-0001"

    GatekeeperForDetail:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/GatekeeperForList'  # include name, description, labels, trigger_method, trigger_condition, trigger_name, watchers, owned_by
      properties:
        notify_ignore_success:
          $ref: '#/components/schemas/boolean_base_boolean'
          example: true
        hook_url:
          allOf:
            - $ref: '#/components/schemas/url_base_string'
          description: "only owner will return the hook_url field value"
          example: "https://dev.testany.com.cn/api/v2/gatekeeper/webhook/{hook_token}"

    GatekeeperUniversalInfoPack:   # 这是我新加的，因为在GatekeeperForList和GatekeeperForDetail中都有用到
      type: object
      additionalProperties: false
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My First Gatekeeper"
        description:
          allOf:
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is the description for my first Gatekeeper"
        labels:
          $ref: '#/components/schemas/object_labels_base_array'
        trigger_method:
          allOf:
            - $ref: '#/components/schemas/long_text_base_string'
          example: "CICD"
        trigger_condition:
          allOf:
            - $ref: '#/components/schemas/long_text_base_string'
          example: "user login with success status"
        trigger_name:
          allOf:
            - $ref: '#/components/schemas/long_text_base_string'
          example: "user login success"
        watchers:
          $ref: '#/components/schemas/object_watcher_base_array'
        owned_by:
          $ref: '#/components/schemas/object_owner_base_array'






  # user management # #  
    bookmark_for_user_management_section:
      type: string
      # The bookmark for user management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    UserForList:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/UserForFilter'  # include uid, name, email, avatar
      properties:
        logged:
          $ref: '#/components/schemas/user_logged_base_boolean'
        global_admin_flag:
          $ref: '#/components/schemas/user_global_admin_flag_base_boolean'
        disabled:
          $ref: '#/components/schemas/user_disabled_base_boolean'
        suspended:
          $ref: '#/components/schemas/user_suspended_base_boolean'
        status:
          $ref: '#/components/schemas/user_status_base_string'
        last_login:
          $ref: '#/components/schemas/user_last_login_date_time_base_string'
        workspace_member_list:
          $ref: '#/components/schemas/user_workspace_member_list_base_array'
        workspace_admin_list:
          $ref: '#/components/schemas/user_workspace_admin_list_base_array'

    UserForWorkspaceUserList:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/UserForFilter'  # include uid, name, email, avatar
      properties:
        workspace_member:
          $ref: '#/components/schemas/user_workspace_member_base_boolean'
        workspace_admin:
          $ref: '#/components/schemas/user_workspace_admin_base_boolean'

    UserForCreate:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/UserBaseInfoPack'  # include uid, name, email 
        - $ref: '#/components/schemas/UserWorkInfoPack'  # include job_title, department, organization, location


    UserForInvite:
      $ref: '#/components/schemas/user_email_base_array'
      description: "The list of user emails to be invited."

    UserForUpdate:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/UserWorkInfoPack'  # include job_title, department, organization, location
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/user_name_base_string'
          example: "John Doe"

    UserForUpdateAttributes:
      type: object
      additionalProperties: false
      properties:
        global_admin_flag:
          $ref: '#/components/schemas/user_global_admin_flag_base_boolean'
        disabled:
          $ref: '#/components/schemas/user_disabled_base_boolean'
        suspended:
          $ref: '#/components/schemas/user_suspended_base_boolean'
        status_reason:
          $ref: '#/components/schemas/short_text_base_string'
          description: "The reason for the status change."
          example: "quit from company"

    UserForAssignWorkspace:
      $ref: '#/components/schemas/user_uid_base_array'
      description: "The list of user uids to be assigned to the workspace."

    UserForDetail:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/UserForFilter'  # include uid, name, email, avatar
        - $ref: '#/components/schemas/UserWorkInfoPack'  # include job_title, department, organization, location
      properties:
        logged:
          $ref: '#/components/schemas/user_logged_base_boolean'
        global_admin_flag:
          $ref: '#/components/schemas/user_global_admin_flag_base_boolean'
        disabled:
          $ref: '#/components/schemas/user_disabled_base_boolean'
        suspended:
          $ref: '#/components/schemas/user_suspended_base_boolean'
        status_reason:
          $ref: '#/components/schemas/short_text_base_string'
          description: "The reason for the status change."
          example: "quit from company"

    UserForFilter:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/UserBaseInfoPack'  # include uid, name, email
        - type: object
          properties:
            avatar:
              allOf:
                - $ref: '#/components/schemas/user_avatar_base_string'  
              example: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80"

    UserForIdQuery:
      $ref: '#/components/schemas/UserForFilter' # include uid, name, email, avatar

        
        
        
  
      
    SystemUser:
      type: object
      additionalProperties: false
      properties:
        id:          # 注意：这里真的是id，不是uid。因为这个是系统用户，不是普通用户。
          $ref: '#/components/schemas/id_base_integer'
        name:
          $ref: '#/components/schemas/user_name_base_string'
        email:
          $ref: '#/components/schemas/user_email_base_string'

    UserBaseInfoPack:
      type: object
      additionalProperties: true
      properties:
        uid:
          allOf:
            - $ref: '#/components/schemas/user_uid_base_string'
          example: "john.doe@testany.io"
        name:
          allOf:
            - $ref: '#/components/schemas/user_name_base_string'
          example: "John Doe"
        email:
          allOf:
            - $ref: '#/components/schemas/user_email_base_string'
          example: "john.doe@testany.io"
    
    UserWorkInfoPack:
      type: object
      additionalProperties: false
      properties:
        job_title:
          $ref: '#/components/schemas/user_job_title_base_string'
        department:
          $ref: '#/components/schemas/user_department_base_string'
        organization:
          $ref: '#/components/schemas/user_organization_base_string'
        location:
          $ref: '#/components/schemas/user_location_base_string'
        timezone:
          $ref: '#/components/schemas/user_timezone_base_string'

    
  # Plan
    bookmark_for_plan_management_section:
      type: string
      # The bookmark for plan section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    PlanForOptCreate:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PlanForOpt'  # include name, description, schedule_expr, schedule_str, timezone, watchers, pipelines, notify_ignore_success
        - $ref: '#/components/schemas/workspace_key_base_string'

    PlanForOpt:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PlanUniversalInfoPack'  # include name, description, schedule_expr, schedule_str, timezone, watchers
        - type: object
          additionalProperties: true
          properties:
            notify_ignore_success:
              $ref: '#/components/schemas/boolean_base_boolean'
            pipelines:
              $ref: '#/components/schemas/PipelinesArrayforPlanOpt'
    
    PipelinesArrayforPlanOpt:
      type: array
      maxItems: 100
      items:
        type: object
        additionalProperties: false
        properties:
          key:
            $ref: '#/components/schemas/pipeline_key_base_string'
          name:
            $ref: '#/components/schemas/object_name_base_string'
          description:
            $ref: '#/components/schemas/object_description_base_string'
          owned_by:
            $ref: '#/components/schemas/object_owner_base_array'


    PlanCreateResponse:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/trigger_method_object_key_base_string'
          example: "P-WKS-0001"

    PlanForMyList:  # boyi  原来的schema里没有timezone，这里我加上了。你看看对不对。
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PlanUniversalInfoPack'  # include name, description, schedule_expr, schedule_str, timezone, watchers
        - type: object
          additionalProperties: true
          properties:
            key:
              $ref: '#/components/schemas/trigger_method_object_key_base_string'
              example: "P-WKS-0001"

    PlanForList:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PlanUniversalInfoPack'  # include name, description, schedule_expr, schedule_str, timezone, watchers
        - type: object
          additionalProperties: true
          properties:
            key:
              $ref: '#/components/schemas/trigger_method_object_key_base_string'
              example: "P-WKS-0001"
            creator:
              $ref: '#/components/schemas/object_creator_base_string'   

#  另外： 原schema里， PlanForMyList里的watcher是uid组成的数组， 但是PlanForList里的watcher是/schemas/User，两边不一样，我觉得应该是一样的（uid组成的数组）。你看看对不对。

    PlanForDetail:  # boyi  这里比原来的schema多了timezone，你看看对不对。
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PlanForOpt' # include name, description, schedule_expr, schedule_str, timezone, watchers, pipelines, notify_ignore_success
        - type: object
          additionalProperties: true
          properties:
            key:
              $ref: '#/components/schemas/trigger_method_object_key_base_string'
              example: "P-WKS-0001"
            creator:
              $ref: '#/components/schemas/object_creator_base_string'   
            owner_by:
              $ref: '#/components/schemas/object_owner_base_array'

    PlanForExecution:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/trigger_method_object_key_base_string'
        creator:
          $ref: '#/components/schemas/object_creator_base_string'
        watcher:
          $ref: '#/components/schemas/object_watcher_base_array'
            

    PlanUniversalInfoPack:   # boyi  这是我新建的
      type: object
      additionalProperties: true
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My first Plan"
        description:
          allOf: 
            - $ref: '#/components/schemas/object_description_base_string'
          example: "This is the description for my first Plan"
        schedule_expr:
          allOf:
            - $ref: '#/components/schemas/schedule_expr_base_string'
          example: "0 0 * * * ?"
        schedule_str:
          allOf:
            - $ref: '#/components/schemas/schedule_str_base_string'
          example: "Every hour of every Monday"
        timezone:
          allOf:
            - $ref: '#/components/schemas/timezone_base_string'
          example: UTC
        watchers:
          $ref: '#/components/schemas/object_watcher_base_array'
        

  # Execution
    bookmark_for_execution_management_section:
      type: string
      # The bookmark for execution management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #
    ExecutionForListV2:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/pipeline_execution_key_base_string'
        start_time:
          $ref: '#/components/schemas/date_time_base_string'
        finish_time:
          $ref: '#/components/schemas/date_time_base_string'
        environments:
          $ref: '#/components/schemas/object_environments_base_array'
        pipeline:
          $ref: '#/components/schemas/PipelineForExecutionV2'
        status:
          $ref: '#/components/schemas/execution_status_code_base_integer'
        executor_uid:
          $ref: '#/components/schemas/user_uid_base_string'
        trigger_group:
          $ref: '#/components/schemas/trigger_method_object_key_base_string'
          description: |
            if execution triggered by plan, this field value will be P-XXX-XXXX
            if the execution triggered by gatekeeper, this field value will be G-XXX-XXXX
            if the execution triggered by manual, this field will not exist.
        trigger_group_type:
          $ref: '#/components/schemas/trigger_method_type_base_string'
          description: |
            if execution triggered by plan, this field value will be plan
            if the execution triggered by gatekeeper, this field value will be gatekeeper
            if the execution triggered by manual, this field will not exist.
        triggered_by:
          $ref: '#/components/schemas/trigger_method_object_key_base_string'
          description: |
            if execution triggered by plan, this field value will be P-XXX-XXXX
            if the execution triggered by gatekeeper, this field value will be G-XXX-XXXX
            if the execution triggered by manual, this field will not exist.
        triggered_type:
          $ref: '#/components/schemas/trigger_method_type_base_string'
          description: |
            if execution triggered by plan, this field value will be plan
            if the execution triggered by gatekeeper, this field value will be gatekeeper
            if the execution triggered by manual, this field will not exist.
    
    ExecutionForRefresh:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/pipeline_execution_key_base_string'
        svg:
          $ref: '#/components/schemas/binary_base_string'
          description: "The SVG content of the pipeline execution."
          example: "<svg>xxxxx</svg>"
        status:
          $ref: '#/components/schemas/execution_status_code_base_integer'
        cases:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/CaseForExecution'    # include key, name, description, environment, runtime_uuid, runtime_name, creator
        queue:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/WorksapceExecutionStatus'    

    ExecutionDetail:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/pipeline_execution_key_base_string'
        start_time:
          $ref: '#/components/schemas/date_time_base_string'
        finish_time:
          $ref: '#/components/schemas/date_time_base_string'
        svg:
          $ref: '#/components/schemas/binary_base_string'
          description: "The SVG content of the pipeline execution."
          example: "<svg>xxxxx</svg>"
        environments:
          $ref: '#/components/schemas/object_environments_base_array'
        pipeline:
          $ref: '#/components/schemas/PipelineForExecution' #include key, name, description
        status:
          $ref: '#/components/schemas/execution_status_code_base_integer'
        planned_by:
          $ref: '#/components/schemas/PlanForExecution' # include key, name, description
        executor:
          $ref: '#/components/schemas/SystemUser'
        cases:
          type: array
          maxItems: 100
          items:
            $ref: '#/components/schemas/CaseForExecution'    # include key, name, description, environment, runtime_uuid, runtime_name, creator



  # Metering Query # #
    bookmark_for_metering_query_section:
      type: string
      # The bookmark for metering query section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #

    AssetsMeteringResponse:
      type: object
      additionalProperties: false
      properties:
        case_count:
          $ref: '#/components/schemas/count_base_integer'
        gatekeeper_count:
          $ref: '#/components/schemas/count_base_integer'
        member_count:
          $ref: '#/components/schemas/count_base_integer'
        pipeline_count:
          $ref: '#/components/schemas/count_base_integer'
        plan_count:
          $ref: '#/components/schemas/count_base_integer'
        tee_limit_count:
          $ref: '#/components/schemas/count_base_integer'
        workspace_count:
          $ref: '#/components/schemas/count_base_integer'
        workspace_key:
          $ref: '#/components/schemas/workspace_key_base_string'

        
   
    UsageMeteringResponse:
      type: object
      additionalProperties: false
      properties:
        workspace_key:
          $ref: '#/components/schemas/workspace_key_base_string'
        case_execution_count:
          $ref: '#/components/schemas/count_base_integer'
        pipeline_execution_count:
          $ref: '#/components/schemas/count_base_integer'
        plan_execution_count:
          $ref: '#/components/schemas/count_base_integer'
        gatekeeper_execution_count:
          $ref: '#/components/schemas/count_base_integer'
        manual_execution_count:
          $ref: '#/components/schemas/count_base_integer'
        
        



  # Tenant Management # #
    bookmark_for_tenant_management_section:
      type: string
      # The bookmark for tenant management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #    
    TenantDetailInfo:
      type: object
      additionalProperties: false
      properties:
        uuid:
          $ref: '#/components/schemas/uuid_base_string'
        org_name:
          allOf:
            - $ref: '#/components/schemas/short_text_base_string'
          example: "MyTenant"
        org_domain_prefix:
          allOf:
            - $ref: '#/components/schemas/short_text_base_string'
          example: "mytenant"
        wide_logo:
          allOf:
            - $ref: '#/components/schemas/url_base_string'
          example: "https://dev.testany.com.cn/static/images/wide_logo.png"
        square_logo:
          allOf:
            - $ref: '#/components/schemas/url_base_string'
          example: "https://dev.testany.com.cn/static/images/square_logo.png"
        timezone:
          allOf:
            - $ref: '#/components/schemas/tenant_timezone_base_string'
          example: "Asia/Shanghai"
        deployment_type:
          allOf: 
            -  $ref: "#/components/schemas/tenant_deployment_type_base_integer"
          example: 1
        payment_method:
          allOf: 
            -  $ref: "#/components/schemas/tenant_payment_method_base_integer"
          example: 1

    TenantBaseInfoPack:
      type: object
      additionalProperties: false
      properties:
        org_name:
          $ref: '#/components/schemas/short_text_base_string'
        wide_logo:
          allOf: 
            - $ref: '#/components/schemas/binary_base_string'
            - description: "The wide logo of the tenant. Upload a JPG or PNG file with a maximum size of 1MB. Recommend size: 800x200px."
        square_logo:
          allOf: 
            -  $ref: '#/components/schemas/binary_base_string'
            - description: "The square logo of the tenant. Upload a JPG or PNG file with a maximum size of 1MB. Recommend size: 200x200px."
        timezone: 
          $ref: '#/components/schemas/tenant_timezone_base_string'

    TenantUsageResponse:
      type: object
      additionalProperties: false
      properties:
        org_name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "Testany-Sample-Tenant"
        deployment_type:
          $ref: '#/components/schemas/tenant_deployment_type_base_integer'
        payment_method:
          $ref: '#/components/schemas/tenant_payment_method_base_integer'
        grace_credit_balance:
          $ref: '#/components/schemas/tenant_grace_credit_base_integer'
        credit_balance:
          $ref: '#/components/schemas/tenant_credit_balance_base_integer'
        time_to_depletion:
          $ref: '#/components/schemas/tenant_time_to_depletion_base_integer'

    TenantInvoiceBaseInfo:
      type: object
      additionalProperties: true
      properties:
        topup_amount:
          allOf:
            - $ref: '#/components/schemas/tenant_credit_topup_base_integer'
          description: "The amount of pipeline execution tims to be added to the tenant's balance."
          example: 50000
        po_number:
          allOf:
            - $ref: '#/components/schemas/free_short_text_base_string'
          example: "PO-2021-0001"
        grace_credit_amount:
          allOf:
            - $ref: '#/components/schemas/tenant_grace_credit_base_integer'
          example: 123  
      required:
        - topup_amount    


  # TSS Management # #
    bookmark_for_TSSM_and_TSS_section:
      type: string
      # The bookmark for TSSM/TSS section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # #    
    TSSCredentialSafeList:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/TSSCredentialSafeBaseInfoPack'  # include workspace, name, key
      properties:
        type:
          $ref: '#/components/schemas/tssm_credentialsafe_type_base_string'

    TSSCredentialSafeDetail:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/TSSCredentialSafeBaseInfoPack'  # include workspace, name, key
        - $ref: '#/components/schemas/TSSCredentialSafeTypeSpecificPack'  # include type, url, credential

    TSSCredentialSafeOPT:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/TSSCredentialSafeTypeSpecificPack'  # include type, url, credential
      properties:
        name:
          $ref: '#/components/schemas/object_name_base_string'
          example: "Key Vault for Tiger Team"

    TSSCredentialSafeForCreateRequest:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/TSSCredentialSafeTypeSpecificPack'  # include type, url, credential
      properties:
        workspace:
          $ref: '#/components/schemas/workspace_key_base_string'
          example: "WKS"
        name:
          $ref: '#/components/schemas/object_name_base_string'
          example: "Key Vault for Tiger Team"

    TSSCredentialSafeForCreateResponse:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
          example: "WKS-CS-FFFF"
          
    TSSCredentialSafeBaseInfoPack:
      type: object
      additionalProperties: false
      properties:
        workspace:
          $ref: '#/components/schemas/workspace_key_base_string'
          example: "WKS"
        name:
          $ref: '#/components/schemas/object_name_base_string'
          example: "XAPI Instance"
        key:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'

    TSSCredentialSafeTypeSpecificPack:
      type: object
      additionalProperties: false
      properties:
        type:
          $ref: '#/components/schemas/tssm_credentialsafe_type_base_string'
        url:
          allOf:
            - $ref: '#/components/schemas/url_base_string'
          example: "https://azure.keyvault.com.cn"
        credential:
          discriminator:
            propertyName: vendor
            mapping:
              azure-key-vault: '#/components/schemas/AzureKeyVaultCredentials'
              aws-secrets-manager: '#/components/schemas/AWSSecretsManagerCredentials'
          anyOf:
            - $ref: '#/components/schemas/AzureKeyVaultCredentials'
#              example: '{ "tenant_id":"","client_id": "", "client_secret": "", "expire_date": ""}'
            - $ref: '#/components/schemas/AWSSecretsManagerCredentials'
#              example: '{ "aws_region": "", "aws_access_key_id": "", "aws_access_key_secret": "", "expire_date": ""}'    
      
    TSSCredentialList:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/TSSCredentialKeyForCreateRequest'  # include name, type, env, labels, expire_date, description, key, credentialsafe_key
      properties:
        uuid:
          $ref: '#/components/schemas/tssm_credential_uuid_base_string'

    TSSCredentialOPT:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/TSSCredentialBaseInfoPack'  # include name, type, env, labels, expire_date, description

    TSSCredentialKeyForCreateRequest:
      type: object
      additionalProperties: false
      allOf:
        - $ref: '#/components/schemas/TSSCredentialBaseInfoPack'  # include name, type, env, labels, expire_date, description
      properties:
        key:
          $ref: '#/components/schemas/tssm_credential_key_base_string'
        credentialsafe_key:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'

    TSSCredentialKeyForCreateResponse:
      type: object
      additionalProperties: false
      properties:
        uuid:
          $ref: '#/components/schemas/tssm_credential_uuid_base_string'

    TSSCredentialKeyDetail:
      $ref: '#/components/schemas/TSSCredentialList' # include name, type, env, labels, expire_date, description, key, credentialsafe_key, uuid

    TSSCredentialAssignOPT:
      type: object
      additionalProperties: false
      properties:
        workspace:
          $ref: '#/components/schemas/workspace_key_base_string'
          example: "WKS"
        credential_safe_key:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
        credential_key:
          $ref: '#/components/schemas/tssm_credential_key_base_string'

    TSSCredentialAssignList:
      type: object
      additionalProperties: false
      properties:
        workspace:
          $ref: '#/components/schemas/workspace_key_base_string'
          example: "WKS"
        credential_safe_name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My Key Vault"
        credentisl_safe_key:
          $ref: '#/components/schemas/tssm_credentialsafe_key_base_string'
        credential_name:
          allOf:
            - $ref: '#/components/schemas/object_name_base_string'
          example: "My Credit Card Password"
        credential_key:
          $ref: '#/components/schemas/tssm_credential_key_base_string'
        valid_flag:
          $ref: '#/components/schemas/boolean_base_boolean'
          description: |
            false: data with deleted status or no related workspace reading_settings permssion 
            true: active data
          
    TSSCredentialBaseInfoPack:
      type: object
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/object_name_base_string'
          example: "User Token for QA environment"
        type:
          $ref: '#/components/schemas/tssm_credential_type_base_string'
        env:
          $ref: '#/components/schemas/object_environment_base_string'
          example: "QA"
        labels:
          $ref: '#/components/schemas/object_labels_base_array'
          example: ["QA", "Token"]
        expire_date:
          $ref: '#/components/schemas/date_base_string'
        description:
          $ref: '#/components/schemas/long_text_base_string'
          example: "This is an user token for QA environment"

    AzureKeyVaultCredentials:
      type: object
      description: "Credentials required for Azure Key Vault"
      additionalProperties: false
      properties:
        vendor:
          type: string
          allOf:
            - $ref: '#/components/schemas/tssm_credentialsafe_vendor_base_string'
          example: "Azure"
        tenant_id:
          allOf:
            - $ref: '#/components/schemas/tssm_credential_uuid_base_string'
          description: "Azure Tenant ID"
          example: 72f988bf-86f1-41af-91ab-2d7cd011db47
        client_id:
          allOf:
            - $ref: '#/components/schemas/tssm_credential_uuid_base_string'
          description: "Azure Key Vault Client ID"
          example: c56a4180-65aa-42ec-a945-5fd21dec0538
        client_secret:
          allOf:
            - $ref: '#/components/schemas/long_text_base_string'
          description: "Azure Key Vault Client Secret"
          example: "This is the client secret"
        expire_date:
          allOf:
            - $ref: '#/components/schemas/date_base_string'
          description: "Expiration date for the credentials"
          example: "2024-10-05"
      required:
        - vendor
        - tenant_id
        - client_id
        - client_secret

    AWSSecretsManagerCredentials:
      type: object
      description: "Credentials required for AWS Secrets Manager"
      additionalProperties: false
      properties:
        vendor:
          type: string
          allOf:
            - $ref: '#/components/schemas/tssm_credentialsafe_vendor_base_string'
          example: "AWS"
        aws_region:
          allOf:
            - $ref: '#/components/schemas/tssm_credentialsafe_aws_region_id_base_string'
          example: "us-east-1"
        aws_access_key_id:
          allOf:
            - $ref: '#/components/schemas/tssm_credentialsafe_aws_access_key_id_base_string'
          example: "AKIAIOSFODNN7EXAMPLE"
        aws_access_key_secret:
          allOf:
            - $ref: '#/components/schemas/tssm_credentialsafe_aws_asm_secret_access_key_base_string'
          example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY"
        expire_date:
          allOf:
            - $ref: '#/components/schemas/date_base_string'
          description: "Expiration date for the credentials"
          example: "2024-10-05"
      required:
        - vendor
        - aws_region
        - aws_access_key_id
        - aws_access_key_secret



  # Partner Management # #
    bookmark_for_Partner_Management_section:
      type: string
      # The bookmark for Partner Management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # # 

    PartnerInfoForCreate:
      type: object
      additionalProperties: false
      properties:
        type:
          $ref: '#/components/schemas/partner_type_base_string'
        key:
          $ref: '#/components/schemas/partner_key_base_string'
      required:
        - type
        - key

    PartnerInfoForUpdateByGlobalAdmin:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PartnerInfoForReadByPartner'  # include type, contract_start_date, contract_expiration_date, workspace_referral_protection_end_date, workspace_referral_period_length, active_referred_workspaces, total_referred_workspaces
        - type: object
          properties:
            crm_link:
              allOf:
                - $ref: '#/components/schemas/url_base_string'
              description: "The CRM link of the partner."

    PartnerInfoForReadByGlobalAdmin:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PartnerInfoForUpdateByGlobalAdmin'  # include type, contract_start_date, contract_expiration_date, workspace_referral_protection_end_date, workspace_referral_period_length, active_referred_workspaces, total_referred_workspaces
        - type: object
          properties:
            uid:
              $ref: '#/components/schemas/partner_uid_base_string'
            referral_id:
              $ref: '#/components/schemas/partner_referral_id_base_string'
        
        
    
    PartnerInfoForUpdateByPartner:
      type: object
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/partner_name_base_string'
        email:
          $ref: '#/components/schemas/partner_email_base_string'
        phone:
          $ref: '#/components/schemas/partner_phone_base_string'

    PartnerInfoForReadByPartner:  # uid is not included. This schema only include name, email, phone, type, contract_start_date, contract_expiration_date, crm_link
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/PartnerInfoForUpdateByPartner'  # include name, email, phone
      properties:
        type:
          $ref: '#/components/schemas/partner_type_base_string'
        contract_start_date:
          $ref: '#/components/schemas/partner_contract_start_date_base_string'
        contract_expiration_date:
          $ref: '#/components/schemas/partner_contract_expiration_date_base_string'
        workspace_referral_protection_end_date:
          $ref: '#/components/schemas/partner_workspace_referral_protection_end_date_base_string'
        workspace_referral_period_length:
          $ref: '#/components/schemas/partner_workspace_referral_period_length_base_integer'
        active_referred_workspaces:
          $ref: '#/components/schemas/partner_active_referred_workspaces_base_array'
        total_referred_workspaces:
          $ref: '#/components/schemas/partner_total_referred_workspaces_base_array'
        
      

        

 
###############
#  belows are unrefined NG schemas
###############
    NGResourceObject:
      type: object
      additionalProperties: true
      allOf:
        - $ref: '#/components/schemas/ng_resource_type_base_string'
        - $ref: '#/components/schemas/ng_resource_key_base_string'

    NGWorkspaceObject:
      type: object
      additionalProperties: false
      $ref: '#/components/schemas/ng_workspace_key_base_string'

    NGUserObject:
      type: object
      additionalProperties: false
      $ref: '#/components/schemas/ng_user_uid_base_string'

    NGEmptyObject:
      type: object
      additionalProperties: true
        




    Method:
      type: object
      additionalProperties: false
      required:
        - id
        - name
        - managed
        - enabled
      properties:
        id:
          allOf:
            - $ref: '#/components/schemas/ng_method_id_base_string'
          example: email
          readOnly: true
        name:
          allOf:
            - $ref: '#/components/schemas/ng_method_name_base_string'
          example: E-mail
          readOnly: true
        managed:
          $ref: '#/components/schemas/boolean_base_boolean'
          readOnly: true
        enabled:
          $ref: '#/components/schemas/boolean_base_boolean'
          nullable: false
      
    Receiver:
      type: object
      additionalProperties: false
      properties:
        uuid:
          $ref: '#/components/schemas/ng_receiver_uuid_base_string'
        name:
          $ref: '#/components/schemas/ng_receiver_name_base_string'
        workspace:
          $ref: '#/components/schemas/ng_workspace_key_base_string'
        user:
          $ref: '#/components/schemas/ng_user_uid_base_string'
        method:
          $ref: '#/components/schemas/ng_method_id_base_string'
        target:
          $ref: '#/components/schemas/ng_receiver_target_base_string'
        link:
          $ref: '#/components/schemas/ng_receiver_link_base_string'
        rules_uuid:
          $ref: '#/components/schemas/ng_rules_uuid_base_array'
    
    Rule:
      type: object
      additionalProperties: false
      properties:
        uuid:
          type: string
          maxLength: 36
          minLength: 36
          pattern: ^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$
          readOnly: true
        name:
          type: string
          minLength: 1
          maxLength: 80
          pattern: /\W{1,80}/
        resource_type:
          type: string
          enum:
            - PLAN
            - GATEKEEPER
        resource_key:
          type: string
          pattern: '[A-Z0-9\-]{10}'
          maxLength: 10
        workspace:
          type: string
          pattern: '[A-Z][A-Z0-9]{1,2}'
          maxLength: 3
          minLength: 3
        active:
          type: boolean
        rule:
          type: string
          pattern: /.*/
          maxLength: 300000
        receivers:
          type: array
          maxItems: 10000
          items:
            type: integer
            maximum: 20
            minimum: 1
            format: int64
    RuleOpt:
      type: object
      additionalProperties: false
      properties:
        uuid:
          type: string
          maxLength: 36
          minLength: 36
          pattern: ^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$
          readOnly: true
        name:
          type: string
          minLength: 1
          maxLength: 80
          pattern: /\W{1,80}/
        resource_type:
          type: string
          enum:
            - PLAN
            - GATEKEEPER
        resource_key:
          type: string
          pattern: '[A-Z0-9\-]{10}'
          maxLength: 10
        workspace:
          type: string
          pattern: '[A-Z][A-Z0-9]{1,2}'
          maxLength: 3
          minLength: 3
        active:
          type: boolean
        receivers:
          type: array
          maxItems: 10000
          items:
            type: integer
            maximum: 20
            minimum: 1
            format: int64
    ReceiverRelations:
      type: object
      additionalProperties: false
      properties:
        uuid:
          type: string
          maxLength: 36
          minLength: 36
          pattern: ^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$
          readOnly: true
        name:
          type: string
          minLength: 1
          maxLength: 80
          pattern: /\W{1,80}/
        resource_type:
          type: string
          enum:
            - PLAN
            - GATEKEEPER
        resource_key:
          type: string
          pattern: '[A-Z0-9\-]{10}'
          maxLength: 10
        workspace:
          type: string
          pattern: '[A-Z][A-Z0-9]{1,2}'
          maxLength: 3
          minLength: 3
    EmailGroupPayload:
      type: object
      additionalProperties: false
      required:
        - resource_type
        - resource_key
        - email_group
      properties:
        resource_type:
          type: string
          enum:
            - PLAN
            - GATEKEEPER
        resource_key:
          type: string
          pattern: '[A-Z0-9\-]{10}'
          maxLength: 10
        email_group:
          type: boolean
      readOnly: false
    GenericError:
      type: object
      additionalProperties: false
      properties:
        code:
          type: string
          pattern: 'E[A-F0-9]{6}'
          minLength: 7
          maxLength: 7
        message:
          type: string
          maxLength: 5000
          pattern: /.*/

###########################
# unrefined NG schemas END
###########################




  # Partner Management # #
    bookmark_for_Directory_View_Management_section:
      type: string
      # The bookmark for Directory View Management section. Just to make it easier to navigate within this file during editing.
  # # # # # # # # # # # 
  
    DirectoryItem:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/directory_key_base_string'
        name:
          $ref: '#/components/schemas/directory_name_base_string'
        parent_key:
          $ref: '#/components/schemas/directory_key_base_string'
        order:
          $ref: '#/components/schemas/directory_order_base_integer'
      required:
        - key
        - parent_key
        - order
    
    DirectoryViewForCreate:
      type: object
      additionalProperties: false
      properties:
        name:
          $ref: '#/components/schemas/directory_name_base_string'
        description:
          $ref: '#/components/schemas/long_text_base_string'
      required:
        - name
    
    DirectoryViewForCreateResponse:
      type: object
      additionalProperties: false
      properties:
        key:
          $ref: '#/components/schemas/directory_key_base_string'
        name:
          $ref: '#/components/schemas/directory_name_base_string'
        is_private:
          $ref: '#/components/schemas/directory_structure_is_private_base_boolean'
        owner:
          $ref: '#/components/schemas/directory_structure_owner_base_string'
        directories:
          type: array
          maxItems: 10000
          items:
            $ref: '#/components/schemas/DirectoryItem'
      required:
        - directories
          
          
          
    
    
          
          
          
  



  responses:
    UnauthorizedResponse:
      description: Unauthorized (401)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E401001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'You are not authorized to access this resource.'
                description: "Detailed error message explaining the failure"
          examples:
            unauthorizedExample:
              summary: "Example of unauthorized error"
              value:
                code: "E401001"
                message: "You are not authorized to access this resource."

    BadRequestResponse:
      description: Bad Request (400)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E400001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'The request parameters are invalid.'
                description: "Detailed error message explaining the failure"
              reason:
                type: string
                pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                maxLength: 64
                example: 'WORKSPACE_GENERATION_NOT_CURRENT'
                description: "Optional. A stable, upper-snake-case reason that tells apart failures that share one error code. It appears only on endpoints that document it, is never renamed once published, and new values may be added over time, so treat unknown values as unknown."
              details:
                type: object
                additionalProperties: true
                description: "Optional. Structured facts about the failure, such as the position of a rule or the key of a missing object. It only repeats what the caller submitted or what is already in the message. The keys depend on the reason."
          examples:
            badRequestExample:
              summary: "Example of bad request error"
              value:
                code: "E400001"
                message: "The request parameters are invalid."

    NotFoundResponse:
      description: Not Found (404)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E404001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'The requested resource could not be found.'
                description: "Detailed error message explaining the failure"
              reason:
                type: string
                pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                maxLength: 64
                example: 'WORKSPACE_GENERATION_NOT_CURRENT'
                description: "Optional. A stable, upper-snake-case reason that tells apart failures that share one error code. It appears only on endpoints that document it, is never renamed once published, and new values may be added over time, so treat unknown values as unknown."
              details:
                type: object
                additionalProperties: true
                description: "Optional. Structured facts about the failure, such as the position of a rule or the key of a missing object. It only repeats what the caller submitted or what is already in the message. The keys depend on the reason."
          examples:
            notFoundExample:
              summary: "Example of not found error"
              value:
                code: "E404001"
                message: "The requested resource could not be found."

    MethodNotAllowedResponse:
      description: Method Not Allowed (405)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E405001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'The requested method is not allowed.'
                description: "Detailed error message explaining the failure"
          examples:
            methodNotAllowedExample:
              summary: "Example of method not allowed error"
              value:
                code: "E405001"
                message: "The requested method is not allowed."

    ForbiddenResponse:
      description: You're not allowed to {$action} {$resource_key} yet. #403
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E403001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: "You don't have permission to perform this action."
                description: "Detailed error message explaining the failure"
              reason:
                type: string
                pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                maxLength: 64
                example: 'WORKSPACE_GENERATION_NOT_CURRENT'
                description: "Optional. A stable, upper-snake-case reason that tells apart failures that share one error code. It appears only on endpoints that document it, is never renamed once published, and new values may be added over time, so treat unknown values as unknown."
              details:
                type: object
                additionalProperties: true
                description: "Optional. Structured facts about the failure, such as the position of a rule or the key of a missing object. It only repeats what the caller submitted or what is already in the message. The keys depend on the reason."
          examples:
            forbiddenExample:
              summary: "Example of forbidden error"
              value:
                code: "E403001"
                message: "You don't have permission to perform this action."

    TooManyRequestsResponse:
      description: Too Many Requests (429)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E429001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'You have made too many requests. Please try again later.'
                description: "Detailed error message explaining the failure"
          examples:
            tooManyRequestsExample:
              summary: "Example of too many requests error"
              value:
                code: "E429001"
                message: "You have made too many requests. Please try again later."

    UnsupportedMediaTypeResponse:
      description: Unsupported Media Type (415)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E415001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'The media type of the request is not supported.'
                description: "Detailed error message explaining the failure"
          examples:
            unsupportedMediaTypeExample:
              summary: "Example of unsupported media type error"
              value:
                code: "E415001"
                message: "The media type of the request is not supported."

    NotAcceptableResponse:
      description: Not Acceptable (406)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E406001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request.'
                description: "Detailed error message explaining the failure"
          examples:
            notAcceptableExample:
              summary: "Example of not acceptable error"
              value:
                code: "E406001"
                message: "The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request."

    ConflictResponse:
      description: Conflict (409)
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E409001'
                description: "Error code associated with the failure"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'The request could not be completed due to a conflict with the current state of the resource.'
                description: "Detailed error message explaining the failure"
              reason:
                type: string
                pattern: '^[A-Z][A-Z0-9_]{1,63}$'
                maxLength: 64
                example: 'WORKSPACE_GENERATION_NOT_CURRENT'
                description: "Optional. A stable, upper-snake-case reason that tells apart failures that share one error code. It appears only on endpoints that document it, is never renamed once published, and new values may be added over time, so treat unknown values as unknown."
              details:
                type: object
                additionalProperties: true
                description: "Optional. Structured facts about the failure, such as the position of a rule or the key of a missing object. It only repeats what the caller submitted or what is already in the message. The keys depend on the reason."
          examples:
            conflictExample:
              summary: "Example of conflict error"
              value:
                code: "E409001"
                message: "The request could not be completed due to a conflict with the current state of the resource."

    DefaultResponse:
      description: "A fallback error response for undefined errors"
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              code:
                type: string
                pattern: 'E[0-9]{6}'
                maxLength: 7
                example: 'E500001'
                description: "Fallback error code for undefined errors"
              message:
                type: string
                pattern: ^[^\u0000-\u001F]{1,1024}$  # 正则表达式，确保没有控制字符且最大长度为1024
                example: 'An unexpected error occurred.'
                description: "A generic message explaining the error"



###################
# below are unrefined NG responses
#######################
    '400':
      description: 'Bad request, parameters issue maybe?'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4740] ValidationError':
              value:
                code: E4E4740
                message: >-
                  Bad request. Required parameters is missing or malformed.
            '[E4E4741] DecodeError':
              value:
                code: E4E4741
                message: >-
                  Bad request. Request is malformed and cannot be decoded correctly.
    '401':
      description: 'Unauthorized. Requesting resources without valid authorization context.'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4730] AuthContextError':
              value:
                code: E4E4730
                message: >-
                  The access_token is missing or invalid. Please trade a new token before accessing this endpoint again.
            '[E4E4731] AuthContextExpiredError':
              value:
                code: E4E4731
                message: >-
                  The access_token was expired. Please trade a new token before accessing this endpoint again.
    '403':
      description: 'Forbidden. Requesting resources without sufficient permissions.'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4735] PermissionError':
              value:
                code: E4E4735
                message: >-
                  The request of resource(s) you're requesting has been rejected due to lack of permissions.
    '404':
      description: 'Not found. Requesting resources is not exist.'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4712] NotFoundError':
              value:
                code: E4E4712
                message: >-
                  The request of resource(s) you're requesting is not exist.

    '405':
      description: 'Method not allowed. The method is not supported for the requested URL.'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E405001] MethodNotAllowedError':
              value:
                code: E405001
                message: >-
                  The request method is not supported for the requested URL.

    '406':
      description: 'Not acceptable. The MIME type of the request is not supported.'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4719] NotFoundError':
              value:
                code: E4E4719
                message: >-
                  The request MIME type is not supported yet.

    '409':
      description: 'Conflict. The request could not be completed due to a conflict with the current state of the resource.'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4713] ConflictError':
              value:
                code: E4E4713
                message: >-
                  The request of resource(s) you're requesting is conflicted with the current state of the resource.
                  
    '410':
      description: 'Resource unavailable. Requesting resources was marked as deleted.'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4715] UnavailableError':
              value:
                code: E4E4715
                message: >-
                  The request of resource(s) you're requesting was marked as deletion.
    '429':
      description: Too many requests
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4718] UnavailableError':
              value:
                code: E4E4718
                message: >-
                  You're requesting us too many times. Please wait for a while and try again.
    '500':
      description: 'Internal server exceptions'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4753] DatabaseConnectionError':
              value:
                code: E4E4753
                message: >-
                  psycopg2.OperationalError: could not connect to server: Connection refused
    '503':
      description: 'Service unavailable'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4752] UpstreamServiceConnectionTimoutError':
              value:
                code: E4E4752
                message: >-
                  An upstream service is currently unavailable. Please try again later.
            '[E4E4754] UpstreamServiceError':
              value:
                code: E4E4754
                message: >-
                  The upstream service is currently unavailable due to internal issues. Please try again later.
    'default':
      description: 'fallback error'
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            properties:
              GenericError:
                $ref: '#/components/schemas/GenericError'
          examples:
            '[E4E4799] FallbackError':
              value:
                code: E4E4799
                message: >-
                  An unknown error occured. Please try again later.



###################
# unrefined NG responses END
#######################


#####################
# below are unrefined NG parameters
#####################
  parameters:
    method_id:
      name: method_id
      in: path
      required: true
      schema:
        $ref: '#/components/schemas/ng_method_id_base_string'
      description: |
        input options (email method is mandatory enabled):
        - webex_webhook
        - ms_teams_webhook
        - generic_webhook
      example: ms_teams_webhook

    receiver_id:
      name: receiver_id
      in: path
      required: true
      schema:
        type: string
        maximum: 36
        minimum: 36
        pattern: ^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$
        maxLength: 36
        minLength: 36
      example: "70a7afb9-e9d1-405c-83e4-6cdd632e9eaa"
    workspace:
      name: workspace
      in: query
      schema:
        type: string
        pattern: '[A-Z][A-Z0-9]{1,2}'
        maxLength: 3
      example: WKS
    user:
      name: uid
      in: query
      schema:
        type: string
        maxLength: 50
        pattern: /.*/
      example: alice@acme.tld
    rule_id:
      name: rule_id
      in: path
      required: true
      schema:
        type: string
        maximum: 36
        minimum: 36
        maxLength: 36
        minLength: 36
        pattern: ^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$
      example: "357364b6-c0b9-4c8d-9ee0-99ffd0bce7a4"
    resource_type:
      name: resource_type
      in: query
      schema:
        type: string
        enum: ["plan", "gatekeeper", "pipeline_manual_execution"]
      example: "plan"
    resource_key:
      name: resource_key
      in: query
      schema:
        type: string
        pattern: /[A-Z0-9\-]{10}/
        maxLength: 32
      example: "P-WKS-0001"


###################
# unrefined NG parameters END
###################





  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        JWT token for authentication. Please use the token provided in the response of the login API.




