openapi: 3.0.0
info:
  title: Bulk Receiver
  version: ''
  description: |
    Email and FCM receiver for QA/test

    # Enviroment Variables

    `SQS_EMAIL_URL` - endpoint URL of the SQS for email

    `SQS_PUSH_URL` - endpoint URL of the SQS for push

    `SQS_PUSH_POLLERS` - number of pollers for push (default 3)
  x-logo:
    url: ../img/cognitive_logo.svg
    backgroundColor: '#FFFFFF'
    altText: Cognitive systems logo
    href: /
paths:
  /emails/generate:
    get:
      tags:
        - EMails
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_emails-generate_200'
          description: ''
      operationId: GET_emails-generate
      summary: Generate email inbox
  /emails/list:
    get:
      tags:
        - EMails
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_emails-list_200'
          description: ''
      operationId: GET_emails-list
      summary: List all inboxes
  /emails/get:
    get:
      tags:
        - EMails
      parameters:
        - name: box
          schema:
            description: target email address
            type: string
          in: query
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_get_200'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_get_400'
          description: ''
      operationId: GET_emails-get
      summary: Retreive e-mail from inbox
  /emails/clear:
    get:
      tags:
        - EMails
      parameters:
        - name: box
          schema:
            description: target email address
            type: string
          in: query
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_clear_200'
          description: ''
      operationId: GET_emails-clear
      summary: Clear inbox
  /push/claim:
    get:
      tags:
        - Push
      parameters:
        - name: fbclient
          schema:
            description: >-
              FireBase Client key, which determines WHICH FB Client to use when
              dealing with Device Notifications
            type: string
          in: query
          required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_push-claim_200'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_push-claim_400'
          description: ''
      operationId: GET_push-claim
      summary: Claim push target
      description: If no push targets are available, a 400 will be returned.
  /client:
    get:
      tags:
        - Push
      responses:
        '200':
          description: Serves up an index.html of the push client
      operationId: GET_client
      summary: Push Client
      description: |-
        Supported Browsers: Firefox, Chrome.

        Each open Client creates 1 push target that can subsequently be claimed.

        Firefox container tabs can be used to spawn multiple inside one browser.
  /reset:
    post:
      tags:
        - Reset
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/generic_200'
          description: Reset all BulkRX state
      operationId: POST_reset
      summary: Global Reset
      description: Nuke all state from orbit
  /stats:
    get:
      tags:
        - Stats
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_stats_200'
          description: BulkRX instance statistics
      operationId: GET_stats
      summary: Stats
  /push/unclaim:
    get:
      tags:
        - Push
      parameters:
        - name: uuid
          schema:
            type: string
          in: query
        - name: fbclient
          schema:
            description: >-
              FireBase Client key used to determine which FB Client key to use
              with regards to Device Notifications.
            type: string
          in: query
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/generic_200'
          description: Unclaim a push receiver.
      operationId: GET_push-unclaim
      summary: Unclaim push target
  /push/get:
    get:
      tags:
        - Push
      parameters:
        - name: uuid
          schema:
            type: string
          in: query
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_get_200'
          description: Get messages from push receiver
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GET_get_400'
          description: Push inbox is empty
      operationId: GET_push-get
      summary: Retrieve notifications from target
  /push/clear:
    get:
      tags:
        - Push
      parameters:
        - name: uuid
          schema:
            type: string
          in: query
      responses:
        '200':
          content:
            application/json: {}
          description: Reset all responces for the given push receiver
      operationId: GET_push-clear
      summary: Clear notifications from target
components:
  schemas:
    GET_emails-generate_200:
      type: object
      properties:
        email:
          type: string
    GET_emails-list_200:
      type: object
      properties:
        emails:
          type: array
          items:
            type: string
    GET_push-claim_200:
      type: object
      properties:
        token:
          type: string
        uuid:
          type: string
    GET_push-claim_400:
      type: object
      properties:
        error:
          type: string
    GET_stats_200:
      title: Root Type for GET_stats_200
      description: BulkRX Statistics
      type: object
      properties:
        db.size:
          format: int32
          type: integer
        push.2.tokens:
          format: int32
          type: integer
        push.clients:
          format: int32
          type: integer
        push.clients.comcast:
          format: int32
          type: integer
        push.clients.comcast.idle:
          format: int32
          type: integer
        push.1.tokens:
          format: int32
          type: integer
        push.clients.halo:
          format: int32
          type: integer
        push.clients.halo.idle:
          format: int32
          type: integer
        push.clients.load:
          format: int32
          type: integer
        push.clients.load.idle:
          format: int32
          type: integer
        push.0.tokens:
          format: int32
          type: integer
        push.2.refresh:
          format: int32
          type: integer
        push.1.refresh:
          format: int32
          type: integer
        push.0.refresh:
          format: int32
          type: integer
        email.generate:
          format: int32
          type: integer
        email.receive:
          format: int32
          type: integer
        push.clients.halo.busy:
          format: int32
          type: integer
        push.halo_claim:
          format: int32
          type: integer
        push.message:
          format: int32
          type: integer
        push.get:
          format: int32
          type: integer
        push.clear:
          format: int32
          type: integer
        push.halo_unclaim:
          format: int32
          type: integer
        push.clients.load.busy:
          format: int32
          type: integer
        push.load_claim:
          format: int32
          type: integer
        push.load_unclaim:
          format: int32
          type: integer
      example:
        db.size: 51
        push.2.tokens: 3779
        push.clients: 15
        push.clients.comcast: 5
        push.clients.comcast.idle: 5
        push.1.tokens: 3734
        push.clients.halo: 5
        push.clients.halo.idle: 5
        push.clients.load: 5
        push.clients.load.idle: 5
        push.0.tokens: 3847
        push.2.refresh: 3775
        push.1.refresh: 3730
        push.0.refresh: 3840
        email.generate: 31
        email.receive: 71
        push.clients.halo.busy: 0
        push.halo_claim: 4
        push.message: 108
        push.get: 10
        push.clear: 10
        push.halo_unclaim: 4
        push.clients.load.busy: 0
        push.load_claim: 4
        push.load_unclaim: 4
    GET_clear_200:
      type: object
      properties:
        clear_ok:
          type: boolean
    GET_get_200:
      type: object
      properties:
        data:
          type: array
          items: {}
    GET_get_400:
      type: object
      properties:
        error:
          type: string
    generic_200:
      title: Root Type for POST_reset_200
      description: Reset all BulkRX state
      type: object
      properties:
        ok:
          type: boolean
      example:
        ok: true
x-tagGroups:
  - name: API Endpoints
    tags:
      - EMails
      - Push
      - Stats
      - Reset
