openapi: "3.0.1"
info:
  title: "Rasa Platform - Project"
  version: "1.0.0"
  description: >-
    Rasa Platform project endpoints
servers:
- url: http://demo-bot.rasa.com/api
  description: Demo
paths:
  /health:
    get:
      tags:
      - Status
      summary: Fetch status of services
      operationId: status
      responses:
        200:
          description: Status of services
          content:
            application/json:
              schema:
                type: object
                properties:
                  nlu:
                    type: string
                  core:
                    type: string
                    nullable: true
  /version:
    get:
      tags:
      - Version
      summary: Fetch versions of services
      operationId: versions
      responses:
        200:
          description: Versions of services
          content:
            application/json:
              schema:
                type: object
                properties:
                  nlu:
                    type: object
                    properties:
                      version:
                        type: string
                      minimum_compatible_version:
                        type: string
                  core:
                    type: object
                    properties:
                      environment:
                        type:
                          string
                      version:
                        type:
                          string
                  platform:
                    type: string
  /logs:
    get:
      tags:
      - logs
      summary: Get the logs of the Platform services
      operationId: getLogs
      parameters:
      - name: api_token
        in: query
        description: a user's api token
        required: true
      responses:
        200:
          description: logs as a zip file
          content:
            application/zip: {}
        401:
          description: unauthorized
          content:
            text/plain:
              schema:
                type: string
        500:
          description: error collecting logs
          content:
            text/plain:
              schema:
                type: string
  /auth:
    post:
      tags:
      - User
      summary: Perform authentication
      operationId: login
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - username
              - password
              properties:
                username:
                  type: string
                password:
                  type: string
      responses:
        200:
          description: Success status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        401:
          description: Wrong schema
          content:
            text/plain:
              schema:
                type: string
                enum:
                - wrong schema
                - unauthorized
  /user:
    get:
      tags:
      - User
      summary: Get information about this user
      operationId: getUserMe
      responses:
        200:
          description: Current user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
    patch:
      tags:
      - User
      summary: Update username
      operationId: updateUsername
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                username:
                  type: string
      responses:
        200:
          description: Current user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
  /users:
    post:
      tags:
      - User
      summary: Create a new user
      operationId: createUser
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
      responses:
        200:
          description: Created user
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
        401:
          description: wrong schema
    get:
      tags:
      - User
      summary: List all users
      operationId: getUsers
      responses:
        200:
          description: List of users
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
  /users/{username}:
    delete:
      tags:
      - User
      summary: Delete a user
      operationId: deleteUser
      parameters:
      - $ref: './common.yml#/components/parameters/username'
      responses:
        200:
          description: Deleted user
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/User'
                - type: object
                  properties:
                    error:
                      type: string
  /users/{username}/roles:
    get:
      tags:
      - Role
      summary: Get user roles
      operationId: getUserRole
      parameters:
      - $ref: './common.yml#/components/parameters/username'
      responses:
        200:
          description: User roles
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
                  description: role of user {username}
  /users/{username}/roles/{role}:
    put:
      tags:
      - Role
      summary: Update user role
      operationId: updateUserRole
      parameters:
      - $ref: './common.yml#/components/parameters/username'
      - $ref: './common.yml#/components/parameters/role'
      responses:
        200:
          description: Updated user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
    delete:
      tags:
      - Role
      summary: Delete user role
      operationId: deleteUserRole
      parameters:
      - $ref: './common.yml#/components/parameters/username'
      - in: path
        name: role
        schema:
          type: string
        required: true
      responses:
        200:
          description: Deleted user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
  /user/password:
    post:
      tags:
      - User
      summary: Change password
      operationId: changePassword
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - username
              - old_password
              - new_password
              - new_password_confirm
              properties:
                username:
                  type: string
                old_password:
                  type: string
                new_password:
                  type: string
                new_password_confirm:
                  type: string
      responses:
        200:
          description: User whose password was just changed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        401:
          description: wrong schema
        400:
          description: user not found, wrong password
  /roles:
    get:
      tags:
      - roles
      summary: List user roles
      operationId: listRoles
      responses:
        200:
          description: List of roles
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Role'
  /projects/{project_id}:
    post:
      tags:
      - Project
      summary: Create a project
      description: Not recommended to be used. The frontend only supports a single project.
      operationId: postProject
      parameters:
      - in: path
        name: project_id
        schema:
          type: string
        required: true
      responses:
        200:
          description: Newly created project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Project'
        401:
          $ref: '#/components/responses/UnauthorizedError'
  /features:
    get:
      tags:
      - FeatureFlag
      summary: Retrieve all features flags
      operationId: getFeatureFlags
      responses:
        200:
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FeatureFlag'
    post:
      tags:
      - FeatureFlag
      summary: Update or create a feature flag
      operationId: updateFeatureFlag
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureFlag'
      responses:
        200:
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeatureFlag'
        401:
          description: wrong schema
        400:
          $ref: '#/components/responses/UnauthorizedError'

  /environments:
    get:
      tags:
      - Environments
      summary: Retrieve Platform deployment environment metadata
      operationId: getEnvironmentsConfig
      responses:
        200:
          description: Deployment environment configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  environments:
                    description: YAML string
                    type: string
        400:
          description: could not find environment settings
        401:
          $ref: '#/components/responses/UnauthorizedError'
    put:
      tags:
      - Environments
      summary: Save Platform deployment environment config
      operationId: saveEnvironmentsConfig
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                environments:
                  description: YAML string
                  type: string
      responses:
        200:
          description: Saved configuration of Platform deployment environments
          content:
            application/json:
              schema:
                type: object
                properties:
                  environments:
                    description: YAML string
                    type: string
        400:
          description: could not find settings
        401:
          $ref: '#/components/responses/UnauthorizedError'

components:
  responses:
    UnauthorizedError:
      description: Access token is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              exception:
                type: string
              reasons:
                oneOf:
                - type: string
                - type: array
                  items:
                    type: string
  schemas:
    FeatureFlag:
      type: object
      description: Information about a toggable feature
      properties:
        name:
          description: Name of the feature
          type: string
        enabled:
          description: Is the feature activated
          type: boolean
    User:
      type: object
      properties:
        username:
          type: string
        password:
          type: string
        role:
          type: string
        api_token:
          type: string
        projects:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              role:
                type: string
        authentication_mechanism:
          type: string
    Role:
      type: object
      properties:
        role:
          type: string
        permissions:
          type: list
          items:
            type: string
    Project:
      type: object
      properties:
        project_id:
          type: string
        role:
          type: string
