openapi: 3.0.3
info:
  title: 'Moodle Licence Manager API Documentation'
  description: ''
  version: 1.0.0
servers:
  -
    url: 'https://mlm.pimenko.com'
tags:
  -
    name: Licences
    description: ''
  -
    name: LicencesTypes
    description: ''
  -
    name: Products
    description: ''
components:
  securitySchemes:
    default:
      type: http
      scheme: bearer
      description: 'You can retrieve your token by visiting your dashboard and clicking <b>Generate API token</b>.'
security:
  -
    default: []
paths:
  /api/licences:
    get:
      summary: 'List all licences.'
      operationId: listAllLicences
      description: 'Retourne la liste de toutes les licences.'
      parameters: []
      responses:
        200:
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      example: 1
                    product_id:
                      type: integer
                      example: 2
                    key:
                      type: string
                      example: ABC123
                    status:
                      type: string
                      example: active
                    expires_at:
                      type: string
                      example: '2026-12-31T00:00:00.000000Z'
                    licence_type_id:
                      type: integer
                      example: 1
                example:
                  -
                    id: 1
                    product_id: 2
                    key: ABC123
                    status: active
                    expires_at: '2026-12-31T00:00:00.000000Z'
                    licence_type_id: 1
      tags:
        - Licences
  /api/licence/create:
    post:
      summary: 'Create a licence and its first site.'
      operationId: createALicenceAndItsFirstSite
      description: 'Crée une licence et associe un premier site.'
      parameters: []
      responses:
        201:
          description: ''
          content:
            application/json:
              schema:
                type: object
                example:
                  licence:
                    id: 4
                    product_id: 2
                    key: 550E8400-E29B-41D4-A716-446655440000-2Q7x9VxvR3m9y5m1n8W4k1qQ9aXhY2Z0mJfP8cT1eUo
                    status: active
                    expires_at: '2027-06-02T00:00:00.000000Z'
                    licence_type_id: 1
                  site:
                    id: 10
                    url: 'https://example.com'
                properties:
                  licence:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 4
                      product_id:
                        type: integer
                        example: 2
                      key:
                        type: string
                        example: 550E8400-E29B-41D4-A716-446655440000-2Q7x9VxvR3m9y5m1n8W4k1qQ9aXhY2Z0mJfP8cT1eUo
                      status:
                        type: string
                        example: active
                      expires_at:
                        type: string
                        example: '2027-06-02T00:00:00.000000Z'
                      licence_type_id:
                        type: integer
                        example: 1
                  site:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 10
                      url:
                        type: string
                        example: 'https://example.com'
        422:
          description: ''
          content:
            application/json:
              schema:
                type: object
                example:
                  message: 'The given data was invalid.'
                properties:
                  message:
                    type: string
                    example: 'The given data was invalid.'
        500:
          description: ''
          content:
            application/json:
              schema:
                type: object
                example:
                  error: 'Internal error message'
                properties:
                  error:
                    type: string
                    example: 'Internal error message'
      tags:
        - Licences
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                licence_type:
                  type: integer
                  description: 'ID du type de licence.'
                  example: 1
                product_id:
                  type: integer
                  description: 'ID du produit.'
                  example: 2
                url:
                  type: string
                  description: 'URL du site à associer.'
                  example: 'https://example.com'
              required:
                - licence_type
                - product_id
                - url
  '/api/licences/{licence_key}/sites':
    post:
      summary: 'Add a new site to an existing licence identified by key.'
      operationId: addANewSiteToAnExistingLicenceIdentifiedByKey
      description: 'Ajoute un site à une licence existante identifiée par sa clé.'
      parameters: []
      responses:
        201:
          description: ''
          content:
            application/json:
              schema:
                type: object
                example:
                  site:
                    id: 11
                    licence_id: 4
                    url: 'https://example.com'
                properties:
                  site:
                    type: object
                    properties:
                      id:
                        type: integer
                        example: 11
                      licence_id:
                        type: integer
                        example: 4
                      url:
                        type: string
                        example: 'https://example.com'
        422:
          description: ''
          content:
            application/json:
              schema:
                type: object
                example:
                  message: 'Nombre maximal de sites atteint pour cette licence.'
                properties:
                  message:
                    type: string
                    example: 'Nombre maximal de sites atteint pour cette licence.'
        500:
          description: ''
          content:
            application/json:
              schema:
                type: object
                example:
                  error: 'Internal error message'
                properties:
                  error:
                    type: string
                    example: 'Internal error message'
      tags:
        - Licences
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  description: 'URL du site à associer à la licence.'
                  example: 'https://example.com'
              required:
                - url
    parameters:
      -
        in: path
        name: licence_key
        description: 'Clé unique de la licence au format UUID-HASH.'
        example: 550E8400-E29B-41D4-A716-446655440000-2Q7x9VxvR3m9y5m1n8W4k1qQ9aXhY2Z0mJfP8cT1eUo
        required: true
        schema:
          type: string
  /api/licencestypes:
    get:
      summary: 'List all licence types'
      operationId: listAllLicenceTypes
      description: 'Retourne la liste de tous les types de licences.'
      parameters: []
      responses:
        200:
          description: ''
          content:
            text/plain:
              schema:
                type: string
                example: "[\n  {\n    \"id\": 1,\n    \"name\": \"Standard\",\n    \"max_sites\": 5,\n\n  }\n]"
      tags:
        - LicencesTypes
  /api/products:
    get:
      summary: 'List all products'
      operationId: listAllProducts
      description: 'Retourne la liste de tous les produits.'
      parameters: []
      responses:
        200:
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      example: 1
                    name:
                      type: string
                      example: 'Plugin Moodle 1'
                    slug:
                      type: string
                      example: plugin-moodle-1
                    description:
                      type: string
                      example: 'Description du plugin Moodle 1'
                    created_at:
                      type: string
                      example: '2024-01-01T00:00:00.000000Z'
                    updated_at:
                      type: string
                      example: '2024-01-01T00:00:00.000000Z'
                example:
                  -
                    id: 1
                    name: 'Plugin Moodle 1'
                    slug: plugin-moodle-1
                    description: 'Description du plugin Moodle 1'
                    created_at: '2024-01-01T00:00:00.000000Z'
                    updated_at: '2024-01-01T00:00:00.000000Z'
      tags:
        - Products
