openapi: 3.0.1
info:
  title: external-api
  description: ''
  version: 1.0.0
tags:
  - name: Server Instances
paths:
  /external/api/v1/createServerInstance:
    post:
      summary: Create
      deprecated: false
      description: ''
      tags:
        - Server Instances
      parameters:
        - name: Api-Key
          in: header
          description: ''
          required: true
          example: '{{Api-Key}}'
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                instance_name:
                  type: string
                template_id:
                  type: integer
                allow_ssh:
                  type: boolean
                extra_ports:
                  type: array
                  items:
                    type: integer
              required:
                - instance_name
                - template_id
                - allow_ssh
                - extra_ports
            example:
              instance_name: lifeng-jupyter-1211
              template_id: 3008
              allow_ssh: false
              extra_ports: []
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      instance_id:
                        type: integer
                      instance_name:
                        type: string
                      org_id:
                        type: integer
                      user_id:
                        type: integer
                      User:
                        type: 'null'
                      UserOrganization:
                        type: 'null'
                      machine_image:
                        type: string
                      support_ssh:
                        type: boolean
                      service_ports:
                        type: array
                        items:
                          type: object
                          properties:
                            port:
                              type: integer
                            protocol:
                              type: string
                            name:
                              type: string
                      service_urls:
                        type: array
                        items:
                          type: object
                          properties:
                            url:
                              type: string
                            name:
                              type: string
                            mapped_port:
                              type: integer
                          required:
                            - url
                            - name
                            - mapped_port
                      cpu_request_count:
                        type: integer
                      cpu_limit_count:
                        type: integer
                      ram_request_gb:
                        type: integer
                      ram_limit_gb:
                        type: integer
                      gpu_request_count:
                        type: integer
                      gpu_request_ratio:
                        type: integer
                      gpu_request_gmem:
                        type: integer
                      ephemeral_storage_request_gb:
                        type: integer
                      ephemeral_storage_limit_gb:
                        type: integer
                      shm_limit_gb:
                        type: integer
                      init_commands:
                        type: object
                        properties:
                          command:
                            type: array
                            items:
                              type: string
                        required:
                          - command
                      metadata:
                        type: object
                        properties:
                          extra:
                            type: object
                            properties:
                              mount_path:
                                type: string
                              password:
                                type: string
                              token:
                                type: string
                            required:
                              - mount_path
                              - password
                              - token
                          ingress:
                            type: array
                            items:
                              type: string
                          service:
                            type: array
                            items:
                              type: string
                          ssh:
                            type: 'null'
                          version:
                            type: integer
                        required:
                          - extra
                          - ingress
                          - service
                          - ssh
                          - version
                      created_at:
                        type: string
                      started_at:
                        type: string
                      destroyed_at:
                        type: 'null'
                      StorageVolume:
                        type: 'null'
                      template_id:
                        type: integer
                      ServerTemplate:
                        type: 'null'
                      is_deleted:
                        type: boolean
                      k8s_namespace:
                        type: string
                      k8s_deployment_name:
                        type: string
                      k8s_deployment_uid:
                        type: string
                      app_name:
                        type: string
                      spend_updated_at:
                        type: 'null'
                    required:
                      - instance_id
                      - instance_name
                      - org_id
                      - user_id
                      - User
                      - UserOrganization
                      - machine_image
                      - support_ssh
                      - service_ports
                      - service_urls
                      - cpu_request_count
                      - cpu_limit_count
                      - ram_request_gb
                      - ram_limit_gb
                      - gpu_request_count
                      - gpu_request_ratio
                      - gpu_request_gmem
                      - ephemeral_storage_request_gb
                      - ephemeral_storage_limit_gb
                      - shm_limit_gb
                      - init_commands
                      - metadata
                      - created_at
                      - started_at
                      - destroyed_at
                      - StorageVolume
                      - template_id
                      - ServerTemplate
                      - is_deleted
                      - k8s_namespace
                      - k8s_deployment_name
                      - k8s_deployment_uid
                      - app_name
                      - spend_updated_at
                required:
                  - status
                  - data
              examples:
                '1':
                  summary: Success
                  value:
                    status: success
                    data:
                      instance_id: 5020
                      instance_name: lifeng-jupyter-1211
                      org_id: 1000
                      user_id: 1000
                      User: null
                      UserOrganization: null
                      machine_image: harbor.service-inference.ai/library/jupyter-torch
                      support_ssh: false
                      service_ports:
                        - port: 8888
                          protocol: TCP
                          name: lifeng-labs-1
                      service_urls:
                        - url: >-
                            https://lifeng-labs-1-8888-1738910087201.service-inference.ai
                          name: lifeng-labs-1
                          mapped_port: 8888
                        - url: >-
                            https://extra-11111-11111-1738910087683.service-inference.ai
                          name: extra-11111
                          mapped_port: 11111
                      cpu_request_count: 2
                      cpu_limit_count: 4
                      ram_request_gb: 8
                      ram_limit_gb: 16
                      gpu_request_count: 1
                      gpu_request_ratio: 20
                      gpu_request_gmem: 8
                      ephemeral_storage_request_gb: 0
                      ephemeral_storage_limit_gb: 0
                      shm_limit_gb: 1
                      init_commands:
                        command:
                          - /bin/bash
                          - '-c'
                          - >-
                            #!/bin/bash

                            set -e -x


                            env | while read -r line; do
                              if [[ $line =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then
                                name="${line%%=*}"
                                value="${line#*=}"
                                printf "export %s=%q\n" "$name" "$value" >> /home/jovyan/.bashrc
                              fi
                            done


                            echo "source /home/jovyan/.bashrc" >> /etc/profile


                            echo "PermitUserEnvironment yes" >>
                            /etc/ssh/sshd_config

                            nohup jupyter lab --no-browser --ip=0.0.0.0
                            --allow-root --NotebookApp.token='Ho9VYx15U0p3I462'
                            --NotebookApp.password='TkYCA7x60WU53248' >
                            /dev/null 2>&1 &

                            sudo /usr/sbin/sshd -D
                      metadata:
                        extra:
                          mount_path: /home/jovyan/work
                          password: TkYCA7x60WU53248
                          token: Ho9VYx15U0p3I462
                        ingress:
                          - ingress-1000-1000-1738910087201
                          - ingress-1000-1000-1738910087683
                        service:
                          - service-1000-1000-1738910086965
                          - service-1000-1000-1738910087443
                        ssh: null
                        version: 1
                      created_at: '2025-02-07T06:34:47.761768Z'
                      started_at: '2025-02-07T06:34:47.761768Z'
                      destroyed_at: null
                      StorageVolume: null
                      template_id: 3008
                      ServerTemplate: null
                      is_deleted: false
                      k8s_namespace: local
                      k8s_deployment_name: deployment-1000-1000-1738910086719
                      k8s_deployment_uid: 6521a545-b5db-40d3-a051-713918a85c09
                      app_name: server-1738910086719
                      spend_updated_at: null
          headers: {}
      security: []
  /external/api/v1/listServerInstances:
    get:
      summary: 'list '
      deprecated: false
      description: ''
      tags:
        - Server Instances
      parameters:
        - name: page_size
          in: query
          description: ''
          required: false
          example: '10'
          schema:
            type: integer
        - name: page_number
          in: query
          description: ''
          required: false
          example: '1'
          schema:
            type: integer
        - name: Api-Key
          in: header
          description: ''
          required: true
          example: '{{Api-Key}}'
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      instances:
                        type: array
                        items:
                          type: object
                          properties:
                            instance_id:
                              type: integer
                            instance_name:
                              type: string
                            org_id:
                              type: integer
                            user_metadata:
                              type: 'null'
                            user_id:
                              type: integer
                            template_id:
                              type: integer
                            template_name:
                              type: string
                            created_at:
                              type: string
                            status:
                              type: string
                            started_at:
                              type: string
                            email:
                              type: string
                            destroyed_at:
                              type: 'null'
                      total:
                        type: integer
                    required:
                      - instances
                      - total
                required:
                  - status
                  - data
              examples:
                '1':
                  summary: Success
                  value:
                    status: success
                    data:
                      instances:
                        - instance_id: 5018
                          instance_name: lifeng-jupyter-1211
                          org_id: 1000
                          user_metadata: null
                          user_id: 1000
                          template_id: 3008
                          template_name: lifeng-jupyter-1211
                          created_at: '2025-02-05T09:57:51.229937Z'
                          status: Running
                          started_at: '2025-02-05T09:57:51.229937Z'
                          email: lifeng@inference.ai
                          destroyed_at: null
                      total: 1
          headers: {}
      security: []
  /external/api/v1/deleteServerInstance:
    post:
      summary: delete
      deprecated: false
      description: ''
      tags:
        - Server Instances
      parameters:
        - name: Api-Key
          in: header
          description: ''
          required: true
          example: '{{Api-Key}}'
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                instance_id:
                  type: integer
              required:
                - instance_id
            example:
              id: 5017
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                required:
                  - status
              examples:
                '1':
                  summary: Success
                  value:
                    status: success
          headers: {}
      security: []
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://console-api.inference.ai
    description: Prod Env
security: {}
