# Copyright 2018 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
openapi: 3.1.0
info:
  title: Matrix Client-Server Application Service Room Directory API
  version: 1.0.0
paths:
  "/directory/list/appservice/{networkId}/{roomId}":
    put:
      summary: Updates a room's visibility in the application service's room directory.
      description: |-
        Updates the visibility of a given room on the application service's room
        directory.

        This API is similar to the room directory visibility API used by clients
        to update the homeserver's more general room directory.

        This API requires the use of an application service access token (`as_token`)
        instead of a typical client's access_token. This API cannot be invoked by
        users who are not identified as application services.
      operationId: updateAppserviceRoomDirectoryVisibility
      parameters:
        - in: path
          name: networkId
          description: |-
            The protocol (network) ID to update the room list for. This would
            have been provided by the application service as being listed as
            a supported protocol.
          required: true
          example: irc
          schema:
            type: string
        - in: path
          name: roomId
          description: The room ID to add to the directory.
          required: true
          example: "!somewhere:example.org"
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                visibility:
                  type: string
                  enum:
                    - public
                    - private
                  description: |-
                    Whether the room should be visible (public) in the directory
                    or not (private).
                  example: public
              required:
                - visibility
        required: true
      security:
        - appserviceAccessTokenQuery: []
        - appserviceAccessTokenBearer: []
      responses:
        "200":
          description: The room's directory visibility has been updated.
          content:
            application/json:
              schema:
                type: object
              examples:
                response:
                  value: {}
      tags:
        - Application service room directory management
servers:
  - url: "{protocol}://{hostname}{basePath}"
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      hostname:
        default: localhost:8008
      basePath:
        default: /_matrix/client/v3
components:
  securitySchemes:
    appserviceAccessTokenQuery:
      $ref: definitions/security.yaml#/appserviceAccessTokenQuery
    appserviceAccessTokenBearer:
      $ref: definitions/security.yaml#/appserviceAccessTokenBearer
