openapi: 3.0.1
info:
  title: FFB METIS API
  description: >-
    Swagger Documentation for FFB to access METIS API. This API provides endpoints to retrieve target data.
  version: "1.0.0"
  termsOfService: 'https://developer.fil.com/legal'
  contact:
    name: API Support
    email: support@fil.com
    url: https://fil.com/contact

  license:
    name: FIL API License
    url: http://www.fil.com/licenses/LICENSE-2.0.html
  
  x-api-template: TMPL_Book
  x-filter: {{
    status: ENV_Development,
    business-unit: BU_Publishing testing, 
    business-domain: Test,
    visibility: <Server2Server>
  }}
  x-discovery-enhancers: {{
    string1: domain-Publishing,
    string2: team-<teamname>
  }}

servers:
- url: https://api.fil.com/partner/metis/model/v1
- url: https://stage.api.fil.com/partner/metis/model/v1

security:
  - OAuth2ClientCredentials: [read]

paths:
  /target:
    get:
      summary: Metis Model Extract
      description: >-
        Metis Model Extract for Germany Funds. Retrieve target model data using the fund code.
      parameters:
        - name: portfolioType
          in: query
          required: true
          schema:
            type: string
          description: Type of the portfolio to retrieve target data for.
        - name: pfShortName
          in: query
          required: true
          schema:
            type: string
          description: Short name of the portfolio to retrieve target data for.
      responses:
        "200":
          description: Successful response with Metis model returns data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetisResponse'
        '400':
          description: 'Bad request. Refer to the more info section for details. Please check that you have entered the correct information.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
              example:
                moreInfo:
                  code: 400.01.001
                  developerMessages:
                    - invalid_request
                    - ''
                  userMessage: Invalid request data or missing mandatory parameters
                  moreInfo: ''
          headers:
            requestId:
              schema:
                type: string
                maxLength: 36
                pattern: '[a-zA-Z0-9\-_]+'
              description:
                requestId is supplied by the caller and should be a unique identifier for this call only.
        '401':
          description: Unauthorised access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
              example:
                moreInfo:
                  code: 401.01.001
                  developerMessage:
                    - access_token_expired
                    - ''
                  userMessage: The token you've supplied has expired, please supply a new token
                  moreInfo: ''
          headers:
            requestId:
              schema:
                type: string
                maxLength: 36
                pattern: '[a-zA-Z0-9\-_]+'
                description:
                  requestId is supplied by the caller and should be a unique identifier for this call only.
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
              example:
                moreInfo:
                  code: 404.01.001
                  developerMessage:
                    - RaiseFault
                    - ''
                  userMessage: Not Found
                  moreInfo: ''
          headers:
            requestId:
              schema:
                type: string
                maxLength: 36
                pattern: '[a-zA-Z0-9\-_]+'
                description:
                  requestId is supplied by the caller and should be a unique identifier for this call only.
        '429':
          description: Too many requests.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
              example:
                moreInfo:
                  code: 404.01.001
                  developerMessage:
                    - RaiseFault
                    - ''
                  userMessage: Exceeded configured rate limit for the API, please try again later
                  moreInfo: ''
          headers:
            requestId:
              schema:
                type: string
                maxLength: 36
                pattern: '[a-zA-Z0-9\-_]+'
                description:
                  requestId is supplied by the caller and should be a unique identifier for this call only.
        '500':
          description: There was an internal issue calling the service. This is likely to be a permanent error. Please contact FIL for support.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
              example:
                moreInfo:
                  code: 500.01.001
                  developerMessage:
                    - ExecutionFailed
                    - 1145501d-f824-465d-a0de-45ce11020fa3
                  userMessage: Internal Server Error
                  moreInfo: ''
          headers:
            requestId:
              schema:
                type: string
                maxLength: 36
                pattern: '[a-zA-Z0-9\-_]+'
                description:
                  requestId is supplied by the caller and should be a unique identifier for this call only.
