openapi: 3.0.3

info:
  title: SeMeet
  description: Secure Jitsi Meet
  version: 1.0.0
  license:
    name: Artistic License 2.0
    url: https://www.perlfoundation.org/artistic-license-20.html
  contact:
    name: Andrej Ramašeuski
    email: andrej@x2.cz
    url: https://pardubicky.pirati.cz/lide/andrej-ramaseuski/

servers:
    - url: https://meet.pirati.cz/api
      description: Production server
    - url: http://127.0.0.1:3000/api
      description: Test server

components:
  securitySchemes:
    Bearer:
      type: apiKey
      in: header
      name: Authorization
  schemas:
    Meet:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        uuid:
          type: string
          description: UUID
        name:
          type: string
          description: Nazev
        description:
          type: string
          nullable: true
        groups:
          type: array
          items:
             $ref: '#/components/schemas/GroupInList'
        moderators:
          type: array
          items:
             $ref: '#/components/schemas/UserInList'
        participants:
          type: array
          items:
             $ref: '#/components/schemas/UserInList'
    GroupInList:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        name:
          type: string
          readOnly: true
    UserInList:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        uuid:
          type: string
          readOnly: true
        name:
          type: string
          readOnly: true
        username:
          type: string
          readOnly: true
          nullable: true
        region:
          type: string
          nullable: true
          readOnly: true

paths:
  /meets:
    post:
      x-mojo-to: meets#create
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Pridat mistnost"
      operationId: createMeet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: "Republikový vybor"
              required:
                - name
      responses:
        201:
          description: Meet created
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Meet id
    get:
      x-mojo-to: meets#list
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Seznam přistupných mistnosti"
      operationId: getMeets
#      parameters:
#      - $ref: '#/components/parameters/offset'
#      - $ref: '#/components/parameters/limit'
#      - name: sort
#        description: "Razeni"
#        in: query
#        style: form
#        schema:
#          type: array
#          uniqueItems: true
#          items:
#            type: string
#            enum: [ start, -start]
#          default: [ start ]
      responses:
        200:
          description: Meets
          content:
            application/json:
              schema:
                type: object
                properties:
                  count:
                    type: integer
                    description: Celkovy pocet
                  records:
                    type: array
                    items:
                      $ref: '#/components/schemas/Meet'
  /meets/{id}:
    get:
      x-mojo-to: meets#get
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Mistnost"
      operationId: getMeet
      parameters:
      - name: id
        in: path
        required: true
        example: 100345
        description: "Identifikator mistnosti"
        schema:
          type: integer
      responses:
        200:
          description: Meet
          content:
            application/json:
              schema:
               $ref: '#/components/schemas/Meet'
    put:
      x-mojo-to: meets#update
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Aktualizovat mistnost"
      operationId: updateMeet
      parameters:
      - name: id
        in: path
        required: true
        example: 100345
        description: "Identifikator mistnosti"
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: "Republikový vybor"
                description:
                  type: string
                  example: "Místnost pro uzavřená jednáni RV"
              required:
                - name
      responses:
        204:
          description: Mistnost je aktualizovana

    delete:
      x-mojo-to: meets#delete
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Smazat mistnost"
      operationId: deleteMeet
      parameters:
      - name: id
        in: path
        required: true
        example: 100345
        description: "Identifikator mistnosti"
        schema:
          type: integer
      responses:
        204:
          description: Mistnost je smazana

  /groups:
    get:
      x-mojo-to: groups#list
      tags:
        - groups
      summary: "Hledani skupin"
      operationId: searchGroups
      parameters:
      - name: search
        in: query
        description: Search query
        schema:
          type: string
          example: 'Media'
      responses:
        200:
          description: Seznam skupin
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GroupInList'

  /users:
    get:
      x-mojo-to: users#list
      tags:
        - users
      summary: "Hledani osob"
      operationId: searchUsers
      parameters:
      - name: search
        in: query
        description: Search query
        schema:
          type: string
          example: 'Ivan'
      responses:
        200:
          description: Seznam osob
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/UserInList'

  /meets/{id}/groups:
    post:
      x-mojo-to: meets#add_groups
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Zpristupnit mistnost skupinam"
      operationId: addGroupsToMeet
      parameters:
      - name: id
        in: path
        required: true
        example: 100345
        description: "Identifikator mistnosti"
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                groups:
                  type: array
                  example: [1,2,3]
                  items:
                    type: integer
              required:
                - groups
      responses:
        201:
          description: Groups authorized

  /meets/{id}/groups/{group_id}:
    delete:
      x-mojo-to: meets#delete_group
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Zruset opravneni skupiny"
      operationId: deleteGroupFromMeet
      parameters:
      - name: id
        in: path
        required: true
        example: 100345
        description: "Identifikator mistnosti"
        schema:
          type: integer
      - name: group_id
        in: path
        required: true
        example: 100345
        description: "Identifikator skupiny"
        schema:
          type: integer
      responses:
        204:
          description: Groups unauthorized

  /meets/{id}/users:
    post:
      x-mojo-to: meets#add_users
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Pridat osoby/moderatory"
      operationId: addUsersToMeet
      parameters:
      - name: id
        in: path
        required: true
        example: 100345
        description: "Identifikator mistnosti"
        schema:
          type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                users:
                  type: array
                  items:
                    type: string
              required:
                - users
      responses:
        201:
          description: Users added

  /meets/{id}/users/{relation_id}:
    delete:
      x-mojo-to: meets#delete_user
      security:
        - Bearer: []
      tags:
        - meets
      summary: "Smazat osobu"
      operationId: deleteUserFromMeet
      parameters:
      - name: id
        in: path
        required: true
        example: 100345
        description: "Identifikator mistnosti"
        schema:
          type: integer
      - name: relation_id
        in: path
        required: true
        example: 100345
        description: "Identifikator relace"
        schema:
          type: integer
      responses:
        204:
          description: User deleted
