# NOTE: Do not upgrade past Swagger 2. zclient does not support OpenAPI 3 unless
# https://github.com/Yelp/bravado/issues/306 is resolved.
swagger: "2.0"
info:
  description: "API Service to schedule missions for Vehicles and AO Operators"
  version: "1.0.0"
  title: "KALI Scheduler"

# Your API spec goes here.  https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
basePath: /v1

tags:
- name: "Requests"
  description: "Query the Open Mission Requests."

- name: "Schedule"
  description: "Create schedule for AO missions."

paths:
  /missionSchedule:
    post:
      tags:
        - "Schedule"
      summary: "Assign Operators and Vehicle for Open Mission Requests"
      operationId: "generateMissionSchedule"
      produces:
        - "application/json"
      parameters:
        - name: "category"
          in: "query"
          required: true
          type: "string"
          enum:
            - "MPO"
            - "P2P"
            - "GENERAL_POOL"
        - name: "limit"
          in: "query"
          type: "integer"
          minimum: 1
          description: "Number of prioritized mission Requests to try and schedule."
          required: false
        - name: "jiraIds"
          in: "query"
          type: "string"
          description: "Comma separated list of jiraIds of missingRequests"
          required: false
        - name: "daysAfter"
          in: "query"
          type: "integer"
          default: 1
          description: "Number of days from today that the schedule is to be generated for"
          required: false
        - name: "isDryRun"
          in: "query"
          type: "boolean"
          default: false
          description: "Represents that this schedule generation is for testing purpose"
          required: false
      responses:
        "201":
          description: "Successful operation."
          schema:
            $ref: "#/definitions/MissionScheduleList"

  /missionRequests:
    get:
      tags:
        - "Requests"
      summary: "Get a list of prioritized open mission requests on JIRA"
      # This operationId maps to a method in your controller.
      # Note that the name will be converted from camelCase here
      # to snake_case in the controller.
      operationId: "getMissionRequests"
      produces:
        - application/json
      parameters:
        - name: "category"
          in: "query"
          required: true
          type: "string"
          enum:
            - "MPO"
            - "P2P"
            - "GENERAL POOL"
        - name: "limit"
          in: "query"
          type: "integer"
          minimum: 1
          default: 5
          description: "Maximum number of mission requests to return"
          required: false
      responses:
        "200":
          description: "Successful operation!"
          schema:
            $ref: "#/definitions/MissionRequestList"


definitions:

  MissionRequest:
    type: "object"
    properties:
      missionKey:
        type: "string"
        description: "JIRA ticket ID"
      levelOfAutonomy:
        type: "string"
        description: "Level of autonomy for the mission"
      missionType:
        type: "string"
        description: ""
      startLocation:
        type: "string"
        description: ""
      summary:
        type: "string"
        description: ""
      missionHoursRequested:
        type: "number"
        description: ""
      missionPriority:
        type: "integer"
      driverRequired:
        type: "string"
      softwareOperatorRequired:
        type: "string"

  MissionRequestList:
    type: "object"
    properties:
      missionRequests:
        type: "array"
        items:
          $ref: "#/definitions/MissionRequest"

  MissionSchedule:
    type: "object"
    properties:
      missionKey:
        type: "string"
      eventId:
        type: "string"
      vehicle:
        type: "string"
      driver:
        type: "string"
      swo:
        type: "string"
      startTime:
        type: "string"
      endTime:
        type: "string"
      summary:
        type: "string"
      noScheduleReason:
        type: "string"

  MissionScheduleList:
    type: "object"
    properties:
      missionSchedules:
        type: "array"
        items:
          $ref: "#/definitions/MissionSchedule"
