# 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: "An open API spec for session microservice for dispatch service."
  version: "1.0.0"
  title: "zoox_dispatch_session_api"
  contact:
    name: "Infra"
    email: "infrateam@zoox.com"
    url: "https://git.zooxlabs.com/zooxco/driving/tree/master/dipatch/zoox_dispatch_session_api/"
schemes:
  - "http"
  - "https"
basePath: "/v1/"
paths:
  /sessions/:
    post:
      summary: "Adds a session for a user"
      operationId: "addSession"
      consumes:
        - "application/json"
      produces:
        - "application/json"
      parameters:
        - in: "body"
          name: "session"
          description: "Session information to be added"
          required: true
          schema:
            $ref: "#/definitions/Session"
      responses:
        "201":
          description: "Session information was successfully added to the system"
          schema:
            $ref: "#/definitions/Session"
        "400":
          description: "Invalid input is provided check parameters"
          schema:
            $ref: "#/definitions/ErrorInfo"
        "500":
          description: "Some internal server error has occurred so retry it again"
          schema:
            $ref: "#/definitions/ErrorInfo"
  /sessions/{sessionId}:
    get:
      summary: "Provides the session information by its id"
      operationId: "getSession"
      produces:
        - "application/json"
      parameters:
        - $ref: "#/parameters/SessionId"
      responses:
        "200":
          description: "Operation was successful and session info with the ID is returned"
          schema:
            $ref: "#/definitions/Session"
        "404":
          description: "Session Info with the ID was not found"
          schema:
            $ref: "#/definitions/ErrorInfo"
        "500":
          description: "Some internal server error has occurred so retry it again"
          schema:
            $ref: "#/definitions/ErrorInfo"
    delete:
      summary: "Deletes the session information"
      operationId: "deleteSession"
      parameters:
        - $ref: "#/parameters/SessionId"
      responses:
        "204":
          description: "Operation was successful and session info was deleted successfully"
        "404":
          description: "Session Info with the ID was not found"
          schema:
            $ref: "#/definitions/ErrorInfo"
        "500":
          description: "Some internal server error has occurred so retry it again"
          schema:
            $ref: "#/definitions/ErrorInfo"
definitions:
  Session:
    description: "Resource representing session information"
    type: "object"
    properties:
      id:
        type: "string"
        description: "Unique Id for the resource"
        format: "uuid"
        readOnly: true
      userId:
        type: "string"
        description: "ID of the user to which the session is related to"
        format: "uuid"
      created:
        type: "integer"
        format: "int64"
        description: "Time in epoch seconds at which the resource has been created"
        readOnly: true
      updated:
        type: "integer"
        format: "int64"
        description: "Time in epoch seconds at which the resource has been last updated"
        readOnly: true
    required:
      - userId
  ErrorInfo:
    type: "object"
    description: "Resource representing the error information"
    properties:
      statusCode:
        type: "integer"
        description: "Error code"
        readOnly: true
      message:
        type: "string"
        description: "Detail info representing the error"
        readOnly: true
    required:
      - statusCode
      - message
parameters:
  SessionId:
    in: "path"
    name: "sessionId"
    type: "string"
    description: "Id of the session whose info needs to be retrieved"
    required: true
