swagger: "2.0"
schemes:
  - http
  - https
host: openstf.local
basePath: /api/v1
info:
  contact:
    email: contact@openstf.io
    name: STF Team
    url: http://openstf.io/
    x-twitter: open_stf
  description: Control and manages real Smartphone devices from browser and restful apis
  license:
    name: Apache-2.0
    url: http://www.apache.org/licenses/LICENSE-2.0
  title: Smartphone Test Farm
  version: 2.3.0
  x-apisguru-categories:
    - telecom
  x-logo:
    url: https://twitter.com/open_stf/profile_image?size=original
  x-origin:
    - format: swagger
      url: https://raw.githubusercontent.com/openstf/stf/master/lib/units/api/swagger/api_v1_generated.json
      version: "2.0"
  x-providerName: openstf.io
consumes:
  - application/json
  - application/octet-stream
produces:
  - application/json
securityDefinitions:
  accessTokenAuth:
    in: header
    name: authorization
    type: apiKey
tags:
  - description: User Operations
    name: user
  - description: Device Operations
    name: devices
paths:
  /devices:
    get:
      description: The devices endpoint return list of all the STF devices including Disconnected and Offline
      operationId: getDevices
      parameters:
        - description: Fields query parameter takes a comma seperated list of fields. Only listed field will be return in response
          in: query
          name: fields
          required: false
          type: string
      responses:
        "200":
          description: List of Devices
          schema:
            $ref: "#/definitions/DeviceListResponse"
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: Device List
      tags:
        - devices
  "/devices/{serial}":
    get:
      description: The device enpoint return information about a single device
      operationId: getDeviceBySerial
      parameters:
        - description: Device Serial
          in: path
          name: serial
          required: true
          type: string
        - description: Fields query parameter takes a comma seperated list of fields. Only listed field will be return in response
          in: query
          name: fields
          required: false
          type: string
      responses:
        "200":
          description: Device Information
          schema:
            $ref: "#/definitions/DeviceResponse"
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: Device Information
      tags:
        - devices
  /swagger.json: {}
  /user:
    get:
      description: The User Profile endpoint returns information about current authorized user
      operationId: getUser
      responses:
        "200":
          description: Current User Profile information
          schema:
            $ref: "#/definitions/UserResponse"
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: User Profile
      tags:
        - user
  /user/accessTokens:
    get:
      description: The Access Tokens endpoints returns titles of all the valid access tokens
      operationId: getUserAccessTokens
      responses:
        "200":
          description: Access Tokens titles
          schema:
            $ref: "#/definitions/AccessTokensResponse"
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: Access Tokens
      tags:
        - user
  /user/devices:
    get:
      description: The User Devices endpoint returns device list owner by current authorized user
      operationId: getUserDevices
      parameters:
        - description: Fields query parameter takes a comma seperated list of fields. Only listed field will be return in response
          in: query
          name: fields
          required: false
          type: string
      responses:
        "200":
          description: Current User Devices List
          schema:
            $ref: "#/definitions/DeviceListResponse"
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: User Devices
      tags:
        - user
    post:
      description: The User Devices endpoint will request stf server for a new device.
      operationId: addUserDevice
      parameters:
        - description: Device to add
          in: body
          name: device
          required: true
          schema:
            $ref: "#/definitions/AddUserDevicePayload"
      responses:
        "200":
          description: Add User Device Status
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: Add a device to a user
      tags:
        - user
  "/user/devices/{serial}":
    delete:
      description: The User Devices endpoint will request for device release from stf server. It will return request accepted if device is being used by current user
      operationId: deleteUserDeviceBySerial
      parameters:
        - description: Device Serial
          in: path
          name: serial
          required: true
          type: string
      responses:
        "200":
          description: Delete User Device Status
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: Delete User Device
      tags:
        - user
    get:
      description: The devices enpoint return information about device owned by user
      operationId: getUserDeviceBySerial
      parameters:
        - description: Device Serial
          in: path
          name: serial
          required: true
          type: string
        - description: Fields query parameter takes a comma seperated list of fields. Only listed field will be return in response
          in: query
          name: fields
          required: false
          type: string
      responses:
        "200":
          description: Device Information owned by user
          schema:
            $ref: "#/definitions/DeviceResponse"
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: User Device
      tags:
        - user
  "/user/devices/{serial}/remoteConnect":
    delete:
      description: The device connect endpoint will request stf server to disconnect remotely
      operationId: remoteDisconnectUserDeviceBySerial
      parameters:
        - description: Device Serial
          in: path
          name: serial
          required: true
          type: string
      responses:
        "200":
          description: Remote Disonnect User Device Request Status
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: Remote Disconnect
      tags:
        - user
    post:
      description: The device connect endpoint will request stf server to connect remotely
      operationId: remoteConnectUserDeviceBySerial
      parameters:
        - description: Device Serial
          in: path
          name: serial
          required: true
          type: string
      responses:
        "200":
          description: Remote Connect User Device Request Status
          schema:
            $ref: "#/definitions/RemoteConnectUserDeviceResponse"
        default:
          description: Unexpected Error
          schema:
            $ref: "#/definitions/ErrorResponse"
      security:
        - accessTokenAuth: []
      summary: Remote Connect
      tags:
        - user
definitions:
  AccessTokensResponse:
    properties:
      tokens:
        items:
          type: string
        type: array
    required:
      - tokens
  AddUserDevicePayload:
    description: payload object for adding device to user
    properties:
      serial:
        description: Device Serial
        type: string
      timeout:
        description: Device timeout in ms. If device is kept idle for this period, it will be automatically disconnected. Default is provider group timeout
        type: integer
    required:
      - serial
  DeviceListResponse:
    properties:
      devices:
        items:
          type: object
        type: array
    required:
      - devices
  DeviceResponse:
    properties:
      device:
        type: object
    required:
      - device
  ErrorResponse:
    properties:
      message:
        type: string
    required:
      - message
  RemoteConnectUserDeviceResponse:
    properties:
      remoteConnectUrl:
        type: string
      serial:
        type: string
    required:
      - remoteConnectUrl
      - serial
  UserResponse:
    properties:
      user:
        type: object
    required:
      - user
