swagger: '2.0'

info:
  title: eHealth SSL Catalogue Excel service
  version: 1.0.0
  description: eHealth SSL Catalogue Excel service
  termsOfService: http://ehealth.sundhed.dk/terms/
  license:
    name: Proprietary
  contact:
    name: Systematic A/S
    url: https://systematic.com/
    email: support.ehealth.servicedesk@systematic.com

host: ssl-catalogue-excel.{environment}.ehealth.sundhed.dk
basePath: /v1

externalDocs:
  description: "eHealth documentation"
  url: "http://ehealth-documentation.s3-website-eu-west-1.amazonaws.com/ "

tags:
  - name: CatalogueTemplate
    description: Operations with catalogue template
  - name: ExcelUpload
    description: Operation for uploading data to the SSL catalogue

schemes:
  - http
  - https

paths:
  /catalogue:
    get:
      operationId: getTemplate
      summary: Download Catalogue excel template.
      tags:
        - Catalogue
      produces:
        - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
      responses:
        200:
          description: OK
          schema:
            type: file
            format: binary
        400:
          description: The request could not be understood
          schema:
            $ref: '#/definitions/Error'
        500:
          description: The server encountered an unexpected condition which prevented it from fulfilling the request.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: 'Unexpected error'
          schema:
            $ref: '#/definitions/Error'
    post:
      operationId: importCatalogue
      summary: Upload an excel sheet with catalogue items, annotations etc.
      tags:
        - Catalogue
      consumes:
        - multipart/form-data  # and/or application/x-www-form-urlencoded
      parameters:
        - name: file
          in: formData
          description: An Excel sheet with all the catalogue and annotation items to upload in a catalogue. If no catalogue exists with a matching identifier, a new catalogue will be created, and all catalogue items and annotations will be added. If a catalogue exists with a matching identifier, the catalogue and details will be updated. To see the format of the excel, please download a template and se the description of it here.
          required: true
          type: file
      responses:
        201:
          description: Excel file was successfully uploaded and entities were successfully created or updated.
          headers:
            Location:
              type: string
              format: uri
              description: The location of the newly created or updated catalogue.
        400:
          description: The request could not be understood
          schema:
            $ref: '#/definitions/Error'
        500:
          description: The server encountered an unexpected condition which prevented it from fulfilling the request.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: 'Unexpected error'
          schema:
            $ref: '#/definitions/Error'
  /catalogue/{id}:
    get:
      operationId: exportCatalogue
      summary: Download existing Catalogue in excel sheet.
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the Catalogue to get.
          type: string
      tags:
        - Catalogue
      produces:
        - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
      responses:
        200:
          description: OK
          schema:
            type: file
            format: binary
        404:
          description: Catalogue not found
          schema:
            $ref: '#/definitions/Error'
        400:
          description: The request could not be understood
          schema:
            $ref: '#/definitions/Error'
        500:
          description: The server encountered an unexpected condition which prevented it from fulfilling the request.
          schema:
            $ref: '#/definitions/Error'
        default:
          description: 'Unexpected error'
          schema:
            $ref: '#/definitions/Error'

definitions:
  Error:
    type: object
    description: An business process error reported by the server.
    required:
      - id
      - time
      - message
    properties:
      id:
        type: string
        format: uuid
        description: Unique ID of this error.
        example: 4cf5bf7f-bf42-48dd-81bf-02b05aaf0858
      time:
        type: string
        format: date-time
        description: Date and time this error occurred.
        example: 2020-01-01T01:00:00Z
      code:
        type: string
        format: string
        description: A protocol defined code allowing the client to understand the error and act appropriately
        example: ORD00125
      message:
        type: string
        format: string
        description: An English text describing the error in end-user terms.
        example: Some server or client error
      parameters:
        type: array
        items:
          type: string
        description: Error parameters for substituting placeholders in error message.
        example: ["abc 123", "DeviceModel, Service"]
      technicalDetails:
        type: string
        format: string
        description: An detailed technical description of an internal, non-business error
        example: <A stack trace>

  Excelfile:
    type: object
    description: excel file with defined values for catalogue items, annotations, etc.
    properties:
      fileName:
        type: string
        format: binary