# Change Control
# ===============
# Version    Date       Author                Description
# 1.0.0      1/08/2022  Viswanathan Kandasamy Initial version

openapi: 3.0.0
info: 
  title: Access Management API 
  version: 1.0.0
  description: API specification for Authentication features like token generation
  contact: 
    name: Colt Reseller Support Voice
    email: ResellerSupport.Voice@colt.net
    
servers:
  - url: https://sandbox.apis.colt.net/accessManagement/oauth/v1
    description: Sandbox server 
  - url: https://apis.colt.net/accessManagement/oauth/v1
    description: Production server 
    
security:
  - basicAuth: []
  - APIKeyAuth: []  
tags: 
  - name: Authentication
paths:
  /token:
    post:
      tags: 
        - Authentication
      parameters: 
        - name: APIGWTrackingId
          in: "header"
          required: true
          schema:
            $ref: '#/components/schemas/APIGWTrackingIdType'
      responses:
        200:
          description: OK
          headers:
            APIGWTrackingId:
              description: Id to track the request end to end
              schema: 
                $ref: '#/components/schemas/APIGWTrackingIdType'          
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accessTokenResponseType'
        "400":
          description: Bad Request
          headers:
            Content-Type: 
              schema:
                type: string
                enum:
                  - application/json          
            APIGWExceptionSystem : 
              schema:
                type: string
                enum:
                  - APIGW
            APIGWExceptionCode : 
              schema:
                type: string
            APIGWTrackingId:
              description: Id to track the request end to end
              schema: 
                $ref: '#/components/schemas/APIGWTrackingIdType'              
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "401":
          description: Unauthorized
          headers:
            Content-Type: 
              schema:
                type: string
                enum:
                  - application/json  
            APIGWExceptionSystem : 
              schema:
                type: string
                enum:
                  - APIGW
            APIGWExceptionCode : 
              schema:
                type: string
            APIGWTrackingId:
              description: Id to track the request end to end
              schema: 
                $ref: '#/components/schemas/APIGWTrackingIdType'                                
          content:
            application/json:          
              schema:
                $ref: '#/components/schemas/Error'                
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
    APIKeyAuth:
      type: apiKey
      description: Unique api key for registered Apps in API Gateway
      in: header
      name: x-apikey      
  schemas:
    APIGWTrackingIdType: 
      type: string
      description: Unique identifier for the transaction
      example: abcd456e-d45645-dfaafda-1232345667dd
      pattern: "^[\\w.~:@-]{1,255}$"
    accessTokenResponseType:
      type: object
      properties:
        access_token:
          type: string
        token_type: 
          type: string
          format: Bearer
        expiry:
          type: string
    Error:
      description: 'Used when an API throws an Error, typically with a HTTP error response-code (3xx, 4xx, 5xx)'
      type: object
      required:
        - code
        - reason
      properties:
        code:
          type: string
          description: 'Application relevant detail, defined in the API or a common list.'
          example: ERR01
        reason:
          type: string
          description: Explanation of the reason for the error which can be shown to a client user.
        message:
          type: string
          description: More details and corrective actions related to the error which can be shown to a client user.
        status:
          type: string
          description: HTTP Error code extension
          example:
             "4000001"          