openapi: 3.0.0
info:
  title: Job
  description: Job APIs for ID360
  version: 1.0.0
servers:
  - url: 'https://id360.manageengine.com/api/v1'
    description: 'API Endpoint'
tags:
  - name: job
    description: 'Job endpoint'
paths:
  /jobs:
    get:
      tags:
        - job
      summary: 'Get Jobs'
      description: 'The Get Jobs API can be used to retrieve a list of jobs.'
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/from'
        - $ref: '#/components/parameters/filter'
      responses:
        '200':
          description: 'OK'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/getAllJob'
                  meta:
                    $ref: '#/components/schemas/paginationMeta'
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.job.ALL
            - id360.job.READ

  /jobs/{id}:
    get:
      tags:
        - job
      summary: 'Get Job by ID'
      description: 'The Get Job by ID API can be used to retrieve a specific job by its ID.'
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/jobId'
      responses:
        '200':
          description: 'OK'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/jobResource'
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '404':
          description: 'Not Found'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/jobNotFound'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.job.ALL
            - id360.job.READ
    delete:
      tags:
        - job
      summary: 'Delete Job by ID'
      description: 'The Delete Job by ID API can be used to delete a specific job by its ID.'
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/jobId'
      responses:
        '204':
          description: 'No Content'
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '404':
          description: 'Not Found'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/jobNotFound'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.job.ALL
            - id360.job.DELETE

components:
  parameters:
    acceptHeader:
      name: Accept
      in: header
      schema:
        type: string
      description: 'Accept header for the API'
      required: false
      example: 'application/json'
    jobId:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: 'Unique identifier for the job'
    limit:
      in: query
      name: limit
      schema:
        type: integer
        maximum: 200
        minimum: 1
        default: 200
      description: 'Number of user creation templates to be returned in the response'
      required: false
      example: 50
    from:
      in: query
      name: from
      schema:
        type: integer
      description: 'Start range of the response'
      required: false
      example: '1'
    filter:
      in: query
      name: filter
      schema:
        type: string
      description: >
        Filter users based on a the provided SCIM filter query. Refer to filter section for more details
        <br>
        <strong>eg:</strong> module eq "Management" and status eq "COMPLETED"
      required: false
      example:  module eq "Management" and status eq "COMPLETED"
  schemas:
    gendoc-attributes-schema:
      $ref: '#/components/schemas/jobResource'
    # Resource representing a job
    jobResource:
      type: object
      properties:
        id:
          type: string
          description: 'Unique identifier for the job'
          example: '2000000000001'
        start_time:
          type: string
          format: date-time
          description: 'Start time of the job in ISO 8601 format'
          example: '2025-04-04T13:12:13.000Z'
        end_time:
          type: string
          format: date-time
          description: 'End time of the job in ISO 8601 format'
          example: '2025-04-04T13:12:16.000Z'
        action_name:
          type: string
          description: 'Name of the action performed by the job'
          example: 'Bulk User Creation'
        status:
          type: string
          description: Status of the job.
          enum:
            - 'QUEUED'
            - 'RUNNING'
            - 'WARNING'
            - 'COMPLETED'
            - 'ERROR'
          example: 'COMPLETED'
        module:
          type: string
          description: 'Module associated with the job'
          example: 'Management'
        details:
          type: object
          description: >
            Details of the job.
            <br>
            <strong>Note:</strong> This field is module-specific and may vary based on the job type.
          properties:
            entity:
              type: string
              description: 'Entity associated with the job'
              example: 'User'
            result:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    description: 'Unique identifier for the entity'
                    example: '2000000000011'
                  status:
                    type: string
                    description: 'Status of the operation on the entity'
                    example: 'SUCCESS'
                  message:
                    type: string
                    description: 'Message describing the result of the operation'
                    example: 'User created successfully'
              example:
                - id: '2000000000011'
                  status: 'SUCCESS'
                  message: 'User created successfully'
                - id: '2000000000012'
                  status: 'ERROR'
                  message: 'Email already exists'

    getAllJob:
      type: array
      items:
        $ref: '#/components/schemas/jobResource'
      example:
        - id: '2000000000001'
          start_time: '2025-04-04T13:12:13.000Z'
          end_time: '2025-04-04T13:12:16.000Z'
          action_name: 'Single User Creation'
          status: 'COMPLETED'
          module: 'Management'
        - id: '2000000000002'
          start_time: '2025-04-04T13:14:21.000Z'
          end_time: '2025-04-04T13:14:24.000Z'
          action_name: 'Bulk User Creation'
          status: 'ERROR'
          module: 'Management'
        - id: '2000000000003'
          start_time: '2025-04-04T13:15:13.000Z'
          end_time: '2025-04-04T13:15:16.000Z'
          action_name: 'Single User Creation'
          status: 'WARNING'
          module: 'Management'
        - id: '2000000000004'
          start_time: '2025-04-04T13:16:13.000Z'
          end_time: null
          action_name: 'Bulk User Creation'
          status: 'RUNNING'
          module: 'Management'
        - id: '2000000000005'
          start_time: '2025-04-04T13:18:13.000Z'
          end_time: null
          action_name: 'Bulk User Creation'
          status: 'QUEUED'
          module: 'Management'

    paginationMeta:
      type: object
      properties:
        start_index:
          type: integer
          example: '1'
          description: 'Start index of the response'
        limit:
          type: integer
          example: 200
          description: 'Number of jobs requested to be returned in the response'
        total_no_of_objects:
          type: integer
          example: 5
          description: 'Total number of jobs available'

    jobNotFound:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '----'
            title:
              type: string
              example: 'Job Not Found'
            detail:
              type: string
              example: 'The requested job does not exist or has been deleted.'
    invalidParam:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '00000107'
            title:
              type: string
              example: 'Invalid Parameter'
            detail:
              type: string
              example: 'The parameter select is invalid.'
    unauthorized:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '00000101'
            title:
              type: string
              example: 'Unauthorized'
            detail:
              type: string
              example: 'The OAuth token is invalid.'
    serverError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '00000000'
            title:
              type: string
              example: 'Internal Server Error'
            detail:
              type: string
              example: 'An unexpected internal error has occurred on the server. Please try again later.'
  securitySchemes:
    Zoho_Auth:
      type: oauth2
      x-authorization-example: 'Zoho-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f'
      flows:
        authorizationCode:
          authorizationUrl: 'https://accounts.zoho.com/oauth/v2/auth'
          tokenUrl: 'https://accounts.zoho.com/oauth/v2/token'
          scopes:
            id360.job.READ: 'Read job details'
            id360.job.DELETE: 'Delete job'
            id360.job.ALL: 'All job operations'