openapi: "3.0.2"
info:
  title: GO_SVC_TEMPLATE RESTful(ish)Api
  version: "1.0"
  description: The API for GO_SVC_TEMPLATE.
servers:
  - url: https://go-mcp-host-dns.local/api/v1
    description: GO_SVC_TEMPLATE RESTful(ish)Api

tags:
  - name: "Examples"
    description: "Everything about examples"

components:
  securitySchemes:

    BearerToken:
      type: http
      description: PHDP Access Token
      scheme: bearer
      bearerFormat: JWT

    ServiceAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Service to Service secret authentication

  schemas:
    Example:
      type: object
      properties:
        name:
          type: string
        attribute:
          type: string
      required:
        - name
        - attribute

paths:
  /public/example/{attribute}:
    get:
      tags:
        - "Example"
      summary: Get the example with the given attribute
      parameters:
        - name: attribute
          in: path
          required: true
          description: requested attribute
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: OK, if the example with given attribute was found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Example'
        "404":
          description: NOT FOUND, if the consent was not found

  /internal/example/:
    post:
      tags:
        - "Example"
      security:
        - ServiceAuth: []
      summary: Upsert example
      requestBody:
        description: Request to add a program
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Program"
      responses:
        "204":
          description: NO CONTENT, if the bearer token, progrmam name and program are valid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Example'
        "409":
          description: Conflict, if the given attribute already exists

  /example/{attribute}:
    get:
      tags:
        - "Example"
      security:
        - BearerToken: []
      summary: Get the example with the given attribute
      parameters:
        - name: attribute
          in: path
          required: true
          description: requested attribute
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: OK, if the example with given attribute was found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Example'
        "404":
          description: NOT FOUND, if the consent was not found