components:
  securitySchemes:
    OAuth2ClientCredentials:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://sandbox.api.fil.com/identity/v1/tokens?grant_type=client_credentials
          scopes:
            read: Grants read access

  schemas:
    MetisResponse:
      type: object
      properties:
        pfShortName:
          type: string
          description: The short name of the portfolio.
        basketFlag:
          type: string
          description: Basket flag indicator.
        assetMapCode:
          type: string
          description: Asset map code.
        comments:
          type: string
          description: Comments regarding the model.
        effectiveDate:
          type: string
          format: date
          description: The effective date of the model.
        statusCode:
          type: object
          properties:
            code:
              type: string
              description: Status code.
            desc:
              type: string
              description: Description of the status code.
        type:
          type: object
          properties:
            code:
              type: string
              description: Type code.
            desc:
              type: string
              description: Description of the type code.
        notToBeConsumedByFode:
          type: boolean
          description: Flag indicating if not to be consumed by FODE.
        allocations:
          type: array
          items:
            type: object
            properties:
              nodeCode:
                type: string
                description: Node code.
              benchmarkWeight:
                type: number
                description: Benchmark weight.
              finalCompWeight:
                type: number
                description: Final composition weight.
              pmDelta:
                type: number
                nullable: true
                description: PM delta.
              pmDeltaLowerLimit:
                type: number
                nullable: true
                description: PM delta lower limit.
              pmDeltaUpperLimit:
                type: number
                nullable: true
                description: PM delta upper limit.
              fundTargets:
                type: array
                items:
                  type: object
                  properties:
                    tradableEntId:
                      type: integer
                      description: Tradable entity ID.
                    fmrCusip:
                      type: string
                      description: FMR CUSIP.
                    finalAlloc:
                      type: number
                      description: Final allocation.
                    fundTarget:
                      type: number
                      description: Fund target.
                    lookThroughTarget:
                      type: number
                      description: Look-through target.
                    mpAllocWeight:
                      type: number
                      description: MP allocation weight.
                    pmDelta:
                      type: number
                      nullable: true
                      description: PM delta.
                    flowDelta:
                      type: number
                      description: Flow delta.
                    baskets:
                      type: array
                      items:
                        type: object
        pmRationale:
          type: string
          description: PM rationale.

    Message:
      required:
        - moreInfo
      type: object
      description: "Schema of Message object"
      properties:
        moreInfo:
          $ref: '#/components/schemas/MoreInfo'
      example:
        moreInfo:
          code: "400"
          developerMessage:
            -  "memberCode cannot be missing or empty;"
          userMessage:  "memberCode cannot be missing or empty;"
          moreInfo: ""
          errorMessages:
            - arguement:
                key: ""
                value: ""
    MoreInfo:
      description: "Schema of MoreInfo object"
      required:
        - code
        - userMessage
      type: object
      properties:
        code:
          type: string
          maxLength: 50
          example: BR400
        developerMessage:
          type: array
          items:
            type: string
          description: message details.
          example: Missing fields
        userMessage:
          type: string
          maxLength: 100
          example: Mandatory fields Missing
        moreInfo:
          type: string
        errorMessages:
          type: array
          items:
            $ref: '#/components/schemas/ErrorMessages'
      example:
        code: 400
        developerMessage:
          -  "memberCode cannot be missing or empty;"
        userMessage:  "memberCode cannot be missing or empty;"
        moreInfo: ""
    ErrorMessages:
      type: object
      description: "Schema of errorMessage object"
      required:
        - code
        - message
      properties:
        argument:
          $ref: '#/components/schemas/Argument'
        code:
          type: string
          maxLength: 50
        userMessage:
          type: string
          maxLength: 100
    Argument:
      type: object
      description: "schema of Arguement object"
      required:
        - key
      properties:
        key:
          type: string
          description: Field name for the returned message.
          maxLength: 50
        value:
          type: string
          description: >-
            Erroneous value passed in request. Value will be sanitized for any
            HTML code before being returned.

          maxLength: 200
