openapi: 3.1.0
info:
  title: Tango MAC Status Update Inbound API
  version: "0.3"
  description: |
    Async REST API: client PUTs MAC (Move/Add/Change) request status updates
    to Tango. One of `tango_request_id`, `mac_request_number`, or
    `ext_request_number` must identify the MAC request.
  x-direction: inbound
  x-source: Client System
  x-destination: Tango
servers:
  - url: https://api.tangoanalytics.com
    description: Production
  - url: https://testapi.tangoanalytics.com
    description: Test (SIT/UAT)
tags: [{name: MAC Status Update}, {name: Status}]
paths:
  /v1/spacemgmt/batch/updatemoverequest:
    put:
      summary: Submit MAC status updates (async)
      operationId: putMacStatusUpdates
      tags: [MAC Status Update]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MacStatusBatchRequest"
            examples:
              default:
                value:
                  records:
                    - ext_request_number: "REQTASK4425002"
                      status: "CANCELLED"
      responses:
        "200":
          description: Accepted.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AcceptedResponse"
  /v1/batch/status:
    get:
      summary: Poll processing status by gu_id
      operationId: getBatchStatus
      tags: [Status]
      parameters:
        - $ref: "#/components/parameters/XClient"
        - $ref: "#/components/parameters/XApiKey"
        - in: query
          name: gu_id
          required: true
          schema: { type: string, format: uuid }
      responses:
        "200":
          description: Status payload.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StatusResponse"
components:
  securitySchemes:
    xClientHeader: { type: apiKey, in: header, name: x-client }
    xApiKeyHeader: { type: apiKey, in: header, name: x-api-key }
  parameters:
    XClient: { name: x-client, in: header, required: true, schema: { type: string } }
    XApiKey: { name: x-api-key, in: header, required: true, schema: { type: string } }
  schemas:
    MacStatusBatchRequest:
      type: object
      required: [records]
      properties:
        records:
          type: array
          items:
            $ref: "#/components/schemas/MacStatusRecord"
    MacStatusRecord:
      type: object
      description: |
        One of `tango_request_id`, `mac_request_number`, or
        `ext_request_number` MUST be present to identify the MAC request
        (OAS 3.1 can't natively express XOR-required; documented here).
      required: [status]
      properties:
        mac_group: { type: string }
        tango_request_id: { type: string, description: "One of three IDs required." }
        mac_request_number: { type: string, description: "One of three IDs required. Client Label 'MAC Number'." }
        ext_request_number: { type: string, description: "One of three IDs required. Client integration ID." }
        status: { type: string, description: "Lookup; e.g., CANCELLED." }
        justification: { type: string, description: "Lookup." }
        notes: { type: string }
        c_ext_attr1: { type: string }
        c_ext_attr2: { type: string }
        c_ext_attr3: { type: string }
        c_ext_attr4: { type: string }
        c_ext_attr5: { type: string }
        n_ext_attr1: { type: number }
        n_ext_attr2: { type: number }
        n_ext_attr3: { type: number }
        n_ext_attr4: { type: number }
        n_ext_attr5: { type: number }
        d_ext_attr1: { type: string, description: "DATE." }
        d_ext_attr2: { type: string, description: "DATE." }
        d_ext_attr3: { type: string, description: "DATE." }
        d_ext_attr4: { type: string, description: "DATE." }
        d_ext_attr5: { type: string, description: "DATE." }
    AcceptedResponse:
      type: object
      required: [status, gu_id]
      properties:
        status: { type: string, enum: [OK, Error] }
        status_message: { type: string }
        gu_id: { type: string, format: uuid }
    StatusResponse:
      oneOf:
        - { type: object, properties: { status: { type: string, const: PROCESSING } } }
        - type: object
          required: [status, total_records]
          properties:
            status: { type: string, const: COMPLETED }
            total_records: { type: integer }
            errors: { type: 'null' }
        - type: object
          required: [status, total_records, errors]
          properties:
            status: { type: string, const: ERROR }
            total_records: { type: integer }
            errors:
              type: array
              items:
                type: object
                required: [record_index, error]
                properties:
                  record_index: { type: integer }
                  record_key: { type: string }
                  error: { type: string }
security:
  - xClientHeader: []
    xApiKeyHeader: []
