#  ============LICENSE_START===============================================
#  Copyright (C) 2020-2022 Nordix Foundation. All rights reserved.
#  ========================================================================
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#  ============LICENSE_END=================================================
#

openapi: 3.0.0
info:
  title: rAPP Catalogue API
  description: The Non RT-RIC Service Catalogue provides a way for services to register
    themselves for other services to discover.
  version: 1.0.0
servers:
- url: /
paths:
  /services:
    get:
      tags:
      - rAPP Catalogue API
      summary: Services
      operationId: getServices
      responses:
        "200":
          description: Services
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/service'
      deprecated: false
  /services/{serviceName}:
    get:
      tags:
      - rAPP Catalogue API
      summary: Individual Service
      operationId: getIndividualService
      parameters:
      - name: serviceName
        in: path
        description: serviceName
        required: true
        style: simple
        explode: false
        schema:
          type: string
        example: DroneIdentifier
      responses:
        "200":
          description: Service
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/service'
        "404":
          description: Service is not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_information'
      deprecated: false
    put:
      tags:
      - rAPP Catalogue API
      summary: Create or update a Service
      operationId: putIndividualService
      parameters:
      - name: serviceName
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
        example: DroneIdentifier
      requestBody:
        description: Service to create/update
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/inputService'
        required: true
      responses:
        "200":
          description: Service updated
        "201":
          description: Service created
          headers:
            Location:
              description: URL to the created Service
              style: simple
              explode: false
              schema:
                type: string
        "400":
          description: Provided service is not correct
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_information'
              example:
                detail: "Service is missing required property: version"
                status: 400
      deprecated: false
    delete:
      tags:
      - rAPP Catalogue API
      summary: Remove a Service from the catalogue
      operationId: deleteIndividualService
      parameters:
      - name: serviceName
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
        example: DroneIdentifier
      responses:
        "204":
          description: Service deleted
      deprecated: false
components:
  schemas:
    inputService:
      title: inputService
      required:
      - version
      type: object
      properties:
        version:
          type: string
          description: Version of the Service
          example: 1.0.0
        display_name:
          type: string
          description: Display name for the Service
          example: Drone Identifier
        description:
          type: string
          description: Description of the Service
          example: Detects if a UE is a drone
      description: A Service to register
    service:
      title: service
      required:
      - name
      - registrationDate
      - version
      type: object
      properties:
        name:
          type: string
          description: Unique identifier of the Service
          example: DroneIdentifier
        version:
          type: string
          description: Version of the Service
          example: 1.0.0
        display_name:
          type: string
          description: Display name for the Service
          example: Drone Identifier
        description:
          type: string
          description: Description of the Service
          example: Detects if a UE is a drone
        registrationDate:
          type: string
          description: Date when the Service was registered in the catalogue
          example: 2020-11-03
      description: A Service
    error_information:
      title: error_information
      type: object
      properties:
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence of
            the problem.
          example: Service not found
        status:
          type: integer
          description: The HTTP status code for this occurrence of the problem.
          format: int32
          example: 404
      description: Problem as defined in https://tools.ietf.org/html/rfc7807
