swagger: '2.0'
info:
  version: '2.0'
  title: active-jobs
consumes:
  - application/json
produces:
  - application/json
paths:
  /active-jobs:
    get:
      tags:
        - active-jobs
      description: Get a collection of active scheduled jobs.
      operationId: getActiveJobs
      parameters:
        - name: id
          in: query
          description: The unique numeric ID for identifying the job instance.
          required: false
          type: integer
          format: int64
        - name: actualEndDateTime
          in: query
          description: The date and time for when the job is completed.
          required: false
          type: string
          format: date-time
        - name: actualStartDateTime
          in: query
          description: The date and time for when the job actaully started to run.
          required: false
          type: string
          format: date-time
        - name: attemptsLeft
          in: query
          description: The number of attempts left for retrying the job.
          required: false
          type: integer
          format: int32
        - name: preferredStartDateTime
          in: query
          description: 'The preferred date and time for when the job should start. The date and time must be entered as a timestamp in the ISO 8601 format "YYYY-MM-DDThh:mm:ssZ".'
          required: false
          type: string
          format: date-time
        - name: priority
          in: query
          description: The priority for the job when multiple jobs are scheduled to run.
          required: false
          type: integer
          format: int32
        - name: queue
          in: query
          description: The placement of the job within the job queue.
          required: false
          type: string
        - name: recoveryInstance
          in: query
          description: 'If the job is a reattempt of a failed job, the value indentifies the instance of the failed job.'
          required: false
          type: integer
          format: int64
        - name: result
          in: query
          description: 'The status of the broadcast job. Available values:\n  S - Successful.\n  F - Failed.'
          required: false
          type: string
        - name: jobId
          in: query
          description: The unique numeric ID for identifying the job.
          required: false
          type: integer
          format: int64
        - name: sequence
          in: query
          description: Scheduling policy for the job.\n  0 - Skip missed repeating job instances.\n  1 - Run all missed repeating job instances.
          required: false
          type: integer
          format: int32
        - name: state
          in: query
          description: 'The state of the job. Available values:\n  I - The job is idle and is waiting to start at the preferred start time.\n  IF - The job is idle and is being rescheduled because the previous attempt to run the job failed.\n  R - The job is currently running.\n  RF - The job is running after the previous attempt to run the job failed.\n  C - The job completed successfully.\n  CF - The job completed, but an exception occurred.'
          required: false
          type: string
        - name: offset
          in: query
          description: 'The position within the resulting dataset where the query begins returning item records. If the offset is "5", the records that returned begin with the sixth record that matches the query parameters. If the offset is "0", the records that are returned begin with the first record that matches the query parameters.'
          required: false
          type: integer
          format: int32
        - name: limit
          in: query
          description: The maximum number of records to return.
          required: false
          type: integer
          format: int32
        - name: fields
          in: query
          description: 'The comma-separated set of properties to be returned. If no properties are specified, all properties are returned.'
          required: false
          type: string
        - name: expand
          in: query
          description: 'The comma-separated set of related resources referenced in the links to be returned. If no related resources are specified, no related resources are returned.'
          required: false
          type: string
        - name: sort
          in: query
          description: 'The comma-separated set of properties which controls the order of the items being listed, prefixed by either (-) to sort by descending order, or optionally (+) to sort by ascending order. For example, sort=name,-d which means, order the items based on the name value in ascending order, then by the id value in descending order.'
          required: false
          type: string
      responses:
        '200':
          description: A collection of active scheduled jobs.
          schema:
            $ref: '#/definitions/ActiveJobCollection'
        '400':
          description: There was a client error.
          schema:
            $ref: '#/definitions/ErrorResponseContainer'
        '500':
          description: There was a server error.
          schema:
            $ref: '#/definitions/ErrorResponseContainer'
  '/active-jobs/{id}':
    get:
      tags:
        - active-jobs
      description: Get an active scheduled job by ID.
      operationId: getActiveJobById
      parameters:
        - name: fields
          in: query
          description: 'The comma-separated set of properties to be returned. If no properties are specified, all properties are returned.'
          required: false
          type: string
        - name: expand
          in: query
          description: 'The comma-separated set of related resources referenced in the links to be returned. If no related resources are specified, no related resources are returned.'
          required: false
          type: string
        - name: sort
          in: query
          description: 'The comma-separated set of properties which controls the order of the items being listed, prefixed by either (-) to sort by descending order, or optionally (+) to sort by ascending order. For example, sort=name,-d which means, order the items based on the name value in ascending order, then by the id value in descending order.'
          required: false
          type: string
      responses:
        '200':
          description: An active scheduled job.
          schema:
            $ref: '#/definitions/ActiveJob'
        '400':
          description: There was a client error.
          schema:
            $ref: '#/definitions/ErrorResponseContainer'
        '404':
          description: The resource was not found.
        '500':
          description: There was a server error.
          schema:
            $ref: '#/definitions/ErrorResponseContainer'
    parameters:
      - name: id
        in: path
        description: The unique numeric ID for identifying the job instance.
        required: true
        type: integer
        format: int64
