---
openapi: 3.0.3
info:
  title: CodeFirst Backend API
  contact:
    name: CodeFirst Support
    email: codefirst@example.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.1
tags:
- name: Kubernetes
  description: Kubernetes resources.
- name: Gitlab
  description: Gitlab resources.
- name: Keycloak
  description: Keycloak resources.
- name: Monitoring
  description: Admin API for backend monitoring.
- name: Issues
  description: API to manage Codefisrt instance issues opened by its users.
- name: Users
- name: Features
- name: Organisation
- name: Quota Requests
paths:
  /admin/k8s/rbac/tokens/available/count:
    get:
      tags:
      - Kubernetes
      summary: Admin only
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: Count all available RBAC token left in the database.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CountDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme:
        - cf-admin
  /admin/k8s/rbac/tokens/history/secret/{secret}:
    get:
      tags:
      - Kubernetes
      summary: Admin only
      parameters:
      - name: secret
        in: path
        required: true
        schema:
          type: string
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: Retrieve assignations history for a dedicated token secret.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/RbacTokenHistoryDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme:
        - cf-admin
  /admin/k8s/rbac/tokens/history/used-by/{usedBy}:
    get:
      tags:
      - Kubernetes
      summary: Admin only
      parameters:
      - name: usedBy
        in: path
        required: true
        schema:
          type: string
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: Retrieve history of token assignations for the requested namespace.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/RbacTokenHistoryDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme:
        - cf-admin
  /admin/k8s/rbac/tokens/history/username/{username}:
    get:
      tags:
      - Kubernetes
      summary: Admin only
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: Retrieve history of token assignations made by the requested
            username.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/RbacTokenHistoryDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme:
        - cf-admin
  /admin/k8s/rbac/tokens/import:
    post:
      tags:
      - Kubernetes
      summary: Admin only
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/ImportRbacTokenDTO'
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: "Status of the import once it is done, gives the number of\
            \ token imported."
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImportStatus'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme:
        - cf-admin
  /admin/k8s/rbac/tokens/used:
    get:
      tags:
      - Kubernetes
      summary: Admin only
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: List all used RBAC token.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/RbacTokenDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme:
        - cf-admin
  /features:
    get:
      tags:
      - Features
      responses:
        "200":
          description: List all available features.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FeatureDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /features/{id}/username/{username}/assign:
    post:
      tags:
      - Features
      summary: Admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: username
        in: path
        required: true
        schema:
          type: string
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /features/{id}/username/{username}/revoke:
    post:
      tags:
      - Features
      summary: Admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: username
        in: path
        required: true
        schema:
          type: string
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /gitlab/groups:
    get:
      tags:
      - Gitlab
      responses:
        "200":
          description: List all existing gitlab groups on which the current user has
            visibility.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CacheGitlabGroupDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
    post:
      tags:
      - Gitlab
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InputGroupDTO'
      responses:
        "200":
          description: Create a new group onto the gitlab instance for SAE projects
            and teacher courses.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GroupDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/groups/user/{id}:
    get:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: List all groups where the user is a member.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/GroupDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/groups/{gitlabId}:
    delete:
      tags:
      - Gitlab
      parameters:
      - name: gitlabId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "204":
          description: No Content
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/groups/{id}:
    get:
      tags:
      - Gitlab
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: Get details of an existing gitlab group on which the current
            user has visibility.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CacheGitlabGroupDetailsDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/groups/{id}/members/add:
    post:
      tags:
      - Gitlab
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GitlabGroupMembersDTO'
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/groups/{id}/members/groups/{groupId}:
    delete:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: groupId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "204":
          description: No Content
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/groups/{id}/members/users/{userId}:
    delete:
      tags:
      - Gitlab
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      - name: userId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "204":
          description: No Content
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects:
    post:
      tags:
      - Gitlab
      summary: Students API
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InputProjectDTO'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects/groups/{groupId}:
    get:
      tags:
      - Gitlab
      summary: Get all projects for a Gitlab Group (must be at least Maintainer on
        projects)
      parameters:
      - name: groupId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProjectDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects/{id}:
    delete:
      tags:
      - Gitlab
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "204":
          description: No Content
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects/{id}/members:
    get:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectMembersDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects/{id}/members/add:
    post:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GitlabGroupMembersDTO'
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects/{id}/members/groups/{groupId}:
    delete:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: groupId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "204":
          description: No Content
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects/{id}/members/students/clear:
    post:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/projects/{id}/members/users/{userId}:
    delete:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int64
          type: integer
      - name: userId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "204":
          description: No Content
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/users/me/color-mode/{id}:
    post:
      tags:
      - Gitlab
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          format: int32
          type: integer
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserUpdateStatusDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /gitlab/users/me/customization:
    get:
      tags:
      - Gitlab
      summary: Teacher and admin only
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GitlabUserCustomization'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /health:
    get:
      tags:
      - Health Controller
      summary: Public API
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: string
  /issues:
    get:
      tags:
      - Issues
      summary: Admin only or feature ISSUES
      parameters:
      - name: closed
        in: query
        schema:
          type: boolean
      responses:
        "200":
          description: List all issues open for the codefirst instance.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
    post:
      tags:
      - Issues
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateIssueDTO'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /issues/me:
    get:
      tags:
      - Issues
      parameters:
      - name: closed
        in: query
        schema:
          type: boolean
      responses:
        "200":
          description: List all issues open for the codefirst instance.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /issues/quota:
    get:
      tags:
      - Issues
      summary: Admin only or feature QUOTA_REQUESTS
      parameters:
      - name: closed
        in: query
        schema:
          type: boolean
      responses:
        "200":
          description: List all quota requests open for the codefirst instance.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /issues/{id}:
    get:
      tags:
      - Issues
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
    patch:
      tags:
      - Issues
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateIssueDTO'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /issues/{id}/assignee/{username}:
    post:
      tags:
      - Issues
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: username
        in: path
        required: true
        schema:
          type: string
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /issues/{id}/comments:
    post:
      tags:
      - Issues
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CommentDTO'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /issues/{id}/comments/{commentId}:
    delete:
      tags:
      - Issues
      summary: Admin only
      parameters:
      - name: commentId
        in: path
        required: true
        schema:
          type: string
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IssueDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /issues/{id}/transition/{state}:
    post:
      tags:
      - Issues
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: state
        in: path
        required: true
        schema:
          type: string
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /k8s/deployments/pods/name/{podName}:
    delete:
      tags:
      - Kubernetes
      parameters:
      - name: podName
        in: path
        required: true
        schema:
          type: string
      - name: namespace
        in: query
        schema:
          type: string
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
  /k8s/events/logs:
    get:
      tags:
      - Kubernetes
      parameters:
      - name: namespace
        in: query
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Return the logs of the namespace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KubernetesLogsDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /k8s/namespaces:
    get:
      tags:
      - Kubernetes
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: List all namespaces according to user visibility.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/NamespaceDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
    post:
      tags:
      - Kubernetes
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NamespaceDTO'
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "201":
          description: Namespace resource created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NamespaceDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
  /k8s/namespaces/name/{name}:
    get:
      tags:
      - Kubernetes
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: Give namespace details with quota and all the pods.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NamespaceDetailDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
    delete:
      tags:
      - Kubernetes
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "204":
          description: No Content
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
  /k8s/pods/{name}/logs:
    get:
      tags:
      - Kubernetes
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      - name: lines
        in: query
        schema:
          format: int32
          default: 150
          type: integer
      - name: namespace
        in: query
        schema:
          type: string
      responses:
        "200":
          description: Return the logs of the pod with the given name and namespace
            (Maximum last 1000 lines).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KubernetesLogsDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /k8s/pods/{name}/logs/full:
    get:
      tags:
      - Kubernetes
      parameters:
      - name: name
        in: path
        required: true
        schema:
          type: string
      - name: namespace
        in: query
        schema:
          type: string
      responses:
        "200":
          description: Return all the logs of the pod with the given name and namespace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KubernetesLogsDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /k8s/rbac/tokens/assign:
    post:
      tags:
      - Kubernetes
      parameters:
      - name: namespace
        in: query
        required: true
        schema:
          type: string
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "200":
          description: Assign a random available token to the requested namespace
            if none already assigned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RbacTokenDTO'
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
  /k8s/stats/objects/count:
    get:
      tags:
      - Kubernetes
      summary: Admin only or feature STATISTICS
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
  /k8s/stats/quota/sum:
    get:
      tags:
      - Kubernetes
      summary: Admin only or feature STATISTICS
      responses:
        "403":
          description: User does not have enough visibility to access the requested
            resource.
        "401":
          description: Not Authorized
      security:
      - SecurityScheme: []
  /keycloak/groups:
    get:
      tags:
      - Keycloak
      summary: Admin only
      responses:
        "200":
          description: List of groups in the master realm.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/KeycloakGroupDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /keycloak/groups/name/{groupName}/members:
    get:
      tags:
      - Keycloak
      summary: Admin only
      parameters:
      - name: groupName
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: List of members for the requested group inside the master realm.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KeycloakUserDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /keycloak/token:
    post:
      tags:
      - Keycloak
      summary: Public API
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CredentialsDTO'
      responses:
        "200":
          description: Bridge to log in into keycloak without using its UI.
          content:
            application/json:
              example:
                access_token: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJLM3A1Z2pxQUJsUUNUS3FISkZrM1RaUHBIbGttUWZhVWl3blFEN1N6ZEZZIn0.XXXX.XXXXX
                expires_in: 36000
                refresh_expires_in: 1800
                refresh_token: eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIwNTJiZDlkYS1jOGQ4LTQ0ODMtODAwZS1jM2YxMDM5MDQ4MTgifQ.XXXX.XXXX
                token_type: Bearer
                not-before-policy: 0
                session_state: 8b5e089c-e3c5-4a65-adbd-bec46d85704b
                scope: email profile
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /migration/helper/username:
    get:
      tags:
      - Migration Helper Controller
      parameters:
      - name: email
        in: query
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: string
  /monitoring/kubernetes/tokens/count:
    get:
      tags:
      - Monitoring
      summary: Admin only or feature STATISTICS
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KubernetesCountTokenDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /monitoring/requests/countByStatusCode:
    get:
      tags:
      - Monitoring
      summary: Admin only or feature STATISTICS
      parameters:
      - name: since
        in: query
        schema:
          $ref: '#/components/schemas/Date'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CountByResponseStatusCodeDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /monitoring/requests/countPerRequest:
    get:
      tags:
      - Monitoring
      summary: Admin only or feature STATISTICS
      parameters:
      - name: since
        in: query
        schema:
          $ref: '#/components/schemas/Date'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CountByRequestDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /monitoring/requests/errors:
    get:
      tags:
      - Monitoring
      summary: Admin only or feature STATISTICS
      parameters:
      - name: since
        in: query
        schema:
          $ref: '#/components/schemas/Date'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ErrorMonitoringDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /organisations:
    get:
      tags:
      - Organisation
      summary: Admin only
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/OrganisationDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
    post:
      tags:
      - Organisation
      summary: Admin only
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateOrganisationDTO'
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganisationDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /organisations/me:
    get:
      tags:
      - Organisation
      summary: Get the organisations of the current user
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrganisationDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /organisations/{id}/failed-users:
    get:
      tags:
      - Organisation
      summary: Admin only - Get users with failed sync status
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /organisations/{id}/members/autocomplete:
    get:
      tags:
      - Organisation
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AutocompleteMemberDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /organisations/{id}/retry-failed:
    post:
      tags:
      - Organisation
      summary: Admin only - Retry failed users synchronization
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /organisations/{id}/sync:
    post:
      tags:
      - Organisation
      summary: Admin only - Asynchronous synchronization
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      - name: scope
        in: query
        schema:
          default: ALL
          enum:
          - TEACHERS
          - STUDENTS
          - ALL
      responses:
        "200":
          description: OK
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /quota-requests:
    post:
      tags:
      - Quota Requests
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateQuotaRequestDTO'
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /quota-requests/{id}/approve:
    post:
      tags:
      - Quota Requests
      summary: Admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuotaReasonDTO'
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /quota-requests/{id}/reject:
    post:
      tags:
      - Quota Requests
      summary: Admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuotaReasonDTO'
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /users:
    get:
      tags:
      - Users
      summary: "Admin only: List all local users"
      responses:
        "200":
          description: List of local users.
          content: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
    post:
      tags:
      - Users
      summary: "Admin only: Create a new local user"
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserDTO'
      responses:
        "201":
          description: Local user created successfully.
          content: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /users/groups:
    get:
      tags:
      - User Group Controller
      parameters:
      - name: full
        in: query
        schema:
          default: "false"
          type: boolean
      responses:
        "200":
          description: List all existing Gitlab Groups the current user has access
            to and their associated namespaces if any.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/UserGroupDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /users/me:
    get:
      tags:
      - Users
      responses:
        "200":
          description: List all features activated for the logged in user.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FeatureDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /users/me/features:
    get:
      tags:
      - Users
      responses:
        "200":
          description: List all features activated for the logged in user.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FeatureDTO'
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /users/me/features/{id}:
    delete:
      tags:
      - Users
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "204":
          description: No Content
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /users/me/features/{id}/assign:
    post:
      tags:
      - Users
      summary: Teacher and admin only
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "201":
          description: Created
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme: []
  /users/organization/{organizationId}:
    get:
      tags:
      - Users
      summary: "Admin only: Get all local users by organization ID"
      parameters:
      - name: organizationId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: List of local users for the organization.
          content: {}
        "404":
          description: No local users found for the organization.
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /users/username/{username}:
    get:
      tags:
      - Users
      summary: "Admin only: Get a local user by username"
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Local user found.
          content: {}
        "404":
          description: Local user not found.
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
  /users/{id}:
    get:
      tags:
      - Users
      summary: "Admin only: Get a local user by ID"
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Local user found.
          content: {}
        "404":
          description: Local user not found.
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
    delete:
      tags:
      - Users
      summary: "Admin only: Delete a local user by email"
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "204":
          description: "Local user deleted successfully from Keycloak, GitLab, and\
            \ DB."
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      security:
      - SecurityScheme:
        - cf-admin
