components:
  schemas:
    AbacusStateBulkPut:
      additionalProperties: false
      example:
        action_status: complete
        message: auto-completed
        parent_table_id: 1
      properties:
        action_status:
          description: One of 'init', 'running', 'error', 'complete', 'approved',
            or 'rejected'
          enum:
          - init
          - running
          - error
          - complete
          - approved
          - rejected
          type: string
        message:
          description: A description or message about the status
          nullable: true
          type: string
        parent_table_id:
          description: ID of the entity in the parent table.
          minimum: 0
          type: integer
      required:
      - action_status
      - parent_table_id
      title: Abacus state bulk PUT request body
      type: object
    AbacusStateBulkQuery:
      additionalProperties: false
      example:
        action_name: deliver_sales_files
        parent_table_ids:
        - 1
        - 2
        - 3
        parent_table_name: accounting_period
      properties:
        action_name:
          description: Action name to filter by
          minLength: 1
          type: string
        parent_table_ids:
          description: List of parent table IDs to filter by (requires parent_table_name)
          items:
            minimum: 0
            type: integer
          type: array
        parent_table_name:
          description: Name of parent table to filter by
          minLength: 1
          type: string
      title: Abacus state bulk query body parameters
      type: object
    AbacusStateBulkQueryResponse:
      additionalProperties: false
      example:
        items:
        - abacus_state_id: 1
          action_name: deliver_sales_files
          action_status: complete
          parent_table_id: 1
          parent_table_name: accounting_period
        limit: 100
        offset: 0
        total: 150
      properties:
        items:
          description: List of abacus states
          items:
            $ref: '#/components/schemas/AbacusStateDetail'
          type: array
        limit:
          description: Maximum number of results returned
          type: integer
        offset:
          description: Number of results skipped
          type: integer
        total:
          description: Total number of results matching the filters
          type: integer
      required:
      - items
      - limit
      - offset
      - total
      title: Abacus state bulk query response
      type: object
    AbacusStateDetail:
      additionalProperties: false
      example:
        abacus_state_id: 1
        action_name: upload_exchange_rates
        action_status: complete
        created_at: 2020-02-02 02:20:02+0000
        created_by: 00000000-0000-0000-0000-00000000000d
        last_modified: 2020-02-03 02:20:02+0000
        last_modified_by: 00000000-1111-1111-1111-00000000000d
        message: null
      properties:
        abacus_state_id:
          description: The ID of the state action
          example: 1
          minimum: 0
          type: integer
        action_name:
          description: The abacus action's name
          minLength: 1
          type: string
        action_status:
          description: One of 'init', 'running', 'error', 'complete', 'approved',
            or 'rejected'
          enum:
          - init
          - running
          - error
          - complete
          - approved
          - rejected
          type: string
        created_at:
          description: Datetime when the state was created
          format: null
          pattern: null
          type: string
        created_by:
          description: identity id of the user who created the state
          minLength: 1
          type: string
        last_modified:
          description: Datetime when the state was last modified
          format: null
          pattern: null
          type: string
        last_modified_by:
          description: identity id of the user who last modified the state
          minLength: 1
          type: string
        message:
          description: A description or message about the status
          nullable: true
          type: string
        parent_table_id:
          description: The ID of the parent table
          minimum: 0
          type: integer
        parent_table_name:
          description: Parent table name
          minLength: 1
          type: string
      required:
      - abacus_state_id
      - action_name
      - action_status
      - created_at
      - created_by
      - last_modified
      - last_modified_by
      - parent_table_id
      - parent_table_name
      title: Abacus state details
      type: object
    AbacusStateIdsPostBody:
      example:
      - 1
      - 2
      - 3
      - 4
      items:
        description: State ids list
        type: integer
      title: Abacus state ID's POST request body
      type: array
    AbacusStatePost:
      additionalProperties: false
      example:
        action_name: upload_exchange_rates
        parent_table_id: 1
        parent_table_name: accounting_period
      properties:
        action_name:
          description: Name of abacus action
          minLength: 1
          type: string
        parent_table_id:
          description: ID of the entity in the parent table. If parent_table_name
            is 'accounting_period', then parent_table_id should be a valid accounting_period_id.
          minimum: 0
          type: integer
        parent_table_name:
          description: Name of parent table -- used with parent_table_id. If parent_table_name
            is 'accounting_period', then parent_table_id should be a valid accounting_period_id.
          minLength: 1
          type: string
      required:
      - action_name
      - parent_table_id
      - parent_table_name
      title: Abacus state POST request body
      type: object
    AbacusStatePut:
      additionalProperties: false
      example:
        action_status: rejected
        message: A reason sent from a 3rd party API (i.e. Payoneer)
      properties:
        action_status:
          description: One of 'init', 'running', 'error', 'complete', 'approved',
            or 'rejected'
          enum:
          - init
          - running
          - error
          - complete
          - approved
          - rejected
          type: string
        message:
          description: A description or message about the status
          nullable: true
          type: string
      required:
      - action_status
      title: Abacus state PUT request body
      type: object
    HealthDetail:
      additionalProperties: false
      properties:
        status:
          type: string
      required:
      - status
      type: object
