openapi: 3.0.0
info:
  title: Exports
  description: 'Exports API documentation'
  version: 1.0.0
servers:
  - url: 'https://id360.manageengine.com/api/v1'
    description: 'API Endpoint'
tags:
  - name: export
    description: 'Exports endpoint'
paths:
  /exports:
    get:
      summary: Export History
      description: Retrieves a list of all export jobs, with options to filter by status and paginate results.
      parameters:
        - in: query
          name: status
          schema:
            type: string
            enum: [ "ALL", "COMPLETED", "IN_PROGRESS", "FAILED" ] # Assuming these are possible statuses
          description: Filter exports by their status.
          example: "ALL"
        - in: query
          name: limit
          schema:
            type: integer
            format: int32
          description: The maximum number of export records to return.
          example: 0
        - in: query
          name: from
          schema:
            type: integer
            format: int32
          description: The starting index of the export records to return.
          example: 1
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                  $ref: '#/components/schemas/exportHistoryList'
  /exports/{id}:
    delete:
      summary: Delete exported report
      description: Deletes a specific exported report.
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
          description: The ID of the export job to delete.
          example: "2000000146357" # Example based on previous id sample
      responses:
        '204':
          description: No Content
  /exports/{id}/send-email:
    post:
      summary: Send Export via Email
      description: Sends an exported report via email using a specified template.
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
          description: The ID of the export job to send via email.
          example: "2000000146357" # Example based on previous id sample
        - in: query
          name: template_id
          schema:
            type: string
          required: true
          description: The ID of the email template to use for sending the export.
          example: "12345"
      responses:
        '204':
          description: No Content
  /exports/{id}/download:
    get:
      summary: Download Exported File
      description: Downloads the file for a completed export job.
      parameters:
        - in: path
          name: id
          schema:
            type: string
          required: true
          description: The ID of the export job whose file is to be downloaded.
          example: "2000000146357" # Example based on previous id sample
      responses:
        '200':
          description: OK
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
                description: The exported file content.
                example: "file-content" # Placeholder for actual file content
components:
  parameters:
    acceptHeader:
      name: Accept
      in: header
      schema:
        type: string
      description: 'Accept header for the API'
      required: false
      example: 'application/json'
  schemas:
    gendoc-attributes-schema:
      type: object
      $ref: '#/components/schemas/exportResource'

    exportResource:
      type: object
      properties:
        id:
          type: string
          description: Unique id for the export
          example: 2090900001000
          pattern: ^[0-9]+$
          readOnly: true
        name:
          type: string
          description: display name for the export
          example: Active User Sessions
          pattern: ^[A-Za-z0-9]+$
          readOnly: true
        format:
          type: string
          description: Type of the export file
          example: csv
          pattern: (csv | html | pdf | xls | xlsx | csvde)
        started_time:
          type: string
          description: Started time of th export
          pattern: ^[A-Za-z0-9:-]+$
          example: 2020-02-08 09:30:26
          readOnly: true
        status:
          type: string
          pattern: (started | scheduled | failed | exporting | completed | cancelling | stopped | initializing)
          example: completed
          description: >
            Status of the export job
            <br> 
            <strong>Available export status</strong>
            <ul>
              <li>started</li>
              <li>scheduled</li>
              <li>failed</li>
              <li>exporting</li>
              <li>completed</li>
              <li>cancelling</li>
              <li>stopped</li>
              <li>initializing</li>
            </ul>
          readOnly: true
        total_objects:
          type: string
          pattern: ^[0-9]+$
          example: 1007
          description: total count of the export file
          readOnly: true

    exportHistoryList:
      type: object
      properties:
        data:
          type: array
          items:
             $ref: '#/components/schemas/exportResource'
        meta:
          type: object
          properties:
            start_index:
              type: integer
              example: 1
            limit:
              type: integer
              example: 50
            total_no_of_objects:
              type: integer
              example: 1

    invalidParam:
      type: object
      properties:
        error_code:
          type: string
          example: "INVALID_PARAMETER"
        message:
          type: string
          example: "Invalid parameter value provided."

    unauthorized:
      type: object
      properties:
        error_code:
          type: string
          example: "UNAUTHORIZED"
        message:
          type: string
          example: "Authentication required or failed."

    serverError:
      type: object
      properties:
        error_code:
          type: string
          example: "INTERNAL_SERVER_ERROR"
        message:
          type: string
          example: "An unexpected error occurred."
  securitySchemes:
    X-ZCSRF-TOKEN:
      type: apiKey
      in: header
      name: X-ZCSRF-TOKEN
      description: >
        CSRF token to prevent cross-site request forgery attacks.
        Ensure this token is included in the request header.