openapi: 3.0.3
info:
  title: Ionroller API
  version: 1.0.1
  description: Software Delivery System for Docker Images
servers:
- url: http://ionroller.gilt.com
paths:
  /services:
    get:
      description: Lists all services
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsService'
  /services/{serviceName}:
    get:
      description: Returns service state (current and desired)
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsService'
  /services/{serviceName}/config:
    get:
      description: Returns latest service configuration
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsServiceConfig'
    put:
      description: Creates or updates service configuration
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsServiceConfig'
        required: true
      responses:
        '204':
          description: No content
    delete:
      description: Removes service configuration (all versions) if no version is currently
        deployed
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      responses:
        '204':
          description: No content
  /services/{serviceName}/configs:
    get:
      description: Returns service configuration (all versions over time)
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      - name: from
        in: query
        description: Find configurations created after this date.
        required: false
        schema:
          type: string
          format: date-time
      - name: to
        in: query
        description: Find configurations created before this date.
        required: false
        schema:
          type: string
          format: date-time
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsServiceConfig'
  /services/{serviceName}/configs/{timestamp}:
    get:
      description: Returns service configuration for specified timestamp
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      - name: timestamp
        in: path
        description: Configuration timestamp
        required: true
        schema:
          type: string
          format: date-time
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsServiceConfig'
  /services/{serviceName}/drop:
    post:
      description: Drops a release
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
              - version
              - force
              properties:
                version:
                  type: string
                config:
                  type: string
                  format: date-time
                force:
                  type: boolean
        required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: integer
                format: int64
  /services/{serviceName}/release:
    post:
      description: Requests a new release
      parameters:
      - name: serviceName
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
              - version
              properties:
                version:
                  type: string
                config:
                  type: string
                  format: date-time
        required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: integer
                format: int64
