Commit 471bb00a authored by Stavros-Anastasios Charismiadis's avatar Stavros-Anastasios Charismiadis
Browse files

First draft of 2 interconnection APIs

parent f1a17e69
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -44,4 +44,7 @@ package_paths:
  configuration_api:
    path: /configuration
    openapi_file: configuration/openapi/openapi.yaml
  interconnection_api:
    path: /interconnection
    openapi_file: interconnection/openapi/openapi.yaml
+215 −0
Original line number Diff line number Diff line
openapi: 3.0.3  # The version of the OpenAPI standard
info:
  title: CCF Interconnection API
  description: APIs for interconnnecting CCFs
  version: 1.0.0
servers:
- url: "{apiRoot}/interconnection"
  variables:
    apiRoot:
      default: http://localhost:8080
      description: Base URL of the Helper service.
# 1. PATHS: Where you define your endpoints
paths:
  /interconnect:
    post:
      summary: Send a new interconnection request
      operationId: interconnect_request  # <--- Becomes 'def interconnect_request(body):' in Python
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CapifDomainDetails' # Reference to the model below
      responses:
        "201":
          description: Interconnection request succeeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CapifDomainDetails'
        "400":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Bad request
        "401":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Unauthorized
        "403":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Forbidden
        "404":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Not Found
        "500":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Internal Server Error
        "503":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Service Unavailable
        default:
          description: Generic Error
  /connect:
    post:
      summary: Create a new interconnection
      operationId: connect_ccfs  # <--- Becomes 'def connect_ccfs(body):' in Python
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CcfInstanceDetails' # Reference to the model below
      responses:
        "201":
          description: Interconnection succeeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CcfInstanceDetails'
        "400":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Bad request
        "401":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Unauthorized
        "403":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Forbidden
        "404":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Not Found
        "500":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Internal Server Error
        "503":
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Service Unavailable
        default:
          description: Generic Error
# 2. COMPONENTS: Reusable data models (Classes in Python)
components:
  schemas:
    CapifDomainDetails:
      type: object
      required:
        - dstProvDom
      properties:
        dstProvDom:
          type: string
    CcfInstanceDetails:
      type: object
      required:
        - caRoot
        - publicKey
        - srcProvDom
        - ccfId
        - dstProvDom
      properties:
        caRoot:
          type: string
        publicKey:
          type: string
        srcProvDom:
          type: string
        ccfId:
          type: string
        dstProvDom:
          type: string
    ProblemDetails:
      description: Represents additional information and details on an error response.
      properties:
        type:
          description: string providing an URI formatted according to IETF RFC 3986.
          title: type
          type: string
        title:
          description: "A short, human-readable summary of the problem type. It should\
            \ not change from occurrence to occurrence of the problem. \n"
          title: title
          type: string
        status:
          description: The HTTP status code for this occurrence of the problem.
          title: status
          type: integer
        detail:
          description: A human-readable explanation specific to this occurrence of
            the problem.
          title: detail
          type: string
        instance:
          description: string providing an URI formatted according to IETF RFC 3986.
          title: type
          type: string
        cause:
          description: |
            A machine-readable application error cause specific to this occurrence of the problem. This IE should be present and provide application-related error information, if available.
          title: cause
          type: string
        invalidParams:
          description: |
            Description of invalid parameters, for a request rejected due to invalid parameters.
          items:
            $ref: '#/components/schemas/InvalidParam'
          minItems: 1
          title: invalidParams
          type: array
        supportedFeatures:
          description: |
            A string used to indicate the features supported by an API that is used as defined in clause  6.6 in 3GPP TS 29.500. The string shall contain a bitmask indicating supported features in  hexadecimal representation Each character in the string shall take a value of "0" to "9",  "a" to "f" or "A" to "F" and shall represent the support of 4 features as described in  table 5.2.2-3. The most significant character representing the highest-numbered features shall  appear first in the string, and the character representing features 1 to 4 shall appear last  in the string. The list of features and their numbering (starting with 1) are defined  separately for each API. If the string contains a lower number of characters than there are  defined features for an API, all features that would be represented by characters that are not  present in the string are not supported.
          pattern: "^[A-Fa-f0-9]*$"
          title: supportedFeatures
          type: string
      title: ProblemDetails
      type: object
    InvalidParam:
      description: |
        Represents the description of invalid parameters, for a request rejected due to invalid parameters.
      properties:
        param:
          description: "Attribute's name encoded as a JSON Pointer, or header's name."
          title: param
          type: string
        reason:
          description: "A human-readable reason, e.g. \"must be a positive integer\"\
            ."
          title: reason
          type: string
      required:
      - param
      title: InvalidParam
      type: object
 No newline at end of file
+0 −0

Empty file added.

+19 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

import connexion

from interconnection import encoder


def main():
    app = connexion.App(__name__, specification_dir='./openapi/')
    app.app.json_encoder = encoder.JSONEncoder
    app.add_api('openapi.yaml',
                arguments={'title': 'CCF Interconnection API'},
                pythonic_params=True)

    app.run(port=8080)


if __name__ == '__main__':
    main()
+0 −0

Empty file added.

Loading