openapi: 3.0.3
info:
  title: LibrePages Conductor - OpenAPI 3.0
  description: |-

    Conductor is the deployment manager used internally in LibrePages. It is
    responsible for creating, updating and deleting websites that are deployed
    with LibrePages

    Some useful links:
    - [LibrePages Conductor repository](https://git.batsense.net/LibrePages/conductor)
  termsOfService: http://libreapages.org/terms/
  contact:
    email: contact@libreapages.org
  license:
    name: AGPLv3 or later version
    url: https://www.gnu.org/licenses/agpl.html
  version: 0.1.0
externalDocs:
  description: LibrePages Conductor - internal service to update deployments
  url: http://git.batsense.net/LibrePages/conductor

tags:
  - name: meta
    description: Information about the system
  - name: site
    description: Information about customer site deployments
paths:
  /api/v1/events/new:
    post:
      tags:
        - site
      summary: Post new event to Conductor
      description: Conductor schedules jobs based on events posted to it.
      operationId: eventsNew
      responses:
        "201":
          description: Successful operation
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/eventsNewPayloadNewSite"
                  - $ref: "#/components/schemas/eventsNewPayloadConfig"
                  - $ref: "#/components/schemas/eventsNewPayloadDeleteSite"
  /api/v1/meta/build:
    get:
      tags:
        - meta
      summary: Get binary's build information
      description: Update an existing pet by Idinformation
      operationId: metaBuild
      responses:
        "200":
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BuildInformation"
  /api/v1/meta/health:
    get:
      tags:
        - meta
      summary: Get instance's health information
      description: Get instance's health information
      operationId: metaHealth
      responses:
        "200":
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HealthInformation"


components:
  schemas:
    BuildInformation:
      required:
        - version
        - git_commit_hash
        - source_code
      type: object
      properties:
        version:
          type: string
          example: v0.1.0
        git_commit_hash:
          type: string
          example: 1fa28ef9b70bb04d6c76eee9e9bc5be77005b4b0
        source_code:
          type: string
          example: https://git.batsense.net/LibrePages
    HealthInformation:
      required:
        - conductor
      type: object
      properties:
        conductor:
          type: boolean
          example: true

    eventsNewPayloadConfig:
      type: object
      required:
         - data
      properties:
        data:
          $ref: '#/components/schemas/LibConfigConfig'
    LibConfigConfig:
      properties:
        source:
          $ref: '#/components/schemas/LibConfigSource'
        forms:
          $ref: '#/components/schemas/LibConfigForms'
        domains:
          type: array
          items:
            type: string
          example: ["example.com", "testing.example.org"]
        image_compression:
          $ref: '#/components/schemas/LibConfigImageCompression'
        redirects:
          $ref: '#/components/schemas/LibConfigRedirects'

    LibConfigSource:
      properties:
        production_branch:
          type: string
          example: "librepages"
        staging_branch:
          type: string
          example: "librepages-staging"

    LibConfigForms:
      properties:
        enabled:
          type: boolean
          example: false
            
    LibConfigImageCompression:
      properties:
        enabled:
          type: boolean
          example: false

    LibConfigRedirects:
      properties:
        from:
          type: string
          example: "/from"
        to:
          type: string
          example: "/to"


    eventsNewPayloadNewSite:
      properties:
        hostname:
          type: string
          example: "example.org"
        path:
          type: string
          example: "/tmp/example.org"
        branch:
          type: string
          example: "librepages"

    eventsNewPayloadDeleteSite:
      properties:
        hostname:
          type: string
          example: "example.org"

  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
