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