components:
  schemas:
    ComGiltIonrollerApiV1ModelsElbSettings:
      description: Settings for external ELB
      type: object
      required:
      - name
      - security_group
      - rollout_delay_minutes
      properties:
        name:
          description: Name of ELB
          type: string
        security_group:
          description: Security group for ELB instances
          type: string
        rollout_delay_minutes:
          description: Delay in minutes between rollout increments
          type: integer
          format: int32
    ComGiltIonrollerApiV1ModelsRelease:
      description: A release of a particular tag of a Docker image
      type: object
      required:
      - image
      - tag
      - config
      properties:
        image:
          description: The Docker repository and name of images to be released
          type: string
        tag:
          description: The tag for the image to be released
          type: string
        config:
          description: Configuration timestamp
          type: string
          format: date-time
        rollout_status:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsRolloutStatus'
          description: Current rollout status
    ComGiltIonrollerApiV1ModelsServiceConfig:
      description: Configuration used by a service
      type: object
      required:
      - url
      - hosted_zone_id
      - aws_account_id
      - service_role
      - image
      - port_mappings
      - run_args
      - eb
      properties:
        url:
          description: URL of endpoint pointing at service
          type: string
        hosted_zone_id:
          description: Hosted Zone ID for DNS entry
          type: string
        aws_account_id:
          description: ID of AWS account where this service is deployed
          type: string
        external_elb:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsElbSettings'
          description: Details for external ELB
        service_role:
          description: Role used to run this service; specifies policy for accessing
            S3, RDS, DynamoDb etc.
          type: string
        image:
          description: Docker image details used in deployments
          type: string
        port_mappings:
          description: List of port mappings configured for use by Docker image
          type: array
          items:
            $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsPortMapping'
        volume_mappings:
          description: List of volume mappings configured for use by Docker image
          type: array
          items:
            $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsVolumeMapping'
        run_args:
          description: Arguments passed to running Docker image
          type: array
          items:
            type: string
        eb:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsEbConfig'
          description: Elastic Beanstalk configuration including deployment bucket,
            stack name and option settings like env variables, vpc, security groups
            etc.
        remove_unused_after_minutes:
          description: When an environment becomes unused, remove it after the specified
            number of minutes
          type: integer
          format: int64
        timestamp:
          description: When this configuration has been created
          type: string
          format: date-time
    ComGiltIonrollerApiV1ModelsPortMapping:
      description: Mapping from port in Docker container to external host port
      type: object
      required:
      - internal
      - external
      properties:
        internal:
          description: Port to be forwarded from Docker container
          type: integer
          format: int32
        external:
          description: Port to be mapped to on external hosts
          type: integer
          format: int32
    ComGiltIonrollerApiV1ModelsEbConfig:
      description: Elastic Beanstalk configuration including deployment bucket, stack
        name and option settings
      type: object
      required:
      - deployment_bucket
      properties:
        deployment_bucket:
          description: Deployment bucket used to deploy Elastic Beanstalk applications
          type: string
        stack:
          description: Solution stack name (i.e. 64bit Amazon Linux 2015.03 v2.0.0
            running Docker 1.6.2)
          type: string
        settings:
          description: Elastic Beanstalk configuration option settings, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html
          type: array
          items:
            $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsOptionSetting'
        resources:
          description: Elastic Beanstalk environment resources, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html
          type: object
          additionalProperties: true
        packages:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
        sources:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
        files:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
        users:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
        groups:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
        commands:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
        container_commands:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
        services:
          description: Elastic Beanstalk container customization, see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
          type: object
          additionalProperties: true
    ComGiltIonrollerApiV1ModelsVolumeMapping:
      description: Mapping from path inside Docker container to external volume
      type: object
      required:
      - internal
      - external
      properties:
        internal:
          description: Location on image's filesystem that Docker volume is mapped
            to
          type: string
        external:
          description: Identifier or path for location to be mapped into Docker environment
          type: string
    ComGiltIonrollerApiV1ModelsServiceCurrentState:
      description: Current state of service environments
      type: object
      required:
      - environments
      properties:
        environments:
          description: List of environments and their current status
          type: array
          items:
            $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsEnvironment'
    ComGiltIonrollerApiV1ModelsEnvironment:
      description: Elastic Beanstalk Environment running in AWS
      type: object
      required:
      - release
      - health
      properties:
        release:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsRelease'
          description: Details of the release present in the environment
        health:
          description: Health of environment
          type: string
    ComGiltIonrollerApiV1ModelsOptionSetting:
      description: Elastic Beanstalk configuration option setting
      type: object
      required:
      - Namespace
      - OptionName
      - Value
      properties:
        Namespace:
          type: string
        OptionName:
          type: string
        Value:
          type: string
    ComGiltIonrollerApiV1ModelsServiceDesiredState:
      description: Desired future state of service
      type: object
      properties:
        current:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsRelease'
          description: Current release of software
        next:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsRelease'
          description: Next release of software
        future:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsRelease'
          description: Future release of software
    ComGiltIonrollerApiV1ModelsRolloutStatus:
      description: Current rollout status for release
      type: object
      properties:
        num_instances:
          description: Number of instances in external load balancer
          type: integer
          format: int32
        completed_at:
          description: Time at which latest increment completed
          type: string
          format: date-time
    ComGiltIonrollerApiV1ModelsServiceState:
      description: State of service environments
      type: object
      required:
      - current
      properties:
        current:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsServiceCurrentState'
          description: List of environments and their current status
        desired:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsServiceDesiredState'
          description: List of environments and their desired status
    ComGiltIonrollerApiV1ModelsService:
      type: object
      required:
      - name
      - state
      properties:
        name:
          type: string
        state:
          $ref: '#/components/schemas/ComGiltIonrollerApiV1ModelsServiceState'
  securitySchemes:
    user_header:
      type: apiKey
      description: Identity of the user who starts a new release, drops env or updates
        config.
      name: User
      in: header
security:
- user_header: []
