openapi: 3.1.0
info:
  title: HPE GreenLake API for Audit Logs
  description: >-
    The HPE GreenLake Audit Log Service offers a collection of RESTful APIs for
    publishing audit logs and querying both application-specific and overall
    platform logs.
  license:
    name: HPE License
    url: https://www.hpe.com/us/en/software/licensing.html
  version: v1
servers:
  - url: https://global.api.greenlake.hpe.com
security:
  - BearerAuth: []
paths:
  /audit-log/v1/logs:
    get:
      summary: Get all audit logs of an application or user.
      tags:
        - Audit logs - v1
      operationId: getAuditLogs
      description: >
        The audit logs can be filtered using a variety of parameters. Queries
        should be separated by `and` and can utilize `eq`, `contains`, and `in`
        operators to construct the final query. Each query should follow the
        format:

        * key eq 'value' for equality operation.

        * contains(key, 'value') for contains operation.

        * key in ('value1', 'value2') for in operation.


        | Filter parameter         | Supported Operators |
        Type                    |
        Example                                                                                        
        |

        |--------------------------|---------------------|-------------------------|-------------------------------------------------------------------------------------------------|

        | createdAt                | lt, ge              | RFC timestamp in
        string | createdAt ge
        '2024-02-16T07:54:55.0Z'                                                          
        |

        | category                 | eq, in              |
        string                  | category eq 'User Management' category in
        ('Device Management', 'User Activity')                |

        | description              | eq, contains        |
        string                  | contains(description, 'Logged in') description
        eq 'User test@test.com logged in via ping mode.' |

        | additionalInfo/ipAddress | eq, contains        | IP
        string               | additionalInfo/ipAddress eq '192.168.12.12'
        contains(additionalInfo/ipAddress, '192.168')       |

        | user/username            | eq, contains        | email in
        string         | user/username eq 'test@test.com'
        contains(user/username, '@gmail.com')                          |

        | workspace/workspaceName  | eq, contains        |
        string                  | workspace/workspaceName eq 'Example workspace'
        contains(workspace/workspaceName, 'Example')     |

        | application/id           | eq                  | UUID in
        string          | application/id eq
        '12312-123123-123123-123121'                                                 
        |

        | region                   | eq                  | region code in
        string   | region eq
        'us-west'                                                                            
        |

        | hasDetails               | eq                  |
        boolean                 | hasDetails eq
        'true'                                                                             
        |
      parameters:
        - name: filter
          in: query
          schema:
            type: string
          examples:
            contains:
              summary: Filter with category name and description
              description: >-
                Get audit logs with category *User Management* and *User
                Activity* and description *logged out*
              value: >-
                category eq 'User Management' and contains(description, 'logged
                out')
          required: false
        - name: select
          required: false
          in: query
          description: >
            Use the `select` query parameter to restrict the number of
            properties included in the audit log response.

            The supported select parameters:
             * additionalInfo
             * createdAt
             * category
             * hasDetails
             * workspace/workspaceName
             * description
             * user/username
          schema:
            type: string
          examples:
            contains:
              summary: select attributes createAt, user/username, category
              description: Get audit logs with selected attributes
              value: createdAt, user/username, category
        - name: all
          in: query
          description: >-
            Provide a free-text search to perform a comprehensive search across
            all properties for audit logs.
          schema:
            type: string
          examples:
            contains:
              description: Get audit logs that contain the provided text
              value: logged in user
        - name: limit
          in: query
          description: How many items to return at one time (max 2000)
          required: false
          schema:
            type: integer
            maximum: 2000
            default: 50
        - name: offset
          in: query
          description: Specifies the zero-based resource offset to start the response from.
          required: false
          schema:
            type: integer
            default: 0
      responses:
        '200':
          description: All audit logs.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditLogs'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - $ref: '#/components/schemas/ErrorBadRequestDetails'
              examples:
                Invalid-Filter-Expression:
                  value:
                    errorCode: HPE_GL_ERROR_BAD_REQUEST
                    httpStatusCode: 400
                    message: Bad request error
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    errorDetails:
                      - type: hpe.greenlake.bad_request
                        issues:
                          - source: query.parameter
                            subject: filter
                            description: >-
                              Invalid filter expression. Expected format is
                              'field-name operator value'.
                Invalid-Select-Expression:
                  value:
                    errorCode: HPE_GL_ERROR_BAD_REQUEST
                    httpStatusCode: 400
                    message: Bad request error
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    errorDetails:
                      - type: hpe.greenlake.bad_request
                        issues:
                          - source: query.parameter
                            subject: select
                            description: >-
                              Unsupported select attributes are passed in the
                              query parameter ['dummy'].
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - $ref: '#/components/schemas/ErrorGeneralDetails'
              examples:
                Unauthorized:
                  value:
                    errorCode: HPE_GL_ERROR_UNAUTHORIZED
                    message: UNAUTHORIZED
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    httpStatusCode: 401
                    errorDetails:
                      - type: hpe.greenlake.metadata
                        source: hpe.greenlake.audit-log
                        metadata:
                          access_token: expired
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Forbidden:
                  value:
                    errorCode: HPE_GL_ERROR_FORBIDDEN
                    message: FORBIDDEN
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    httpStatusCode: 403
                    errorDetails:
                      - type: hpe.greenlake.metadata
                        source: hpe.greenlake.audit-log
                        metadata:
                          access_token: invalid
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - $ref: '#/components/schemas/ErrorRetryDetails'
              examples:
                Internal-Server-Error:
                  value:
                    httpStatusCode: 500
                    message: INTERNAL_SERVER_ERROR
                    errorCode: HPE_GL_ERROR_INTERNAL_SERVER_ERROR
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    errorDetails:
                      - type: hpe.greenlake.retry_info
                        source: hpe.greenlake.audit-log
                        retryAfterSeconds: 30
  /audit-log/v1/logs/{id}/detail:
    get:
      summary: Get additional detail of an audit log.
      tags:
        - Audit logs - v1
      operationId: getAuditLogDetails
      parameters:
        - name: id
          in: path
          required: true
          description: >-
            Provide the ID of the audit log record that has the `hasDetails`
            value set to `true` to fetch the additional details.
          schema:
            type: string
      responses:
        '200':
          description: Audit log details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditLogDetails'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - $ref: '#/components/schemas/ErrorGeneralDetails'
              examples:
                Unauthorized:
                  value:
                    errorCode: HPE_GL_ERROR_UNAUTHORIZED
                    message: UNAUTHORIZED
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    httpStatusCode: 401
                    errorDetails:
                      - type: hpe.greenlake.metadata
                        source: hpe.greenlake.audit-log
                        metadata:
                          access_token: expired
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Forbidden:
                  value:
                    errorCode: HPE_GL_ERROR_FORBIDDEN
                    message: FORBIDDEN
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    httpStatusCode: 403
                    errorDetails:
                      - type: hpe.greenlake.metadata
                        source: hpe.greenlake.audit-log
                        metadata:
                          access_token: invalid
        '404':
          description: Record Not found
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - $ref: '#/components/schemas/ErrorNotFoundDetails'
              examples:
                Invalid_audit-record-id:
                  value:
                    errorCode: HPE_GL_ERROR_NOT_FOUND
                    httpStatusCode: 404
                    message: Audit details not found.
                    debugId: 25e86df4-e2cd-4996-a2eb-895166174941
                    errorDetails:
                      - type: hpe.greenlake.not_found
                        source: hpe.greenlake.audit-log
                        metadata:
                          id: not found
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - $ref: '#/components/schemas/ErrorRetryDetails'
              examples:
                Internal-Server-Error:
                  value:
                    httpStatusCode: 500
                    message: INTERNAL_SERVER_ERROR
                    errorCode: HPE_GL_ERROR_INTERNAL_SERVER_ERROR
                    debugId: abbeeb59-12cb-49a3-9ce5-55edba12213f
                    errorDetails:
                      - type: hpe.greenlake.retry_info
                        source: hpe.greenlake.audit-log
                        retryAfterSeconds: 30
components:
  schemas:
    AuditLogs:
      allOf:
        - type: object
          required:
            - items
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/AuditLog'
        - $ref: '#/components/schemas/PaginatedApiResponse'
    PaginatedApiResponse:
      type: object
      required:
        - count
        - next
        - total
      properties:
        count:
          description: Number of returned items
          type: integer
        offset:
          description: >-
            Specifies the offset of the returned page. Only when offset based
            pagination is used.
          type: integer
        total:
          description: Total number of items in the collection.
          type: integer
        remainingRecords:
          description: This boolean flag shows whether there are more records available
          type: boolean
    AuditLog:
      type: object
      required:
        - id
        - type
      properties:
        id:
          type: string
          description: Unique audit log ID
        type:
          type: string
          default: /audit-log/logs
          description: Resource type
        application:
          type: object
          properties:
            id:
              type: string
              description: Unique application ID
        region:
          type: string
          description: The region code associated with the application.
        user:
          type: object
          properties:
            username:
              type: string
              description: The user who performed the action.
        category:
          type: string
          description: The category of the audit log.
        description:
          type: string
          description: >-
            A short description of the changes such as subscription assignment,
            firmware upgrade, and configuration updates.
        workspace:
          type: object
          properties:
            id:
              type: string
              description: Unique workspace ID
            workspaceName:
              type: string
              description: The workspace name associated with the audit log.
        createdAt:
          type: string
          format: date-time
          description: The time the audit log was created.
        updatedAt:
          type: string
          format: date-time
          description: The time the audit log was updated.
        generation:
          type: integer
          description: if any update happened then field count will get increased.
        additionalInfo:
          type: object
          description: Returns additional attributes.
        hasDetails:
          type: boolean
          description: >-
            If set to `true`, additional details are available for the audit
            log.
    AuditLogDetails:
      type: object
      required:
        - id
        - type
        - header
        - body
      properties:
        id:
          type: string
          format: uuid
          description: audit log id
        type:
          type: string
          default: /audit-log/logs
          description: resource type
        header:
          type: string
        body:
          type: array
          items:
            type: string
    Error:
      type: object
      required:
        - errorCode
        - message
        - debugId
        - httpStatusCode
      properties:
        errorCode:
          type: string
          description: Unique machine-friendly identifier for the error.
        message:
          type: string
          description: User-friendly error message.
        debugId:
          type: string
          description: Unique identifier for the instance of this error.
        httpStatusCode:
          type: integer
          description: HTTP status code for the error.
    ErrorBadRequestDetails:
      type: object
      properties:
        errorDetails:
          description: Additional detailed information about the error.
          type: array
          items:
            required:
              - type
              - issues
            properties:
              type:
                type: string
                default: hpe.greenlake.bad_request
                description: Error type
              issues:
                type: array
                description: List of bad request issues
                items:
                  required:
                    - source
                    - subject
                  properties:
                    source:
                      type: string
                      description: The part of the request with an issue.
                    subject:
                      type: string
                      description: >-
                        The specific issue key. For example, if the source
                        property is field, the subject is the dot-separated
                        property name the issue is about
                    description:
                      type: string
                      description: A user-friendly description of the issue.
    ErrorNotFoundDetails:
      type: object
      properties:
        errorDetails:
          description: Additional detailed information about the error.
          type: array
          items:
            required:
              - type
              - source
              - metadata
            properties:
              type:
                type: string
              source:
                type: string
                description: Source of the error, typically the API group
              metadata:
                type: object
                description: >-
                  Additional key value pairs that provide information about this
                  error.
    ErrorRetryDetails:
      type: object
      properties:
        errorDetails:
          description: Additional detailed information about the error.
          type: array
          items:
            required:
              - type
              - retryAfterSeconds
            properties:
              type:
                type: string
              retryAfterSeconds:
                type: integer
    ErrorGeneralDetails:
      type: object
      properties:
        errorDetails:
          description: Additional detailed information about the error.
          type: array
          items:
            required:
              - type
              - source
              - metadata
            properties:
              type:
                type: string
                description: Error type
              source:
                type: string
                description: Source of the error, typically the API group
              metadata:
                type: object
                description: >-
                  Additional key value pairs that provide information about this
                  error.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
