---
openapi: 3.1.2
info:
  title: pollen API
  version: 3.5.0
paths:
  /v2/status:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PollenStatus"
      summary: Get Status
      operationId: status
      tags:
        - Health
  /v2/polls:
    get:
      parameters:
        - name: search
          in: query
          schema:
            type: string
          required: false
        - name: usage
          in: query
          schema:
            $ref: '#/components/schemas/PollGetUsage'
          required: false
        - name: filter
          in: query
          schema:
            $ref: '#/components/schemas/PollGetFilter'
          required: false
        - name: pageNumber
          in: query
          schema:
            type: integer
            format: int32
        - name: pageSize
          in: query
          schema:
            type: integer
            format: int32
        - name: order
          in: query
          schema:
            type: string
        - name: desc
          in: query
          schema:
            type: boolean
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaginatedPolls"
      summary: List polls
      operationId: getPolls
      tags:
        - Poll
  /v2/user:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PollenUser"
        "401":
          description: Not authenticated
      summary: Get Connected User
      operationId: getConnectedUser
      tags:
        - User
  /v2/users/{userId}:
    get:
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PollenUser"
      summary: Get User
      operationId: getUser
      tags:
        - User
  /v2/logout:
    delete:
      responses:
        "204":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UndefinedResponse"
      operationId: logout
      tags:
        - Auth
  /v2/login:
    post:
      parameters:
        - name: Authorization
          in: header
          schema:
            type: string
          required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PollenUserId"
      operationId: login
      tags:
        - Auth
components:
  schemas:
    AppStatus:
      type: object
      properties:
        version:
          type: string
        commitId:
          type: string
        buildDate:
          type: string
    PersistenceStatus:
      type: object
      properties:
        nbPolls:
          type: integer
          format: int64
        errors:
          type: array
          items:
            type: string
    PollenStatus:
      type: object
      properties:
        app:
          $ref: "#/components/schemas/AppStatus"
        runtime:
          $ref: "#/components/schemas/RuntimeStatus"
        persistence:
          $ref: "#/components/schemas/PersistenceStatus"
    RuntimeStatus:
      type: object
      properties:
        jvmName:
          type: string
        javaVersion:
          type: string
        availableProcessors:
          type: integer
          format: int32
        loadAverage:
          type: number
          format: double
        memoryAllocated:
          type: string
        memoryUsed:
          type: string
        memoryFree:
          type: string
        memoryMax:
          type: string
        charset:
          type: string
        zoneId:
          type: string
        runningSince:
          type: string
          format: date-time
        uptime:
          type: string
    PollGetUsage:
      type: string
      enum:
        - ALL
        - INVITED
        - PARTICIPATED
        - CREATED
    PollGetFilter:
      type: string
      enum:
        - NONE
        - PAST
        - CURRENT
        - UPCOMING
    Pagination:
      type: object
      properties:
        count:
          type: integer
          format: int64
        currentPage:
          type: integer
          format: int32
        lastPage:
          type: integer
          format: int32
        pageSize:
          type: integer
          format: int32
        order:
          type: string
        desc:
          type: boolean
    PaginatedPolls:
      type: object
      required:
        - elements
        - pagination
      properties:
        elements:
          type: array
          items:
            $ref: "#/components/schemas/PollSummary"
        pagination:
          $ref: "#/components/schemas/Pagination"
    PollStatus:
      type: string
      enum:
        - CREATED
        - VOTING
        - ADDING_CHOICES
        - CLOSED
    PollSummary:
      type: object
      required:
        - id
        - title
        - status
        - creatorName
        - voteCount
      properties:
        id:
          type: string
        title:
          type: string
        permission:
          type: string
        status:
          $ref: "#/components/schemas/PollStatus"
        creatorAvatar:
          type: string
        creatorName:
          type: string
        voteCount:
          type: integer
          format: int64
        description:
          type: string
        beginDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        picture:
          type: string
        builtinPicture:
          type: string
    PollenUserId:
      type: object
      required:
        - id
      properties:
        id:
          type: string
    PollenUser:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: string
        name:
          type: string
        avatar:
          type: string
        defaultEmailAddress:
          type: string
    UndefinedResponse:
      type: null
