openapi: 3.0.0 

info:
  description: API to retrieve public IPs used by Michelin devices
  version: 1.0.0
  title: SWA-Public-IP
  contact: 
    name: Net Automation Team
    email: net-devops@michelin.com

servers:
  - url: https://indus.api.michelin.com/swa-public_ip-list-v1/
    description: Indus

security:
  - OAuth2: [MichelinPublicIPAddresses]

tags:
  - name: MichelinPublicIPAddresses
    description: Retrieve public IP used by Michelin to access internet.

paths:
  /all:
    get:
      parameters:
        - $ref: '#/components/parameters/ApiKey'
      tags:
        - MichelinPublicIPAddresses
      description: Retrieve public IP used by Michelin to access internet.
      summary: Retrieve public IP used by Michelin to access internet.
      x-swagger-router-controller: MichelinPublicIPAddresses
      responses:
        '200':
          description: 'Return list of Public IPs & Networks'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicIPResponse'
              example: |-
                [
                  {
                    "zone": "Country #1",
                    "addresses": 
                      [
                        "1.2.3.4",
                        "5.6.7.8"
                      ]
                  },
                  {
                    "zone": "Country #2",
                    "addresses": 
                      [
                        "9.10.11.12",
                        "13.14.15.6"
                      ]
                  }
                ]
        '401':
          description: 'Unauthorized: Missing or bad API Key'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Bad API Key:
                  value:
                    fault:
                      faultstring: Invalid ApiKey
                      detail:
                        errorcode: oauth.v2.InvalidApiKey
                Missing API Key:
                  value:
                    fault:
                      faultstring: Failed to resolve API Key variable request.header.apikey
                      detail:
                        errorcode: steps.oauth.v2.FailedToResolveAPIKey
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Missing client_id Header:
                  value:
                    fault:
                      faultstring: "Unresolved variable : request.header.client_id"
                      detail:
                        errorcode: steps.basicauthentication.UnresolvedVariable
                Missing client_secret Header:
                  value:
                    fault:
                      faultstring: "Unresolved variable : request.header.client_secret"
                      detail:
                        errorcode: steps.basicauthentication.UnresolvedVariable
                Wrong Credentials:
                  value:
                    fault:
                      faultstring: "Execution of ServiceCallout SC-GetAuthToken failed. Reason: ResponseCode 401 is treated as error"
                      detail:
                        errorcode: steps.servicecallout.ExecutionFailed
                Problem with Backend:
                  value:
                    fault: 
                      faultstring: "Error with Backend, contact net-devops@michelin.com"
                      detail: 
                        message: "Unauthorized"


components:
  parameters:
    ApiKey:
      name: apikey
      in: header
      description: Your app KEY from developer.michelin.com
      schema:
        type: string
      required: true 
  securitySchemes:
    OAuth2:
      type: oauth2
      description: This is the OAuth2 security scheme for the production environment
      flows:
        clientCredentials:
          tokenUrl: https://indus.api.michelin.com/idp/v1/internal/oauth/token/accesstoken?grant_type=client_credentials
          scopes: 
            MichelinPublicIPAddresses: this scope grants access to the Michelin Public IP Addresses

  schemas:
    PublicIPResponse:
      type: array
      items: 
        type: object
        properties:
          zone: 
            type: string
          addresses: 
            type: array
            items : 
              type: string
    ErrorResponse:
      type: object
      properties:
        fault:
          type: object
          properties:
            faultstring:
              type: string
              minLength: 1
            detail:
              type: object
              properties:
                errorcode:
                  type: string
                  minLength: 1
              required:
                - errorcode
          required:
            - faultstring
            - detail
      required:
      - fault

