openapi: 3.0.1
info:
  title: OSBuild Composer - Koji
  version: '1'
  description: Service to build and push images to Koji.
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
servers:
  - url: /api/composer-koji/v1
paths:
  /status:
    get:
      summary: status
      tags: [ ]
      responses:
        '200':
          description: OK
          headers: { }
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Status'
      operationId: GetStatus
      description: Simple status handler to check whether the service is up.
  '/compose/{id}':
    get:
      summary: The status of a compose
      parameters:
        - in: path
          name: id
          schema:
            type: string
            format: uuid
            example: 123e4567-e89b-12d3-a456-426655440000
          required: true
          description: ID of compose status to get
      description: 'Get the status of a running or finished compose. This includes whether or not it succeeded, and also meta information about the result.'
      responses:
        '200':
          description: Compose status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComposeStatus'
        '400':
          description: Invalid compose id
          content:
            text/plain:
              schema:
                type: string
        '404':
          description: Unknown compose id
          content:
            text/plain:
              schema:
                type: string
  '/compose/{id}/logs':
    get:
      summary: Get logs for a compose.
      parameters:
        - in: path
          name: id
          schema:
            type: string
            format: uuid
            example: 123e4567-e89b-12d3-a456-426655440000
          required: true
          description: ID of compose status to get
      description: 'Get the status of a running or finished compose. This includes whether or not it succeeded, and also meta information about the result.'
      responses:
        '200':
          description: The logs for the given compose, in no particular format (though valid JSON).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComposeLogs'
        '400':
          description: Invalid compose id
          content:
            text/plain:
              schema:
                type: string
        '404':
          description: Unknown compose id
          content:
            text/plain:
              schema:
                type: string
  '/compose/{id}/manifests':
    get:
      summary: Get the manifests for a compose.
      parameters:
        - in: path
          name: id
          schema:
            type: string
            format: uuid
            example: 123e4567-e89b-12d3-a456-426655440000
          required: true
          description: ID of compose status to get
      description: 'Get the manifests of a running or finished compose. Returns one manifest for each image in the request. Each manifest conforms to the format defined at https://www.osbuild.org/man/osbuild-manifest.5'
      responses:
        '200':
          description: The manifest for the given compose.
          content:
            application/json:
        '400':
          description: Invalid compose id
          content:
            text/plain:
              schema:
                type: string
        '404':
          description: Unknown compose id
          content:
            text/plain:
              schema:
                type: string
  /compose:
    post:
      summary: Create compose
      description: 'Create a new compose, potentially consisting of several images and upload each to koji.'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ComposeRequest'
      responses:
        '201':
          description: Compose has started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComposeResponse'
        '400':
          description: Invalid compose request
          content:
            text/plain:
              schema:
                type: string
        '415':
          description: The content type is not supported
          content:
            text/plain:
              schema:
                type: string
