openapi: 3.1.0
info:
  title: DTZ Core Api
  version: 2.1.0
  description: a generated client for the DTZ Core API
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  contact:
    name: Jens Walter
    email: jens@apimeister.com
servers:
- url: https://dtz.rocks/api/2021-12-09
paths:
  /context:
    get:
      summary: get current context
      description: get current context
      operationId: getCurrentContext
      responses:
        "200":
          description: status
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ContextResponse'
    post:
      summary: create new context
      description: create new context
      operationId: createContext
      x-openai-isConsequential: true
      requestBody: 
        description: create a new context
        content: 
          application/json:
            schema:
              type: object
              properties:
                alias:
                  type: string
      responses:
        "200":
          description: status
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ContextResponse'
  /context/{context_id}:
    get:
      summary: get context information
      operationId: getContext
      parameters:
        - in: path
          name: context_id
          schema:
            type: string
            format: ContextId
          required: true
          description: context id
      responses:
        "200":
          description: context information
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ContextResponse'
    post:
      summary: update context
      description: update context
      operationId: updateContext
      parameters:
        - in: path
          name: context_id
          schema:
            type: string
            format: ContextId
          required: true
          description: context id
      requestBody: 
        description: update context
        content: 
          application/json:
            schema:
              type: object
              properties:
                alias:
                  type: string
      responses:
        "200":
          description: status
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ContextResponse'
    delete:
      summary: delete context
      operationId: deleteContext
      x-openai-isConsequential: true
      parameters:
        - in: path
          name: context_id
          schema:
            type: string
            format: ContextId
          required: true
          description: context id
      responses:
        "200":
          description: status
  /context/{context_id}/enableService:
    post:
      summary: enable service for context
      operationId: enableService
      parameters:
        - in: path
          name: context_id
          schema:
            type: string
            format: ContextId
          required: true
          description: context id
      responses:
        "200":
          description: context information
  /chat:
    get:
      summary: list all chat threads for the current context
      operationId: listChat
      responses:
        "200":
          description: thread listing
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                    id:
                      type: string
                      format: ChatId
                    lastUpdate:
                      type: string
                      format: date-time
    post:
      summary: create a new chat by posting a message
      operationId: createChat
      requestBody:
        description: chat request request
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
      responses:
        "200":
          description: single response for the request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponseMessage'
  /chat/{chat_id}:
    get:
      summary: get the full chat timeline
      operationId: getChat
      parameters:
        - in: path
          name: chat_id
          schema:
            type: string
            format: ChatId
          required: true
          description: chat id
          examples:
            chatId1:
              description: sample chat id
              value: chat-r3e2m4sa
      responses:
        "200":
          description: returns the full chat
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Chat'
    post:
      summary: add a new message to the chat
      operationId: updateChat
      parameters:
        - in: path
          name: chat_id
          schema:
            type: string
            format: ChatId
          required: true
          description: chat id
      requestBody:
        description: chat post
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
      responses:
        "200":
          description: single response for the request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponseMessage'
  /certificate:
    post:
      summary: issue a certificate
      description: |
        issue a certificate - 
        if no certificate exists a new one is issued, if a certificate exists
        a new one will only be issued 3 days before its expiration
      operationId: issueCertificate
      requestBody: 
        description: issue a new certificate
        content: 
          application/json:
            schema:
              type: object
              properties:
                domain:
                  type: string
      responses:
        "200":
          description: issue certificate response
        "429":
          description: too many certificates already issued
  /task:
    post:
      summary: pull one task from the async task queue
      operationId: pullTaskFromQueue
      x-dtz-all-responses: true
      requestBody:
        description: pulls the next task
        content: 
          application/json:
            schema:
              type: object
              properties:
                nodeId:
                  type: string
                instanceId:
                  type: string
                cpuCapacity:
                  type: integer
                  format: int64
                memCapacity:
                  type: integer
                  format: int64
                ecoMode:
                  type: boolean
              required:
              - nodeId
              - instanceId
              - cpuCapacity
              - memCapacity
              - ecoMode
      responses:
        "200":
          description: success
          content: 
            application/json:
              schema:
                type: object
                properties:
                  contextId:
                    type: string
                    format: ContextId
                  executionId:
                    type: string
                    format: ExecutionId
                  taskId:
                    type: string
                    format: TaskId
                  taskName:
                    type: string
                  containerImage:
                    type: string
                  containerImageVersion:
                    type: string
                  containerPullUser:
                    type: string
                  containerPullPwd:
                    type: string
                  envVariables:
                    $ref: '#/components/schemas/EnvironmentVariables'
                required:
                - contextId
                - executionId
                - taskId
                - taskName
                - containerImage
        "204":
          description: nothing found
  /task/{task_id}:
    post:
      summary: create task for async execution
      operationId: createTask
      parameters:
        - in: path
          name: task_id
          schema:
            type: string
            format: TaskId
          required: true
          description: task id
      requestBody:
        description: create a new task
        content: 
          application/json:
            schema:
              type: object
              properties:
                taskName:
                  type: string
                service:
                  description: origin service, like dtz-flows, dtz-containers
                  type: string
                earliestStart:
                  type: string
                  format: dateTime
                latestStart:
                  type: string
                  format: dateTime
                requireEcoMode:
                  type: boolean
                taskDefinition:
                  type: object
                  properties:
                    containerImage:
                      type: string
                    containerImageVersion:
                      type: string
                    containerPullUser:
                      type: string
                    containerPullPwd:
                      type: string
                    envVariables:
                      $ref: '#/components/schemas/EnvironmentVariables'
                  required:
                  - containerImage
              required:
              - taskName
              - service
              - earliestStart
              - latestStart
              - requireEcoMode
              - taskDefinition
      responses:
        "200":
          description: success
          content: 
            application/json: 
              schema:
                type: object
                properties:
                  taskId:
                    type: string
                    format: TaskId
                  service:
                    type: string
                  executionId:
                    type: string
                    format: ExecutionId
                required:
                  - taskId
                  - service
                  - executionId
    get:
      summary: get execution history
      operationId: getTaskHistory
      parameters:
        - in: path
          name: task_id
          schema:
            type: string
            format: TaskId
          required: true
          description: task id
      responses:
        "200":
          description: success
  /ingress:
    get:
      summary: list all ingress
      operationId: listIngress
      parameters:
        - in: query
          name: scope
          schema:
            type: string
          description: only include the named scope
      responses:
        "200":
          description: success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/IngressResponse'
  /ingress/{domain}/:
    get:
      summary: get ingress for '/' path
      operationId: getRootIngress
      parameters:
        - in: path
          name: domain
          schema:
            type: string
          required: true
          description: domain name
        - in: query
          name: scope
          schema:
            type: string
          required: true
          description: only include the named scope
      responses:
        "200":
          description: success
          content: 
            application/json: 
              schema:
                $ref: '#/components/schemas/IngressResponse'
    post:
      summary: create or update ingress
      operationId: createRootIngress
      parameters:
        - in: path
          name: domain
          schema:
            type: string
          required: true
          description: domain name
      requestBody:
        description: create or update ingress
        content: 
          application/json:
            schema:
              $ref: '#/components/schemas/CreateIngressRequest'
      responses:
        "200":
          description: success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngressResponse'
    delete:
      summary: delete ingress
      operationId: deleteRootIngress
      x-openai-isConsequential: true
      parameters:
        - in: path
          name: domain
          schema:
            type: string
          required: true
          description: domain name
      responses:
        "200":
          description: status
  /ingress/{domain}/{uri}:
    get:
      summary: get ingress for '/' path
      operationId: getIngress
      parameters:
        - in: path
          name: domain
          schema:
            type: string
          required: true
          description: domain name
        - in: path
          name: uri
          schema:
            type: string
          required: true
          description: uri
        - in: query
          name: scope
          schema:
            type: string
          required: true
          description: only include the named scope
      responses:
        "200":
          description: success
          content: 
            application/json: 
              schema:
                $ref: '#/components/schemas/IngressResponse'
    post:
      summary: create static content for ingress
      operationId: createIngress
      parameters:
        - in: path
          name: domain
          schema:
            type: string
          required: true
          description: domain name
        - in: path
          name: uri
          schema:
            type: string
          required: true
          description: uri
      requestBody:
        description: serve static content for ingress
        content: 
          application/json:
            schema:
              $ref: '#/components/schemas/CreateIngressRequest'
      responses:
        "200":
          description: success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngressResponse'
    delete:
      summary: delete ingress
      operationId: deleteIngress
      x-openai-isConsequential: true
      parameters:
        - in: path
          name: domain
          schema:
            type: string
          required: true
          description: domain name
        - in: path
          name: uri
          schema:
            type: string
          required: true
          description: uri
      responses:
        "200":
          description: status
  /identity/availableContexts:
    get:
      summary: list all avaiable contexts
      operationId: listAvailableContexts
      responses:
        "200":
          description: context listing
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ContextResponse'                    
components:
  schemas:
    ContextResponse:
      type: object
      properties:
        contextId:
          type: string
          format: ContextId
        owner:
          type: string
          format: IdentityId
        created:
          type: string
          format: date-time
        alias:
          type: string
      required:
      - contextId
      - owner
      - created
    CreateIngressRequest: 
      type: object
      properties:
        scope:
          description: set the scope for this ingress, changes can only be performed within the same scope
          type: string
        validity:
          $ref: '#/components/schemas/Validity'
        login:
          $ref: '#/components/schemas/Login'
        rewrite:
          $ref: '#/components/schemas/Rewrite'
        container:
          $ref: '#/components/schemas/Container'
        staticContent:
          $ref: '#/components/schemas/StaticContent'
      required:
      - scope
    Login:
      type: object
      properties:
        providerName:
          type: string
      required:
      - providerName
    Validity:
      type: object
      properties:
        validFrom:
          description: if not present, ingress is immediately available
          type: string
          format: date-time
        validTo:
          description: if not present, ingress is available forwever
          type: string
          format: date-time
    Rewrite:
      type: object
      properties:
        source:
          description: URI source as Regex (re2 syntax)
          type: string
        target:
          description: replacement string
          type: string
      required:
        - source
        - target
    IngressResponse:
      type: object
      properties:
        domain:
          type: string
        pathPrefix:
          type: string
        scope:
          description: owning scope, changes can only be performed within the scope 
          type: string
        validity:
          $ref: '#/components/schemas/Validity'
        login:
          $ref: '#/components/schemas/Login'
        rewrite:
          $ref: '#/components/schemas/Rewrite'
        container:
          $ref: '#/components/schemas/Container'
        staticContent:
          $ref: '#/components/schemas/StaticContent'
      required:
      - domain
      - pathPrefix
    StaticContent:
      type: object
      properties:
        http:
          type: object
          properties:
            header:
              type: array
              items:
                type: object
                properties:
                  name: 
                    type: string
                  value:
                    type: string
            content:
              description: base64 encoded content
              type: string
              format: byte
          required:
          - content
        https:
          type: object
          properties:
            header:
              type: array
              items:
                type: object
                properties:
                  name: 
                    type: string
                  value:
                    type: string
            content:
              description: base64 encoded content
              type: string
              format: byte
          required:
          - content
    Container:
      type: object
      properties:
        containerImage:
          type: string
        containerImageVersion:
          type: string
        containerIdentity:
          type: string
        containerPullUser:
          type: string
        containerPullPwd:
          type: string
        envVariables:
          $ref: '#/components/schemas/EnvironmentVariables'
      required:
      - containerImage
    Chat:
      type: object
      properties:
        chatId:
          type: string
          format: chatId
        created:
          type: string
          format: date-time
        owner:
          type: string
          format: IdentityId
        privileges:
          type: object
          properties:
            allContextMembers:
              type: boolean
            nullBotRead:
              type: boolean
            nullBotWrite:
              type: boolean
            supportEmployee:
              type: boolean
        timeline:
          type: array
          items:
            type: object
            properties:
              created:
                type: string
                format: date-time
              content:
                type: string
              identityId:
                type: string
                format: IdentityId
    ChatResponseMessage:
      type: object
      properties:
        chatId:
          type: string
          format: chatId
        created:
          description: when the message was created
          type: string
          format: date-time
        content:
          type: string
        identityId:
          type: string
          format: IdentityId
          description: who the answer is from
    EnvironmentVariables:
      type: object
      additionalProperties:
        oneOf:
        - type: string
        - $ref: '#/components/schemas/EncryptedValue'
    EncryptedValue:
      type: object
      properties:
        encryptionKey:
          type: string
          description: "Encryption algorithm or key reference, e.g. 'AES256:KEY1'."
        encryptedValue:
          type: string
          description: "The base-64 encoded ciphertext."
  securitySchemes:
    dtz_oauth:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://identity.dtz.rocks/api/2021-02-21/oauth/authorize
          tokenUrl: https://identity.dtz.rocks/api/2021-02-21/oauth/token
          scopes:
            openid: general scope
    dtz_apikey:
      type: apiKey
      in: header
      name: X-API-KEY
    dtz-cookie:
      type: apiKey
      in: cookie
      name: dtz_auth
security:
  - dtz_oauth: []
  - dtz_apikey: []
  - dtz-cookie: []