openapi: 3.1.0
info:
  title: Comunidesk API — Gestión transversal — Banco de reservas
  version: 1.0.0
  description: Personal de reserva compartido entre edificios (comunidesk_transversal).
servers:
  - url: "https://gateway.comunidesk.com"
    description: Gateway producción
tags:
  - name: gestion-transversal-personal
    description: Gestión transversal — Banco de reservas — Personal de reserva compartido entre edificios (comunidesk_transversal).
paths:
  /v1/rest/GestionTransversalPersonal:
    get:
      tags:
        - gestion-transversal-personal
      operationId: listPersonalReserva
      summary: Listar Gestión transversal — Banco de reservas
      description: Personal de reserva compartido entre edificios (comunidesk_transversal).
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: edificioId
          in: query
          required: false
          schema:
            type: string
          description: Contexto de edificio (requerido en la mayoría de módulos).
        - name: $filter
          in: query
          required: false
          schema:
            type: string
          description: "Filtro OData, p.ej. edificioId eq 'abc'"
        - name: $top
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
        - name: $skip
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PersonalReserva"
                  count:
                    type: integer
        401:
          description: Token inválido
        403:
          description: Sin permiso
    post:
      tags:
        - gestion-transversal-personal
      operationId: createPersonalReserva
      summary: Crear Gestión transversal — Banco de reservas
      security:
        - OAuth2App: []
          ComunideskUser: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PersonalReserva"
      responses:
        200:
          description: Creado
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PersonalReserva"
        403:
          description: Sin permiso
        422:
          description: Contrato inválido
  /v1/rest/GestionTransversalPersonal/{id}:
    get:
      tags:
        - gestion-transversal-personal
      operationId: getPersonalReserva
      summary: Obtener Gestión transversal — Banco de reservas
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: edificioId
          in: query
          required: false
          schema:
            type: string
          description: Contexto de edificio (requerido en la mayoría de módulos).
        - name: $filter
          in: query
          required: false
          schema:
            type: string
          description: "Filtro OData, p.ej. edificioId eq 'abc'"
        - name: $top
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
        - name: $skip
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: "#/components/schemas/PersonalReserva"
        404:
          description: No encontrado
    patch:
      tags:
        - gestion-transversal-personal
      operationId: updatePersonalReserva
      summary: Actualizar Gestión transversal — Banco de reservas
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PersonalReserva"
      responses:
        200:
          description: Actualizado
        403:
          description: Sin permiso
        422:
          description: Contrato inválido
    delete:
      tags:
        - gestion-transversal-personal
      operationId: deletePersonalReserva
      summary: Eliminar Gestión transversal — Banco de reservas
      security:
        - OAuth2App: []
          ComunideskUser: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: edificioId
          in: query
          required: false
          schema:
            type: string
      responses:
        200:
          description: Eliminado
        403:
          description: Sin permiso
        404:
          description: No encontrado
components:
  securitySchemes:
    OAuth2App:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Access token OAuth2 de tu aplicación.
    ComunideskUser:
      type: apiKey
      in: header
      name: x-comunidesk-user-authorization
      description: "Bearer <JWT de la cuenta Comunidesk del usuario>."
  schemas:
    PersonalReserva:
      type: object
      description: Personal de reserva compartido entre edificios (comunidesk_transversal).
      properties:
        _id:
          type: string
        _rev:
          type: string
        type:
          type: string
          const: personal_reserva
        nombre:
          type: string
        apellido:
          type: string
        rut:
          type: string
        tipo:
          type: string
        telefono:
          type: string
        email:
          type: string
        disponible:
          type: boolean
        estado:
          type: string
          enum:
            - activo
            - inactivo
            - suspendido
        createdAt:
          type: string
          readOnly: true
        updatedAt:
          type: string
          readOnly: true
        tipo_doc:
          type: string
          readOnly: true
        creadoPor:
          type: string
          readOnly: true
        rbacUsers:
          type: string
          readOnly: true
      required:
        - nombre
        - apellido
        - rut
        - tipo
    OAuthScopes:
      type: string
      enum:
        - "comunidesk:read"
        - "comunidesk:write"
        - "files:pdf"
        - "files:excel"
        - "ai:models"
        - "ai:chat"
        - "ai:extract"
        - "ai:web"
        - "flex-pro:manage"
        - "flex-pro:runtime"
        - "flex-pro:marketplace"
      description: Scopes OAuth soportados por el gateway.
security:
  - OAuth2App: []
    ComunideskUser: []