basePath: /api/v1
definitions:
  errors.StatusError:
    properties:
      code:
        description: Suggested HTTP return code for this status
        type: integer
      message:
        description: A human-readable description of the status of this operation.
        type: string
      reason:
        description: A machine-readable description of why this operation is failed
        type: string
    type: object
  model.CPUResource:
    properties:
      core:
        type: number
    type: object
  model.MemoryResource:
    properties:
      byte:
        type: integer
    type: object
  model.PhysicalResource:
    properties:
      cpu:
        $ref: '#/definitions/model.CPUResource'
      memory:
        $ref: '#/definitions/model.MemoryResource'
    type: object
  model.TestBedItem:
    properties:
      name:
        description: Name is the name of the test resource
        type: string
      provider:
        description: Provider indicates the name of provider who creates the resource.
        type: string
      qos:
        description: Qos is the quality of service on test resource
        items:
          type: integer
        type: array
      ready:
        description: Ready identifies whether the test resource is in the ready state,
          it's generated on the RMS server side
        type: boolean
      spec:
        description: |-
          Spec is the specification of test resource
          TODO(@mahjonp): add a validator(used on the TCMS server)
        items:
          type: integer
        type: array
      testbed:
        description: Testbed is the name of test resource's testbed and it's required
          unless the Type value equals to TEST_BED
        type: string
      type:
        description: Type is the resource type
        type: string
    required:
    - type
    type: object
  request.AuthTestbedRequest:
    properties:
      authorizeTo:
        items:
          $ref: '#/definitions/request.User'
        type: array
      name:
        type: string
    type: object
  request.CreateTestbedRequest:
    properties:
      generateName:
        description: |-
          GenerateName is an optional prefix, used by the RMS server, to generate a unique
          name ONLY IF the Name field has not been provided.
        type: string
      items:
        items:
          $ref: '#/definitions/model.TestBedItem'
        type: array
      meta:
        $ref: '#/definitions/request.TestBedMeta'
      name:
        description: Name can be generated by scheduler from GenerateName
        type: string
      physicalResourceRequest:
        $ref: '#/definitions/model.PhysicalResource'
        description: If left empty, scheduler will try to estimate it
      qos:
        items:
          $ref: '#/definitions/resource.QosClaim'
        type: array
      reclaimPolicy:
        $ref: '#/definitions/resource.ReclaimPolicy'
        description: ReclaimPolicy shows how to clean the whole testbed resources
      resourcePool:
        default: default
        description: ResourcePool can be re-written by scheduler
        type: string
      rmsUrl:
        description: RmsUrl is the url added by scheduler and used by executor
        type: string
    type: object
  request.CredentialRequest:
    properties:
      pem:
        items:
          type: integer
        type: array
      testbedName:
        type: string
    type: object
  request.GetResourcePoolStatusRequest:
    properties:
      resourcePool:
        type: string
    type: object
  request.GetTestbedResourceOvertimeRequest:
    properties:
      end:
        type: string
      start:
        type: string
      testbed:
        type: string
    type: object
  request.GetTestbedsResourceRequest:
    properties:
      resourcePool:
        type: string
    type: object
  request.RestoreMonitorRequest:
    properties:
      clusterType:
        default: k8s
        type: string
      prometheusTarballURL:
        type: string
      testbed:
        type: string
    type: object
  request.TestBedMeta:
    properties:
      accounting:
        $ref: '#/definitions/request.User'
      to:
        items:
          $ref: '#/definitions/request.User'
        type: array
    type: object
  request.User:
    properties:
      kind:
        type: string
      name:
        type: string
      namespace:
        type: string
    type: object
  resource.Details:
    properties:
      endpoints:
        description: 'TODO(@codingpoet): add more fields here'
        items:
          $ref: '#/definitions/resource.Endpoint'
        type: array
    type: object
  resource.Endpoint:
    properties:
      externalSvcAddress:
        type: string
      name:
        type: string
      type:
        type: string
    type: object
  resource.GcAction:
    properties:
      artifact:
        $ref: '#/definitions/resource.GcArtifactAction'
      notification:
        $ref: '#/definitions/resource.GcNotificationAction'
      reserveEnv:
        $ref: '#/definitions/resource.GcReserveEnvAction'
    type: object
  resource.GcArtifactAction:
    properties:
      log:
        type: boolean
      monitor:
        type: boolean
    type: object
  resource.GcNotificationAction:
    properties:
      feishu:
        type: string
    type: object
  resource.GcReserveEnvAction:
    properties:
      durationOnWorkingHour:
        description: retain duration on working hour, if triggers on non-working hour,
          retain to next working hour
        type: string
      scaleDown:
        description: scale down to min request, on k8s impl, means removing resource
          requests(cpu & memory)
        type: boolean
      scaleIn:
        description: scale in to min replicas, to tidbcluster, is 1 tidb, 1 tikv,
          1 pd etc
        type: boolean
    type: object
  resource.GcStrategy:
    properties:
      onCompletion:
        $ref: '#/definitions/resource.GcAction'
      onFailure:
        $ref: '#/definitions/resource.GcAction'
      onSuccess:
        $ref: '#/definitions/resource.GcAction'
    type: object
  resource.QosClaim:
    properties:
      exclusive:
        description: |-
          Exclusive means whether the podGroup is mutually exclusive with other Pod or PodGroup.

          If it is set, this pod are mutually exclusive with other pods(means don't schedule on the same node)
          which has different podGroup name or without a podGroup binding
        type: boolean
      podGroup:
        description: |-
          PodGroup is the podGroup name, with the PodGroup we ensure a group of pods can be scheduled altogether.

          ref: https://github.com/PingCAP-QE/NaglfarCloud
        type: string
    type: object
  resource.ReclaimPolicy:
    properties:
      gcStrategy:
        $ref: '#/definitions/resource.GcStrategy'
      lease:
        default: 24h
        type: string
    type: object
  response.CheckTestbedResponse:
    properties:
      message:
        type: string
      name:
        type: string
      status:
        type: string
    type: object
  response.CreateTestbedResponse:
    properties:
      items:
        items:
          $ref: '#/definitions/response.TestbedResponseItem'
        type: array
      name:
        type: string
    type: object
  response.GetLogLinksResponse:
    properties:
      logLinks:
        additionalProperties:
          type: string
        type: object
    type: object
  response.GetResourcePoolStatusResponse:
    properties:
      nonTestbedOccupation:
        $ref: '#/definitions/model.PhysicalResource'
      totalResource:
        $ref: '#/definitions/model.PhysicalResource'
    type: object
  response.GetShootKubeConfigResponse:
    properties:
      kubeConfig:
        items:
          type: integer
        type: array
    type: object
  response.GetTestbedResourceOvertimeResponse:
    properties:
      averageTestBedPhysicalResource:
        $ref: '#/definitions/model.PhysicalResource'
      maxTestBedPhysicalResource:
        $ref: '#/definitions/model.PhysicalResource'
    type: object
  response.GetTestbedResponse:
    properties:
      items:
        items:
          $ref: '#/definitions/response.TestbedResponseItem'
        type: array
      lease:
        $ref: '#/definitions/response.LeaseResponse'
      name:
        type: string
    type: object
  response.GetTestbedsResourceResponse:
    properties:
      testbedsOccupation:
        additionalProperties:
          $ref: '#/definitions/model.PhysicalResource'
        type: object
    type: object
  response.LeaseResponse:
    properties:
      expireDate:
        description: ExpireDate is the testbed's expire date
        type: string
      lease:
        description: Lease is the testbed's lease duration
        type: string
    type: object
  response.ListTestbedResponse:
    properties:
      items:
        items:
          $ref: '#/definitions/response.GetTestbedResponse'
        type: array
    type: object
  response.RenewalLeaseResponse:
    properties:
      expireDate:
        description: ExpireDate is the testbed's expire date
        type: string
      name:
        description: Name is the testbed's name
        type: string
    type: object
  response.TestbedResponseItem:
    properties:
      details:
        $ref: '#/definitions/resource.Details'
      name:
        description: Name is the name of the test resource
        type: string
      provider:
        description: Provider indicates the name of provider who creates the resource.
        type: string
      ready:
        description: Ready identifies whether the test resource is in the ready state,
          it's generated on the RMS server side
        type: boolean
      testbed:
        description: Testbed is the name of test resource's testbed and it's required
          unless the Type value equals to TEST_BED
        type: string
      type:
        description: Type is the resource type
        type: string
    required:
    - type
    type: object
info:
  contact: {}
  version: "1.0"
paths:
  /credential/:
    post:
      consumes:
      - application/json
      operationId: generate-credential
      parameters:
      - description: provided public info
        in: body
        name: resource
        required: true
        schema:
          $ref: '#/definitions/request.CredentialRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            type: string
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: generate credential for user at this cluster
      tags:
      - credential
  /credential/ecr:
    get:
      operationId: get-temporary-ecr-image-sync-credential
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
      summary: get the temporary ecr image sync credential
      tags:
      - credentials
  /proxy:
    get:
      operationId: get-proxy
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
      summary: get the proxy
      tags:
      - proxy
  /resource-pool/status:
    get:
      consumes:
      - application/json
      operationId: get-resource-pool-status
      parameters:
      - description: ResourcePool to get status
        in: body
        name: resource
        required: true
        schema:
          $ref: '#/definitions/request.GetResourcePoolStatusRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.GetResourcePoolStatusResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      summary: get resource pool status
      tags:
      - resource-pool
  /resource-pool/testbed-resource-overtime:
    get:
      consumes:
      - application/json
      operationId: get-testbed-resource-overtime
      parameters:
      - description: testbed to get resource
        in: body
        name: resource
        required: true
        schema:
          $ref: '#/definitions/request.GetTestbedResourceOvertimeRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.GetTestbedResourceOvertimeResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      summary: get testbed resource overtime
      tags:
      - resource-pool
  /resource-pool/testbeds-resource:
    get:
      consumes:
      - application/json
      operationId: get-testbed-resource
      parameters:
      - description: ResourcePool to get testbeds resource
        in: body
        name: resource
        required: true
        schema:
          $ref: '#/definitions/request.GetTestbedsResourceRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.GetTestbedsResourceResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      summary: get testbed resource
      tags:
      - resource-pool
  /testbeds:
    get:
      consumes:
      - application/json
      operationId: list-testbed
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.ListTestbedResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: list testbeds
      tags:
      - testbeds
    post:
      consumes:
      - application/json
      operationId: create-testbed
      parameters:
      - description: Testbed to create
        in: body
        name: testbed
        required: true
        schema:
          $ref: '#/definitions/request.CreateTestbedRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.CreateTestbedResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: Create the testbed
      tags:
      - testbeds
  /testbeds/:name:
    delete:
      consumes:
      - application/json
      operationId: delete-testbed
      parameters:
      - description: Testbed to delete
        in: path
        name: name
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: delete the testbed
      tags:
      - testbeds
    get:
      consumes:
      - application/json
      operationId: get-testbed
      parameters:
      - description: Testbed to get
        in: path
        name: name
        required: true
        type: string
      - description: return with details
        in: query
        name: with_details
        type: boolean
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.GetTestbedResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: Get the testbed basic info
      tags:
      - testbeds
  /testbeds/:name/auth:
    put:
      consumes:
      - application/json
      operationId: auth-testbed
      parameters:
      - description: Testbed to auth
        in: path
        name: name
        required: true
        type: string
      - description: authTestbed Request
        in: body
        name: user
        required: true
        schema:
          $ref: '#/definitions/request.AuthTestbedRequest'
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: Authenticate the testbed to user(s)
      tags:
      - testbeds
  /testbeds/:name/check:
    get:
      operationId: check-testbed
      parameters:
      - description: Testbed to check
        in: path
        name: name
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.CheckTestbedResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: check the testbed status
      tags:
      - testbeds
  /testbeds/:name/complete:
    put:
      consumes:
      - application/json
      operationId: complete-testbed
      parameters:
      - description: Testbed to complete
        in: path
        name: name
        required: true
        type: string
      - description: On Testbed Completion Type
        in: query
        name: type
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: complete the testbed
      tags:
      - testbeds
  /testbeds/:name/lease:
    get:
      operationId: get-testbed-lease
      parameters:
      - description: Testbed to get lease
        in: path
        name: name
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.LeaseResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: get the testbed lease
      tags:
      - testbeds
  /testbeds/:name/lease/renew:
    put:
      operationId: renew-lease
      parameters:
      - description: Testbed to renew lease
        in: path
        name: name
        required: true
        type: string
      - description: Lease to renew, testbed DDL will be updated to 'time.Now() +
          lease'
        in: query
        name: lease
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.RenewalLeaseResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: RenewLease renew lease of a testbed
      tags:
      - testbeds
  /testbeds/:name/log_links:
    get:
      operationId: get-testbed-log-links
      parameters:
      - description: Testbed to get log links
        in: path
        name: name
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.GetLogLinksResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: get the testbed log links
      tags:
      - testbeds
  /testbeds/:name/restore-monitor:
    post:
      consumes:
      - application/json
      operationId: restore-monitor
      parameters:
      - description: Testbed to restore monitor
        in: path
        name: name
        required: true
        type: string
      - description: restore monitor request
        in: body
        name: testbed
        required: true
        schema:
          $ref: '#/definitions/request.RestoreMonitorRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            type: string
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/errors.StatusError'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: restore monitor from prometheus backup
      tags:
      - testbeds
  /testbeds/:name/shoot-kubeconfig:
    get:
      consumes:
      - application/json
      operationId: get-shoot-kubeconfig
      parameters:
      - description: Testbed the TiDBCloudCluster belongs to
        in: path
        name: name
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/response.GetShootKubeConfigResponse'
        "500":
          description: Internal Server Error
          schema:
            $ref: '#/definitions/errors.StatusError'
      security:
      - Bearer: []
      summary: Get kubeconfig of tidbcloud's shoot cluster
      tags:
      - testbeds
securityDefinitions:
  Bearer:
    in: header
    name: Authorization
    type: apiKey
swagger: "2.0"