components:
  schemas:
    Status:
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - OK
    ComposeStatus:
      required:
        - status
        - image_statuses
        - koji_task_id
      properties:
        status:
          $ref: '#/components/schemas/ComposeStatusValue'
        image_statuses:
          type: array
          items:
            $ref: '#/components/schemas/ImageStatus'
        koji_task_id:
          type: integer
          example: 203143
        koji_build_id:
          type: integer
          example: 42
    ComposeStatusValue:
      type: string
      enum:
        - success
        - failure
        - pending
        - registering
      example: success
    ComposeLogs:
      required:
        - koji_init_logs
        - koji_import_logs
        - image_logs
      properties:
        koji_init_logs: {}
        koji_import_logs: {}
        image_logs:
          type: array
    ImageStatus:
      required:
        - status
      properties:
        status:
          $ref: '#/components/schemas/ImageStatusValue'
    ImageStatusValue:
      type: string
      enum:
        - success
        - failure
        - pending
        - building
        - uploading
      example: success
    ComposeRequest:
      type: object
      required:
        - name
        - version
        - release
        - distribution
        - image_requests
        - koji
      properties:
        name:
          type: string
          example: Fedora-Cloud-Base
        version:
          type: string
          example: '31'
        release:
          type: string
          example: '20200907.0'
        distribution:
          type: string
          example: fedora-32
        image_requests:
          type: array
          items:
            $ref: '#/components/schemas/ImageRequest'
        koji:
          $ref: '#/components/schemas/Koji'
    ImageRequest:
      required:
        - architecture
        - image_type
        - repositories
      properties:
        architecture:
          type: string
          example: x86_64
        image_type:
          type: string
          example: ami
        repositories:
          type: array
          items:
            $ref: '#/components/schemas/Repository'
    Repository:
      type: object
      required:
        - baseurl
      properties:
        baseurl:
          type: string
          format: url
          example: 'https://cdn.redhat.com/content/dist/rhel8/8/x86_64/baseos/os/'
        gpgkey:
          type: string
          example: "-----BEGIN PGP PUBLIC KEY BLOCK-----\\n\\nmQINBErgSTsBEACh2A4b0O9t+vzC9VrVtL1AKvUWi9OPCjkvR7Xd8DtJxeeMZ5eF\\n0HtzIG58qDRybwUe89FZprB1ffuUKzdE+HcL3FbNWSSOXVjZIersdXyH3NvnLLLF\\n0DNRB2ix3bXG9Rh/RXpFsNxDp2CEMdUvbYCzE79K1EnUTVh1L0Of023FtPSZXX0c\\nu7Pb5DI5lX5YeoXO6RoodrIGYJsVBQWnrWw4xNTconUfNPk0EGZtEnzvH2zyPoJh\\nXGF+Ncu9XwbalnYde10OCvSWAZ5zTCpoLMTvQjWpbCdWXJzCm6G+/hx9upke546H\\n5IjtYm4dTIVTnc3wvDiODgBKRzOl9rEOCIgOuGtDxRxcQkjrC+xvg5Vkqn7vBUyW\\n9pHedOU+PoF3DGOM+dqv+eNKBvh9YF9ugFAQBkcG7viZgvGEMGGUpzNgN7XnS1gj\\n/DPo9mZESOYnKceve2tIC87p2hqjrxOHuI7fkZYeNIcAoa83rBltFXaBDYhWAKS1\\nPcXS1/7JzP0ky7d0L6Xbu/If5kqWQpKwUInXtySRkuraVfuK3Bpa+X1XecWi24JY\\nHVtlNX025xx1ewVzGNCTlWn1skQN2OOoQTV4C8/qFpTW6DTWYurd4+fE0OJFJZQF\\nbuhfXYwmRlVOgN5i77NTIJZJQfYFj38c/Iv5vZBPokO6mffrOTv3MHWVgQARAQAB\\ntDNSZWQgSGF0LCBJbmMuIChyZWxlYXNlIGtleSAyKSA8c2VjdXJpdHlAcmVkaGF0\\nLmNvbT6JAjYEEwECACAFAkrgSTsCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK\\nCRAZni+R/UMdUWzpD/9s5SFR/ZF3yjY5VLUFLMXIKUztNN3oc45fyLdTI3+UClKC\\n2tEruzYjqNHhqAEXa2sN1fMrsuKec61Ll2NfvJjkLKDvgVIh7kM7aslNYVOP6BTf\\nC/JJ7/ufz3UZmyViH/WDl+AYdgk3JqCIO5w5ryrC9IyBzYv2m0HqYbWfphY3uHw5\\nun3ndLJcu8+BGP5F+ONQEGl+DRH58Il9Jp3HwbRa7dvkPgEhfFR+1hI+Btta2C7E\\n0/2NKzCxZw7Lx3PBRcU92YKyaEihfy/aQKZCAuyfKiMvsmzs+4poIX7I9NQCJpyE\\nIGfINoZ7VxqHwRn/d5mw2MZTJjbzSf+Um9YJyA0iEEyD6qjriWQRbuxpQXmlAJbh\\n8okZ4gbVFv1F8MzK+4R8VvWJ0XxgtikSo72fHjwha7MAjqFnOq6eo6fEC/75g3NL\\nGht5VdpGuHk0vbdENHMC8wS99e5qXGNDued3hlTavDMlEAHl34q2H9nakTGRF5Ki\\nJUfNh3DVRGhg8cMIti21njiRh7gyFI2OccATY7bBSr79JhuNwelHuxLrCFpY7V25\\nOFktl15jZJaMxuQBqYdBgSay2G0U6D1+7VsWufpzd/Abx1/c3oi9ZaJvW22kAggq\\ndzdA27UUYjWvx42w9menJwh/0jeQcTecIUd0d0rFcw/c1pvgMMl/Q73yzKgKYw==\\n=zbHE\\n-----END PGP PUBLIC KEY BLOCK-----\\n"
    Koji:
      type: object
      required:
        - server
        - task_id
      properties:
        server:
          type: string
          format: url
          example: 'https://koji.fedoraproject.org/kojihub'
        task_id:
          type: integer
          example: 42
    ComposeResponse:
      required:
        - id
        - koji_build_id
      properties:
        id:
          type: string
          format: uuid
          example: 123e4567-e89b-12d3-a456-426655440000
        koji_build_id:
          type: integer
          example: 42
