openapi: 3.0.0
info:
  title: Integration Command Log API
  description: API for managing integration command logs
  version: 1.0.0
  contact:
    name: Repzo
    url: https://repzo.com

servers:
  - url: https://sv.api.repzo.me
    description: Production server
  - url: https://staging.sv.api.repzo.me
    description: Staging server

tags:
  - name: Integration Command Log
    description: Operations related to integration command log management

paths:
  /integration-command-log:
    get:
      tags:
        - Integration Command Log
      summary: Get all integration command log records
      description: Retrieve a list of all integration command log records with optional filtering and pagination
      parameters:
        - name: limit
          in: query
          description: Maximum number of records to return
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: offset
          in: query
          description: Number of records to skip for pagination
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: sort
          in: query
          description: Field to sort by
          required: false
          schema:
            type: string
        - name: order
          in: query
          description: Sort order (asc or desc)
          required: false
          schema:
            type: string
            enum: [asc, desc]
            default: desc
        - name: filter
          in: query
          description: Filter conditions in JSON format
          required: false
          schema:
            type: string
        - name: search
          in: query
          description: Search term for text fields
          required: false
          schema:
            type: string
      responses:
        "200":
          description: List of integration command log records retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/IntegrationCommandLog"
                  total:
                    type: integer
                    description: Total number of records
        "400":
          description: Bad request
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    post:
      tags:
        - Integration Command Log
      summary: Create a new integration command log record
      description: Create a new integration command log record with the provided data
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/IntegrationCommandLogInput"
      responses:
        "201":
          description: Integration command log record created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/IntegrationCommandLog"
        "400":
          description: Bad request
        "401":
          description: Unauthorized
        "500":
          description: Internal server error

  /integration-command-log/{id}:
    get:
      tags:
        - Integration Command Log
      summary: Get integration command log record by ID
      description: Retrieve a specific integration command log record by its ID
      parameters:
        - name: id
          in: path
          required: true
          description: Integration command log record ID
          schema:
            type: string
      responses:
        "200":
          description: Integration command log record retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/IntegrationCommandLog"
        "404":
          description: Integration command log record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    put:
      tags:
        - Integration Command Log
      summary: Update integration command log record
      description: Update an existing integration command log record with new data
      parameters:
        - name: id
          in: path
          required: true
          description: Integration command log record ID
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/IntegrationCommandLogInput"
      responses:
        "200":
          description: Integration command log record updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/IntegrationCommandLog"
        "400":
          description: Bad request
        "404":
          description: Integration command log record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    delete:
      tags:
        - Integration Command Log
      summary: Delete integration command log record
      description: Delete an existing integration command log record
      parameters:
        - name: id
          in: path
          required: true
          description: Integration command log record ID
          schema:
            type: string
      responses:
        "200":
          description: Integration command log record deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Integration command log record deleted successfully
        "404":
          description: Integration command log record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error

components:
  schemas:
    IntegrationCommandLog:
      type: object
      properties:
        _id:
          type: string
          description: Unique identifier for the integration command log record
          example: "60f7b1b3e4b0e8b3f8b3f8b3"
        integrationId:
          type: string
          description: Integration identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b4"
        commandType:
          type: string
          enum: [sync, import, export, validate, transform]
          description: Type of command executed
          example: "sync"
        command:
          type: string
          description: The actual command that was executed
          example: "sync-products"
        parameters:
          type: object
          additionalProperties: true
          description: Command parameters
        status:
          type: string
          enum: [pending, running, completed, failed, cancelled]
          description: Status of the command execution
          example: "completed"
        startTime:
          type: string
          format: date-time
          description: Command start time
          example: "2023-01-15T08:00:00Z"
        endTime:
          type: string
          format: date-time
          description: Command end time
          example: "2023-01-15T08:05:00Z"
        duration:
          type: number
          description: Command execution duration in milliseconds
          example: 300000
        output:
          type: object
          additionalProperties: true
          description: Command output data
        errorLog:
          type: string
          description: Error log if command failed
        processedRecords:
          type: integer
          minimum: 0
          description: Number of records processed
        failedRecords:
          type: integer
          minimum: 0
          description: Number of records that failed processing
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata
        createdAt:
          type: string
          format: date-time
          description: Record creation timestamp
          example: "2023-01-15T08:00:00Z"
        updatedAt:
          type: string
          format: date-time
          description: Record last update timestamp
          example: "2023-01-15T10:30:00Z"
      required:
        - integrationId
        - commandType
        - command
        - status

    IntegrationCommandLogInput:
      type: object
      properties:
        integrationId:
          type: string
          description: Integration identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b4"
        commandType:
          type: string
          enum: [sync, import, export, validate, transform]
          description: Type of command executed
          example: "sync"
        command:
          type: string
          description: The actual command that was executed
          example: "sync-products"
        parameters:
          type: object
          additionalProperties: true
          description: Command parameters
        status:
          type: string
          enum: [pending, running, completed, failed, cancelled]
          description: Status of the command execution
          example: "completed"
        startTime:
          type: string
          format: date-time
          description: Command start time
          example: "2023-01-15T08:00:00Z"
        endTime:
          type: string
          format: date-time
          description: Command end time
          example: "2023-01-15T08:05:00Z"
        duration:
          type: number
          description: Command execution duration in milliseconds
          example: 300000
        output:
          type: object
          additionalProperties: true
          description: Command output data
        errorLog:
          type: string
          description: Error log if command failed
        processedRecords:
          type: integer
          minimum: 0
          description: Number of records processed
        failedRecords:
          type: integer
          minimum: 0
          description: Number of records that failed processing
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata
      required:
        - integrationId
        - commandType
        - command
        - status

  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key

security:
  - ApiKeyAuth: []