definitions:
  Link:
    type: object
    properties:
      href:
        type: string
        format: uri
        description: The URL of the link.
    description: Links to related resources.
  Error:
    type: object
    properties:
      code:
        type: string
        description: The error message code.
      message:
        type: string
        description: The error message.
      messageKey:
        type: string
        description: The error message key.
      messageArguments:
        type: array
        description: The arguments used to construct the error message.
        items:
          type: object
      correlationId:
        type: string
        description: The unique identifier for the request.
      locale:
        type: string
        description: The locale of the error message.
    description: The error message item model.
  ErrorResponseContainer:
    type: object
    properties:
      requestId:
        type: string
        description: The request identifier.
      errors:
        type: array
        description: The errors.
        items:
          $ref: '#/definitions/Error'
    description: The error message model.
  ActiveJob:
    type: object
    properties:
      id:
        type: integer
        format: int64
        description: The unique numeric ID for identifying the job instance.
      actualEndDateTime:
        type: string
        format: date-time
        description: The date and time for when the job is completed.
      actualStartDateTime:
        type: string
        format: date-time
        description: The date and time for when the job actaully started to run.
      attemptsLeft:
        type: integer
        format: int32
        description: The number of attempts left for retrying the job.
      preferredStartDateTime:
        type: string
        format: date-time
        description: 'The preferred date and time for when the job should start. The date and time must be entered as a timestamp in the ISO 8601 format "YYYY-MM-DDThh:mm:ssZ".'
      priority:
        type: integer
        format: int32
        description: The priority for the job when multiple jobs are scheduled to run.
      queue:
        type: string
        description: The placement of the job within the job queue.
      recoveryInstance:
        type: integer
        format: int64
        description: 'If the job is a reattempt of a failed job, the value indentifies the instance of the failed job.'
      result:
        type: string
        description: 'The status of the broadcast job. Available values:\n  S - Successful.\n  F - Failed.'
      jobId:
        type: integer
        format: int64
        description: The unique numeric ID for identifying the job.
      sequence:
        type: integer
        format: int32
        description: Scheduling policy for the job.\n  0 - Skip missed repeating job instances.\n  1 - Run all missed repeating job instances.
      state:
        type: string
        description: 'The state of the job. Available values:\n  I - The job is idle and is waiting to start at the preferred start time.\n  IF - The job is idle and is being rescheduled because the previous attempt to run the job failed.\n  R - The job is currently running.\n  RF - The job is running after the previous attempt to run the job failed.\n  C - The job completed successfully.\n  CF - The job completed, but an exception occurred.'
    description: An active scheduled job.
  ActiveJobCollection:
    type: object
    properties:
      count:
        type: integer
        format: int64
        description: The total number of items.
      items:
        type: array
        description: The items.
        items:
          $ref: '#/definitions/ActiveJob'
    description: A collection of active scheduled jobs.
