openapi: 3.1.0
info:
  title: DTZ Containers
  version: 2.0.1
  description: a generated client for the DTZ Containers 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://containers.dtz.rocks/api/{version}
  variables:
    version:
      default: "2021-02-21"
      enum:
        - "2021-02-21"
paths:
  /enable:
    post:
      summary: enable the containers service
      operationId: enable
      responses:
        "200":
          description: service enabled
  /disable:
    post:
      summary: disable the containers service
      operationId: disable
      responses:
        "200":
          description: service disabled
  /domain:
    get:
      summary: get all domains
      operationId: getDomains
      responses:
        "200":
          description: success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Domain'
    post:
      summary: create a new domain
      operationId: createDomain
      requestBody: 
        description: register a new domain within dtz
        content: 
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDomain'
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/Domain'
        "409":
          description: domain already registered
  /domain/{domain_name}:
    get:
      summary: get single domain
      operationId: getDomain
      parameters:
        - in: path
          name: domain_name
          schema:
            type: string
          required: true
          description: name of the domain
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/Domain'
    delete:
      summary: delete single domain
      operationId: deleteDomain
      parameters:
        - in: path
          name: domain_name
          schema:
            type: string
          required: true
          description: name of the domain
      responses:
        "200":
          description: success
    patch:
      summary: trigger domain verification
      operationId: verifyDomain
      parameters:
        - in: path
          name: domain_name
          schema:
            type: string
          required: true
          description: name of the domain
      responses:
        "200":
          description: success
        "500":
          description: error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
  /service:
    get:
      summary: get current container services
      operationId: getServices
      responses:
        "200":
          description: status
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Service'
    post:
      summary: create a new service hosting
      operationId: createService
      requestBody: 
        description: creation request
        content: 
          application/json:
            schema:
              $ref: '#/components/schemas/CreateService'
            examples:
              basic_service:
                summary: Basic web service
                description: Deploy a simple nginx service accessible at the root path
                value:
                  prefix: "/"
                  containerImage: "nginx:latest"
              authenticated_service:
                summary: Service with DTZ authentication
                description: Deploy a web application with DTZ authentication enabled
                value:
                  prefix: "/app"
                  containerImage: "myregistry/webapp:v2.1.0"
                  login:
                    providerName: "dtz"
                  envVariables:
                    DATABASE_URL: "postgresql://localhost:5432/myapp"
                    API_KEY: "secret-api-key"
              service_with_digest:
                summary: Service with specific image digest
                description: Deploy using a specific SHA256 digest instead of a tag
                value:
                  prefix: "/secure-app"
                  containerImage: "myregistry/secure-app"
                  containerImageVersion: "@sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7"
                  login:
                    providerName: "dtz"
              private_registry_service:
                summary: Service from private registry
                description: Deploy a service from a private container registry
                value:
                  prefix: "/private-app"
                  containerImage: "private.registry.com/myapp:production"
                  containerPullUser: "username"
                  containerPullPwd: "password"
                  envVariables:
                    ENV: "production"
                    LOG_LEVEL: "info"
      responses:
        "200":
          description: success
          content: 
            application/json:
              schema:
                $ref: '#/components/schemas/Service'
  /service/{serviceId}:
    get:
      summary: get service
      operationId: getService
      parameters:
        - in: path
          name: serviceId
          schema:
            type: string
            format: ServiceId
          required: true
          description: service id
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/Service'
    post:
      summary: update service
      operationId: updateService
      parameters:
        - in: path
          name: serviceId
          schema:
            type: string
            format: ServiceId
          required: true
          description: service id
      requestBody: 
        description: update request
        content: 
          application/json:
            schema:
              type: object
              properties:
                domain:
                  description: by default this property is empty and represents that all verified domains will be added. I a domain is added through a service, this service will only be served through that domain, und new domain als also no longer added automatically.
                  type: array
                  items:
                    type: string
                prefix:
                  type: string
                containerImage:
                  type: string
                containerImageVersion:
                  type: string
                containerPullUser:
                  type: string
                containerPullPwd:
                  type: string
                envVariables:
                  type: object
                  additionalProperties:
                    oneOf:
                    - type: string
                    - type: object
                      name: EncryptedValue
                      properties:
                        encryptionKey:
                          type: string
                          description: "Encryption algorithm or key reference, e.g. 'AES256:KEY1'."
                        encryptedValue:
                          type: string
                          description: "The base-64 encoded ciphertext."
                    - type: object
                      name: PlainValue
                      properties:
                        plainValue:
                          type: string
                          description: "the plain text value for server side encryption"
                rewrite:
                  description: provids url rewriting capabilities
                  type: object
                  properties:
                    source:
                      type: string
                      description: regex to match the incoming uri
                    target:
                      description: replacement value
                      type: string
                  required:
                    - source
                    - target
              required:
                - prefix
                - containerImage
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/Service'
    delete:
      summary: delete service
      operationId: deleteService
      parameters:
        - in: path
          name: serviceId
          schema:
            type: string
            format: ServiceId
          required: true
          description: service id
      responses:
        "200":
          description: success
  /job:
    get:
      summary: list all jobs
      operationId: getJobs
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/JobResponse'
    post:
      summary: create new job
      operationId: createJob
      requestBody: 
        description: update existing hosting
        content: 
          application/json:
            schema:
              $ref: '#/components/schemas/CreateJob'
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/JobResponse'   
  /job/{job_id}:
    get:
      summary: get single job
      operationId: getJob
      parameters:
        - in: path
          name: job_id
          schema:
            type: string
            format: JobId
          required: true
          description: uuid of the job
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/JobResponse'
    post:
      summary: update single job
      operationId: updateJob
      parameters:
        - in: path
          name: job_id
          schema:
            type: string
            format: JobId
          required: true
          description: uuid of the job
      responses:
        "200":
          description: success
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/JobResponse'
    patch:
      summary: trigger single job
      operationId: triggerJob
      parameters:
        - in: path
          name: job_id
          schema:
            type: string
            format: JobId
          required: true
          description: uuid of the job
      responses:
        "200":
          description: success
        "404":
          description: job not found
    delete:
      summary: delete single job
      operationId: deleteJob
      parameters:
        - in: path
          name: job_id
          schema:
            type: string
            format: JobId
          required: true
          description: uuid of the job
      responses:
        "200":
          description: success
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        msg:
          type: string
    CreateJob:
      type: object
      properties:
        name:
          type: string
        containerImage:
          type: string
        containerPullUser:
          type: string
        containerPullPwd:
          type: string
        scheduleType:
          type: string
          enum:
          - relaxed
          - precise
          - none
        scheduleCron:
          type: string
        scheduleRepeat:
          type: string
        envVariables:
          type: object
          additionalProperties:
            oneOf:
            - type: string
            - $ref: '#/components/schemas/EncryptedValue'
            - $ref: '#/components/schemas/PlainValue'
      required:
      - name
      - containerImage
      - scheduleType
    JobResponse:
      type: object
      properties:
        id:
          type: string
          format: JobId
        name:
          type: string
        containerImage:
          type: string
        containerPullUser:
          type: string
        containerPullPwd:
          type: string
        scheduleType:
          type: string
          enum:
            - relaxed
            - precise
            - none
        scheduleRepeat:
          type: string
        scheduleCron:
          type: string
        envVariables:
          type: object
          additionalProperties:
            oneOf:
            - type: string
            - $ref: '#/components/schemas/EncryptedValue'
      required:
        - id
        - name
        - containerImage
        - scheduleType
    Domain:
      type: object
      properties:
        contextId:
          type: string
          format: ContextId
        name:
          type: string
        verified:
          type: boolean
        created:
          type: string
          format: date-time
      required:
        - contextId
        - name
        - verified
        - created
    CreateDomain:
      type: object
      properties:
        name:
          type: string
      required:
        - name
    Service:
      type: object
      properties:
        contextId:
          type: string
          format: ContextId
        domain:
          description: by default this property is empty, this property is only populated if it was part of the service creation.
          type: array
          items:
            type: string
        serviceId:
          type: string
          format: ServiceId
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
        prefix:
          type: string
        containerImage:
          type: string
        containerImageVersion:
          type: string
        containerPullUser:
          type: string
        containerPullPwd:
          type: string
        envVariables:
          type: object
          additionalProperties:
            oneOf:
            - type: string
            - $ref: '#/components/schemas/EncryptedValue'
        rewrite:
          description: provids url rewriting capabilities
          type: object
          properties:
            source:
              type: string
              description: regex to match the incoming uri
            target:
              description: replacement value
              type: string
          required:
            - source
            - target
        login:
          type: object
          properties:
            providerName:
              type: string
          required:
          - providerName
      required:
        - contextId
        - serviceId
        - created
        - prefix
        - containerImage
    CreateService:
      type: object
      properties:
        domain:
          description: by default this property is empty and represents that all verified domains will be added. I a domain is added through a service, this service will only be served through that domain, und new domain als also no longer added automatically.
          type: array
          items:
            type: string
        prefix:
          type: string
        containerImage:
          type: string
        containerImageVersion:
          type: string
        containerPullUser:
          type: string
        containerPullPwd:
          type: string
        envVariables:
          type: object
          additionalProperties:
            oneOf:
            - type: string
            - $ref: '#/components/schemas/EncryptedValue'
            - $ref: '#/components/schemas/PlainValue'
        rewrite:
          description: provids url rewriting capabilities
          type: object
          properties:
            source:
              type: string
              description: regex to match the incoming uri
            target:
              description: replacement value
              type: string
          required:
            - source
            - target
        login:
          type: object
          properties:
            providerName:
              type: string
          required:
          - providerName
      required:
        - prefix
        - containerImage
    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."
    PlainValue:
      type: object
      properties:
        plainValue:
          type: string
          description: "the plain text value for server side encryption"
  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: "default profile"
    dtz_apikey:
      type: apiKey
      in: header
      name: X-API-KEY
    dtz-cookie:
      type: apiKey
      in: cookie
      name: dtz_auth
security:
  - dtz_apikey: []
  - dtz_oauth: []
  - dtz-cookie: []