# Copyright 2016 OpenMarket 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 Voice over IP API
  version: 1.0.0
paths:
  /voip/turnServer:
    get:
      summary: Obtain TURN server credentials.
      description: |-
        This API provides credentials for the client to use when initiating
        calls.
      operationId: getTurnServer
      security:
        - accessTokenQuery: []
        - accessTokenBearer: []
      responses:
        "200":
          description: The TURN server credentials.
          content:
            application/json:
              schema:
                type: object
                properties:
                  username:
                    type: string
                    description: The username to use.
                  password:
                    type: string
                    description: The password to use.
                  uris:
                    type: array
                    items:
                      type: string
                    description: A list of TURN URIs
                  ttl:
                    type: integer
                    description: The time-to-live in seconds
                required:
                  - username
                  - password
                  - uris
                  - ttl
              examples:
                response:
                  value: {
                    "username": "1443779631:@user:example.com",
                    "password": "JlKfBy1QwLrO20385QyAtEyIv0=",
                    "uris": [
                      "turn:turn.example.com:3478?transport=udp",
                      "turn:10.20.30.40:3478?transport=tcp",
                      "turns:10.20.30.40:443?transport=tcp"
                    ],
                    "ttl": 86400
                  }
        "429":
          description: This request was rate-limited.
          content:
            application/json:
              schema:
                $ref: definitions/errors/rate_limited.yaml
      tags:
        - VOIP
servers:
  - url: "{protocol}://{hostname}{basePath}"
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      hostname:
        default: localhost:8008
      basePath:
        default: /_matrix/client/v3
components:
  securitySchemes:
    accessTokenQuery:
      $ref: definitions/security.yaml#/accessTokenQuery
    accessTokenBearer:
      $ref: definitions/security.yaml#/accessTokenBearer
