openapi: 3.0.3
info:
  title: Analytics Settings REST API
  version: '7.6'
  license:
    name: Business Source License 1.1
    url: https://github.com/couchbaselabs/cb-swagger/blob/release/7.6/licenses/BSL-Couchbase.txt
  description: |
    The Analytics Settings REST API is provided by the Analytics service.
    This API enables you to view or set cluster-level Analytics settings.

servers:
  - url: '{scheme}://{host}:{port}'
    description: The URL scheme, host, and port are as follows.
    variables:
      scheme:
        default: http
        description: |-
          The URL scheme.
          Use `https` for secure access.
        enum:
          - http
          - https
      host:
        default: localhost
        description: The host name or IP address of a node running the Analytics Service.
      port:
        default: "8091"
        description: |-
          The Cluster administration REST port.
          Use `18091` for secure access.

          Note that the port numbers for this REST API are different to the port numbers used by the other Analytics REST APIs.
        enum:
          - "8091"
          - "18091"

paths:
  /settings/analytics:
    get:
      operationId: get_settings
      summary: View Analytics Settings
      description: >
        Retrieves cluster-level Analytics settings.
        Note that only one setting is available: `numReplicas`.
      security:
        - ClusterReadPoolsRead: []
      responses:
        "200":
          $ref: '#/components/responses/OK'
        "401":
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: post_settings
      summary: Modify Analytics Settings
      description: >
        Sets cluster-level Analytics settings.
        Note that only one setting is available: `numReplicas`.
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: "#/components/schemas/Settings"
      security:
        - ClusterReadPoolsRead: []
      responses:
        "200":
          $ref: '#/components/responses/OK'
        "400":
          $ref: '#/components/responses/BadRequest'
        "401":
          $ref: '#/components/responses/Unauthorized'

components:
 schemas:
  Settings:
    type: object
    properties:
      numReplicas:
        type: integer
        minimum: 0
        maximum: 3
        description: Specifies the number of replicas for Analytics.
        x-has-example: true
        example: 3

 responses:
  OK:
    description: The operation was successful.
    content:
      application/json:
        schema:
          $ref: "#/components/schemas/Settings"

  BadRequest:
    description: >
      Bad request.
      A parameter has an incorrect value.
    content:
      application/json:
        schema:
          type: object

  Unauthorized:
    description: >
      Unauthorized.
      The user name or password may be incorrect.
    content:
      application/json:
        schema:
          type: object

 securitySchemes:
  ClusterReadPoolsRead:
    x-displayName: Cluster Read / Pools Read
    type: http
    scheme: basic
    description: |-
      Users must have one of the following RBAC roles:

      * Full Admin
      * Cluster Admin
      * Read-Only Admin
      * Analytics Admin