info:
  title: ows-abacus-state API Specifications
  version: 1.0.0
openapi: 3.0.0
paths:
  /abacus-state/dataloader:
    post:
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AbacusStateIdsPostBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AbacusStateDetail'
                type: array
          description: OK
        '400':
          content:
            application/json:
              schema: {}
          description: Bad data received in payload
      summary: Dataload states by state ids
  /abacus-state/{object_id}:
    put:
      parameters:
      - description: ID of abacus state
        in: path
        name: object_id
        required: true
        schema:
          format: int32
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AbacusStatePut'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AbacusStateDetail'
          description: OK
      summary: Update action status of specified abacus state
  /abacus-state/{parent_table_name}/{parent_table_id}:
    get:
      parameters:
      - description: An ID of a record in the parent_table
        in: path
        name: parent_table_id
        required: true
        schema:
          format: int32
          type: integer
      - description: Name of the royalty_accounting datatable
        in: path
        name: parent_table_name
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AbacusStateDetail'
                type: array
          description: OK
      summary: Retrieves abacus state actions details
  /abacus-state/{parent_table_name}/{parent_table_id}/reset:
    put:
      parameters:
      - description: An ID of a record in the parent_table
        in: path
        name: parent_table_id
        required: true
        schema:
          format: int32
          type: integer
      - description: Name of the royalty_accounting datatable
        in: path
        name: parent_table_name
        required: true
        schema:
          type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AbacusStateDetail'
                type: array
          description: OK
      summary: Reset abacus state actions
  /abacus-states:
    post:
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              items:
                $ref: '#/components/schemas/AbacusStatePost'
              type: array
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AbacusStateDetail'
          description: OK
      summary: Create abacus states
  /abacus-states/query:
    post:
      parameters:
      - description: 'Maximum number of results to return (default: 100, max: 300,
          min: 0)'
        in: query
        name: limit
        required: false
        schema:
          default: 100
          maximum: 300
          minimum: 0
          type: integer
      - description: 'Number of results to skip (default: 0, max: 2147483647)'
        in: query
        name: offset
        required: false
        schema:
          default: 0
          maximum: 2147483647
          minimum: 0
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AbacusStateBulkQuery'
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AbacusStateBulkQueryResponse'
          description: OK
      summary: Bulk query abacus states with filters and pagination
  /abacus-states/{parent_table_name}:
    put:
      parameters:
      - description: Name of the royalty_accounting datatable
        in: path
        name: parent_table_name
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              items:
                $ref: '#/components/schemas/AbacusStateBulkPut'
              type: array
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AbacusStateDetail'
                type: array
          description: OK
      summary: Update action status of abacus states
  /abacus-states/{parent_table_name}/{parent_table_id}/:
    post:
      parameters:
      - description: ID of the particular record in the parent table for which to
          create states
        in: path
        name: parent_table_id
        required: true
        schema:
          format: int32
          type: integer
      - description: Name of the royalty_accounting datatable
        in: path
        name: parent_table_name
        required: true
        schema:
          type: string
      responses:
        '201':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/AbacusStateDetail'
                type: array
          description: OK
      summary: Create abacus_state records for specified parent table. No request
        body.
  /hello/:
    get:
      description: Check the health of the application.
      parameters: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthDetail'
          description: OK
servers:
- description: QA server
  url: https://qa-ows-abacus-state.theorchard.io
