openapi: 3.0.3
info:
  title: 云托管
  description: |-
    ### Feature Introduction

    This series of open APIs provides the ability to interface with CloudBase Run. Through these APIs you can invoke CloudBase Run services within an environment, with support for both `SSE (Server-Sent Event)` and `WebSocket` requests.

    ### Access Guide

    Calling the following APIs requires an AccessToken in the format `Authorization: Bearer <token>`. For details on how to obtain the token, refer to https://docs.cloudbase.net/http-api/basic/access-token.

    ### HTTP Status Codes

    Depending on the response result, status codes `2xx`, `4xx`, or `5xx` may appear.

    ### Error Codes

    The following table lists the error codes specific to this series of APIs. For the complete list, refer to https://docs.cloudbase.net/error-code/service.

    <table>
      <thead>
      <tr>
        <td>Error Code</td>
        <td>Description</td>
      </tr>
      </thead>
      <tr>
        <td>SERVICE_NOT_FOUND</td>
        <td>The specified service was not found</td>
      </tr>
      <tr>
        <td>SERVICE_TIMEOUT</td>
        <td>The CloudBase Run service call timed out</td>
      </tr>
      <tr>
        <td>SERVICE_FORBIDDEN</td>
        <td>Access to the CloudBase Run service was denied, possibly due to permission configuration or service status issues</td>
      </tr>
      <tr>
        <td>SERVICE_NOT_READY</td>
        <td>The CloudBase Run service is not ready</td>
      </tr>
      <tr>
        <td>SERVICE_VERSION_NOT_FOUND</td>
        <td>No matching CloudBase Run service version was found</td>
      </tr>
      <tr>
        <td>SERVICE_ENDPOINT_NOT_FOUND</td>
        <td>No available endpoint was found for the CloudBase Run service</td>
      </tr>
      <tr>
        <td>SERVICE_LB_STATUS_ABNORMAL</td>
        <td>The load balancer status of the CloudBase Run service is abnormal; try creating a new version</td>
      </tr>
      <tr>
        <td>SERVICE_RESOURCE_NOT_FOUND</td>
        <td>No resources associated with the service were found</td>
      </tr>
      <tr>
        <td>SERVICE_CHARGE_OVERDUE</td>
        <td>Service is suspended due to overdue payment. Please recharge in time.</td>
      </tr>
    </table>
  contact:
    name: TCB
    url: https://cloud.tencent.com/product/tcb
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
  - url: https://{envId}.api.tcloudbasegateway.com
    description: TCB openapi endpoint
    variables:
      envId:
        default: "your-envId"
        description: Environment ID
paths:
  /v1/cloudrun/{name}/{anyPath}:
    get:
      operationId: cloudrun-get
      tags:
        - 云托管调用
      summary: Invoke CloudBase Run service
      externalDocs:
        description: "For the complete error code list, refer to:"
        url: https://docs.cloudbase.net/error-code/service
      parameters:
        - name: name
          in: path
          description: Name of the service to invoke
          required: !!bool true
          schema:
            type: string
            pattern: "^[a-zA-Z][a-zA-Z0-9_-]{0,58}[a-zA-Z0-9]$"
        - name: anyPath
          required: false
          in: path
          description: Append any additional path segments
          schema:
            type: string
      description: |-
        Invoke the specified CloudBase Run service.

        When calling CloudBase Run through the open APIs, the response headers are adjusted to mitigate potential compliance-related blocking risks:

        1. For all responses to `GET` requests, the header `Content-Disposition: attachment` is added.
        2. For non-text responses (text types include `application/json`, `application/x-www-form-urlencoded`, and `text/plain` in the response `Content-Type` header), the header `Content-Disposition: attachment` is added.

        > **Note**: `SSE (Server-Sent Event)` and `WebSocket` requests are exempt from these adjustments.
      responses:
        "200":
          $ref: "#/components/responses/CloudRunSuccessResponse"
        "403":
          $ref: "#/components/responses/CloudRunErrorResponse403"
        "404":
          $ref: "#/components/responses/CloudRunErrorResponse404"
        "default":
          $ref: "#/components/responses/CommonErrorResponse"
    post:
      operationId: cloudrun-post
      tags:
        - 云托管调用
      externalDocs:
        description: "For the complete error code list, refer to:"
        url: https://docs.cloudbase.net/error-code/service
      summary: Invoke CloudBase Run service
      parameters:
        - name: name
          in: path
          description: Name of the service to invoke
          required: true
          schema:
            type: string
            pattern: "^[a-zA-Z][a-zA-Z0-9_-]{0,58}[a-zA-Z0-9]$"
        - name: anyPath
          required: false
          in: path
          description: Append any additional path segments
          schema:
            type: string
      description: |-
        Invoke the specified CloudBase Run service.

        When calling CloudBase Run through the open APIs, the response headers are adjusted to mitigate potential compliance-related blocking risks:

        1. For all responses to `GET` requests, the header `Content-Disposition: attachment` is added.
        2. For non-text responses (text types include `application/json`, `application/x-www-form-urlencoded`, and `text/plain` in the response `Content-Type` header), the header `Content-Disposition: attachment` is added.

        > **Note**: `SSE (Server-Sent Event)` and `WebSocket` requests are exempt from these adjustments.
      requestBody:
        description: Request payload for invoking the CloudBase Run service
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            examples:
              Echo:
                summary: echo
                value: { "a": 1, "b": 2 }
      responses:
        "200":
          $ref: "#/components/responses/CloudRunSuccessResponse"
        "403":
          $ref: "#/components/responses/CloudRunErrorResponse403"
        "404":
          $ref: "#/components/responses/CloudRunErrorResponse404"
        "default":
          $ref: "#/components/responses/CommonErrorResponse"