components:
  schemas:
    AccessLevel:
      enum:
      - -1
      - 0
      - 5
      - 10
      - 20
      - 30
      - 40
      - 40
      - 50
      - 60
      type: string
    AnnotationDTO:
      type: object
      properties:
        key:
          type: string
        value:
          type: string
    AutocompleteMemberDTO:
      type: object
      properties:
        fullName:
          type: string
        username:
          type: string
    CacheGitlabGroupDTO:
      type: object
      properties:
        name:
          type: string
        gitlabGroupId:
          format: int64
          type: integer
        groupFullPath:
          type: string
        accessLevel:
          $ref: '#/components/schemas/AccessLevel'
    CacheGitlabGroupDetailsDTO:
      type: object
      properties:
        name:
          type: string
        fullPath:
          type: string
        gitlabId:
          format: int64
          type: integer
        createdAt:
          $ref: '#/components/schemas/Date'
        organizationId:
          $ref: '#/components/schemas/ObjectId'
        studentsCanCreateRepository:
          type: boolean
        directMembers:
          type: array
          items:
            $ref: '#/components/schemas/EmbedGitlabUserDTO'
        studentListGroups:
          type: array
          items:
            $ref: '#/components/schemas/EmbedStudentListGroupDTO'
    CommentDTO:
      type: object
      properties:
        content:
          type: string
    CountByRequestDTO:
      type: object
      properties:
        count:
          format: int64
          type: integer
        uri:
          type: string
        method:
          type: string
    CountByResponseStatusCodeDTO:
      type: object
      properties:
        count:
          format: int64
          type: integer
        statusCode:
          type: string
    CountDTO:
      type: object
      properties:
        count:
          format: int64
          type: integer
    CreateIssueDTO:
      type: object
      properties:
        title:
          type: string
        description:
          type: string
        type:
          type: string
        labels:
          type: array
          items:
            type: string
    CreateOrganisationDTO:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        syncSource:
          type: string
        createdAt:
          $ref: '#/components/schemas/Date'
        lastSyncAt:
          $ref: '#/components/schemas/Date'
        studentEmailPattern:
          type: string
        teacherEmailPattern:
          type: string
        temporaryTeacherEmailPattern:
          type: string
        odinDepartmentParameter:
          type: string
        ciGenActive:
          type: boolean
    CreateQuotaRequestDTO:
      type: object
      properties:
        namespace:
          type: string
        cpu:
          type: string
        ram:
          type: string
        justification:
          type: string
    CreateUserDTO:
      type: object
      properties:
        email:
          type: string
        username:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        organizationId:
          type: string
        keycloakGroupName:
          type: string
    CredentialsDTO:
      type: object
      properties:
        username:
          type: string
        password:
          type: string
        clientId:
          type: string
        clientSecret:
          type: string
    Date:
      format: date
      type: string
      example: 2022-03-10
    EmbedGitlabUserDTO:
      type: object
      properties:
        name:
          type: string
        gitlabId:
          format: int64
          type: integer
        accessLevel:
          $ref: '#/components/schemas/AccessLevel'
        fullName:
          type: string
    EmbedOrganisationStudentGroupDTO:
      type: object
      properties:
        gitlabId:
          format: int64
          type: integer
        name:
          type: string
    EmbedStudentListGroupDTO:
      type: object
      properties:
        name:
          type: string
        gitlabId:
          format: int64
          type: integer
        accessLevel:
          $ref: '#/components/schemas/AccessLevel'
    ErrorMonitoringDTO:
      type: object
      properties:
        id:
          type: string
        exception:
          type: string
        cause:
          type: string
        at:
          $ref: '#/components/schemas/Date'
        stacktrace:
          type: string
        javaClass:
          type: string
    FeatureDTO:
      type: object
      properties:
        name:
          type: string
        id:
          type: string
        featureId:
          $ref: '#/components/schemas/ObjectId'
        mode:
          type: string
        defaultVisibilityRole:
          type: string
    GitlabGroupMembersDTO:
      type: object
      properties:
        usernames:
          type: array
          items:
            type: string
        groupsIds:
          type: array
          items:
            format: int64
            type: integer
        accessLevel:
          $ref: '#/components/schemas/AccessLevel'
        orgId:
          type: string
    GitlabUserCustomization:
      type: object
      properties:
        themeId:
          format: int32
          type: integer
        colorSchemeId:
          format: int64
          type: integer
        colorModeId:
          format: int32
          type: integer
    GroupDTO:
      type: object
      properties:
        id:
          format: int64
          type: integer
        name:
          type: string
        shortName:
          type: string
        path:
          type: string
        parentId:
          format: int64
          type: integer
    ImportRbacTokenDTO:
      type: object
      properties:
        user:
          type: string
        secret:
          type: string
    ImportStatus:
      type: object
      properties:
        count:
          format: int64
          type: integer
        status:
          $ref: '#/components/schemas/Status'
    InputGroupDTO:
      type: object
      properties:
        orgId:
          type: string
        name:
          type: string
        parentGroupId:
          format: int64
          type: integer
        studentsCanCreateRepository:
          type: boolean
    InputProjectDTO:
      type: object
      properties:
        name:
          type: string
        parentGroupId:
          format: int64
          type: integer
    IssueCommentDTO:
      type: object
      properties:
        id:
          type: string
        author:
          type: string
        createdAt:
          $ref: '#/components/schemas/Date'
        updatedAt:
          $ref: '#/components/schemas/Date'
        content:
          type: string
    IssueDTO:
      type: object
      properties:
        title:
          type: string
        description:
          type: string
        type:
          type: string
        labels:
          type: array
          items:
            type: string
        id:
          type: string
        severity:
          type: string
        author:
          type: string
        assignee:
          type: string
        createdAt:
          $ref: '#/components/schemas/Date'
        updatedAt:
          $ref: '#/components/schemas/Date'
        closedAt:
          $ref: '#/components/schemas/Date'
        closedBy:
          type: string
        comments:
          type: array
          items:
            $ref: '#/components/schemas/IssueCommentDTO'
        namespace:
          type: string
        cpu:
          type: string
        status:
          type: string
        ram:
          type: string
        reason:
          type: string
    KeycloakGroupDTO:
      type: object
      properties:
        name:
          type: string
        path:
          type: string
    KeycloakUserDTO:
      type: object
      properties:
        username:
          type: string
        email:
          type: string
    KubernetesCountTokenDTO:
      type: object
      properties:
        total:
          format: int64
          type: integer
        available:
          format: int64
          type: integer
    KubernetesLogsDTO:
      type: object
      properties:
        logs:
          type: string
    MetadataDTO:
      type: object
      properties:
        owner:
          type: string
        createdAt:
          type: string
        name:
          type: string
    NamespaceDTO:
      type: object
      properties:
        metadata:
          $ref: '#/components/schemas/MetadataDTO'
        quota:
          $ref: '#/components/schemas/QuotaDTO'
    NamespaceDetailDTO:
      type: object
      properties:
        metadata:
          $ref: '#/components/schemas/MetadataDTO'
        quota:
          $ref: '#/components/schemas/QuotaDTO'
        pods:
          type: array
          items:
            $ref: '#/components/schemas/PodDTO'
        totalRamUsed:
          type: string
        totalCpuUsed:
          type: string
    ObjectId:
      type: object
      properties:
        timestamp:
          format: int32
          type: integer
        counter:
          format: int32
          type: integer
        randomValue1:
          format: int32
          type: integer
        randomValue2:
          type: integer
        date:
          $ref: '#/components/schemas/Date'
    OrganisationDTO:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        syncSource:
          type: string
        createdAt:
          $ref: '#/components/schemas/Date'
        lastSyncAt:
          $ref: '#/components/schemas/Date'
        studentEmailPattern:
          type: string
        teacherEmailPattern:
          type: string
        temporaryTeacherEmailPattern:
          type: string
        gitlabTopLevelGroupId:
          format: int64
          type: integer
        gitlabStudentProjectsGroupId:
          format: int64
          type: integer
        studentGroups:
          type: array
          items:
            $ref: '#/components/schemas/EmbedOrganisationStudentGroupDTO'
    PodDTO:
      type: object
      properties:
        name:
          type: string
        appLabel:
          type: string
        namespace:
          type: string
        image:
          type: string
        quota:
          $ref: '#/components/schemas/QuotaDTO'
        status:
          $ref: '#/components/schemas/PodStatusDTO'
        annotations:
          type: array
          items:
            $ref: '#/components/schemas/AnnotationDTO'
    PodStatusDTO:
      type: object
      properties:
        message:
          type: string
        phase:
          type: string
        reason:
          type: string
        startTime:
          type: string
    ProjectDTO:
      type: object
      properties:
        id:
          format: int64
          type: integer
        name:
          type: string
        path:
          type: string
    ProjectMembersDTO:
      type: object
      properties:
        directMembers:
          type: array
          items:
            $ref: '#/components/schemas/EmbedGitlabUserDTO'
        studentListGroups:
          type: array
          items:
            $ref: '#/components/schemas/EmbedStudentListGroupDTO'
    QuotaDTO:
      type: object
      properties:
        cpuLimit:
          type: number
        ramLimit:
          type: number
    QuotaReasonDTO:
      type: object
      properties:
        reason:
          type: string
    RbacTokenDTO:
      type: object
      properties:
        id:
          type: string
        user:
          type: string
        secret:
          type: string
        inUseSince:
          $ref: '#/components/schemas/Date'
        inUseBy:
          type: string
        available:
          type: boolean
    RbacTokenHistoryDTO:
      type: object
      properties:
        id:
          type: string
        who:
          type: string
        rbacToken:
          $ref: '#/components/schemas/RbacTokenDTO'
        action:
          type: string
    ResponseStatus:
      enum:
      - FAILED
      - SUCCESS
      type: string
    Status:
      enum:
      - OK
      - KO
      type: string
    UpdateIssueDTO:
      type: object
      properties:
        title:
          type: string
        description:
          type: string
        type:
          type: string
        labels:
          type: array
          items:
            type: string
        id:
          type: string
        severity:
          type: string
    UserDTO:
      type: object
      properties:
        id:
          type: string
        createdAt:
          type: string
        username:
          type: string
        gitlabId:
          format: int64
          type: integer
        organizationId:
          type: string
        groups:
          uniqueItems: true
          type: array
          items:
            format: int64
            type: integer
    UserGroupDTO:
      type: object
      properties:
        name:
          type: string
        namespace:
          $ref: '#/components/schemas/UserGroupNamespaceDTO'
    UserGroupNamespaceDTO:
      type: object
      properties:
        name:
          type: string
        createdAt:
          type: string
        deletionTimestamp:
          type: string
        podsCount:
          format: int64
          type: integer
    UserUpdateStatusDTO:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/ResponseStatus'
  securitySchemes:
    SecurityScheme:
      type: openIdConnect
      description: Authentication
      openIdConnectUrl: https://codefirst.iut.uca.fr/keycloak/realms/master/.well-known/openid-configuration