components:
  responses:
    CommonErrorResponse:
      description: Common error information, see https://docs.cloudbase.net/error-code/service for details
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Request ID
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/CommonErrorResponse"
          examples:
            InvalidHost:
              summary: Invalid request address
              value:
                code: "INVALID_HOST"
                message: "xxx"
                requestId: "xxx"
    CloudRunErrorResponse404:
      description: Returned when the CloudBase Run call fails
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Request ID
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/CommonErrorResponse"
          examples:
            ServiceNotFound:
              summary: CloudBase Run service not found
              value:
                {
                  "code": "SERVICE_NOT_FOUND",
                  "message": "Service not found. For more information, please refer to https://docs.cloudbase.net/error-code/service",
                  "requestId": "yyxxxxxx-yyyy-yyyy-zzzz-xxxxxxzzyyyy",
                }
    CloudRunErrorResponse403:
      description: Returned when the CloudBase Run call fails
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Request ID
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/CommonErrorResponse"
          examples:
            ServiceForbidden:
              summary: Access to the CloudBase Run service was denied
              value:
                {
                  "code": "SERVICE_FORBIDDEN",
                  "message": "Service forbidden. For more information, please refer to https://docs.cloudbase.net/error-code/service",
                  "requestId": "yyxxxxxx-yyyy-yyyy-zzzz-xxxxxxzzyyyy",
                }
    CloudRunSuccessResponse:
      description: Returned when the call succeeds
      headers:
        X-Request-Id:
          schema:
            type: string
          description: Request ID
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/v1CloudRunResponseDataJSON"
          examples:
            Echo:
              summary: echo
              description: |-
                A CloudBase Run service that echoes the original JSON request body
              value: { "a": 1, "b": 2 }
        text/plain:
          schema:
            $ref: "#/components/schemas/v1CloudRunResponseDataText"
          examples:
            Text:
              summary: text
              description: |-
                A CloudBase Run service that returns `Hello world`
              value: "Hello world"
  requestBodies:
    v1CloudRunRequestData:
      required: true
      description: Request payload for invoking CloudBase Run, no format restriction
      content:
        application/json:
          schema:
            type: object
  schemas:
    v1CloudRunResponseDataJSON:
      type: object
      additionalProperties: true
    v1CloudRunResponseDataText:
      type: string
    CommonErrorResponse:
      type: object
      properties:
        code:
          type: string
          title: Error code
        message:
          type: string
          title: Error message
        requestId:
          type: string
          title: Request ID
      description: Error information returned when a request fails
  securitySchemes:
    JWTAuth:
      type: http
      scheme: Bearer
      description: The token corresponding to the environment ID is obtained using login authentication (v2)
    APIKey:
      type: apiKey
      in: header
      name: Authorization
      description: Tencent Cloud 3.0 signature that starts with TC3-HMAC-SHA256, with Timestamp and Token appended to the end of the signature
security:
  - JWTAuth: []
  - APIKey: []
tags:
  - name: 云托管
