From 3b84377154da23b8b5a011a7c0344f36f56ced16 Mon Sep 17 00:00:00 2001 From: jannovak-msft <81623717+jannovak-msft@users.noreply.github.com> Date: Mon, 14 Jun 2021 19:33:25 +0200 Subject: [PATCH] New SIP routing API version preview/2021-05-01-preview (#14500) * sip routing API * return 422 instead of 400 * change missing trunk error message * add 'error' prefix in error examples * describe patch behaviour * use the standard Azure error * remove unnecessary descriptions * fix descriptions * change fqdn max length * remove locale from example params and change endpoint * use the standard Azure error in examples * unify tags * use CommunicationServicesCommon/CommunicationErrorResponse * refactor sip configuration patch into separate class * fix CommunicationErrorResponse file path * add x-ms-error-response flag * add http errors schemas --- .../communicationservicessiprouting.json | 259 ++++++++++++++++++ .../examples/GetSipConfiguration.json | 35 +++ .../examples/PatchSipConfiguration.json | 76 +++++ .../data-plane/SipRouting/readme.csharp.md | 15 + .../data-plane/SipRouting/readme.md | 66 +++++ .../data-plane/SipRouting/readme.python.md | 21 ++ .../data-plane/SipRouting/readme.ruby.md | 19 ++ .../SipRouting/readme.typescript.md | 13 + 8 files changed, 504 insertions(+) create mode 100644 specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/communicationservicessiprouting.json create mode 100644 specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/GetSipConfiguration.json create mode 100644 specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/PatchSipConfiguration.json create mode 100644 specification/communication/data-plane/SipRouting/readme.csharp.md create mode 100644 specification/communication/data-plane/SipRouting/readme.md create mode 100644 specification/communication/data-plane/SipRouting/readme.python.md create mode 100644 specification/communication/data-plane/SipRouting/readme.ruby.md create mode 100644 specification/communication/data-plane/SipRouting/readme.typescript.md diff --git a/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/communicationservicessiprouting.json b/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/communicationservicessiprouting.json new file mode 100644 index 00000000000..f50f588232f --- /dev/null +++ b/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/communicationservicessiprouting.json @@ -0,0 +1,259 @@ +{ + "swagger": "2.0", + "info": { + "title": "SipRouting Service", + "description": "SipRouting Service", + "contact": { + "email": "acsdevexdisc@microsoft.com" + }, + "version": "2021-05-01-preview" + }, + "paths": { + "/sip": { + "get": { + "tags": [ + "SipConfiguration" + ], + "summary": "Gets SIP configuration for resource.", + "operationId": "GetSipConfiguration", + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Ok.", + "schema": { + "$ref": "#/definitions/SipConfiguration" + } + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "../../../Common/stable/2021-03-07/common.json#/definitions/CommunicationErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Get SIP configuration for resource": { + "$ref": "./examples/GetSipConfiguration.json" + } + } + }, + "patch": { + "tags": [ + "SipConfiguration" + ], + "summary": "Patches SIP configuration for resource.", + "operationId": "PatchSipConfiguration", + "consumes": [ + "application/merge-patch+json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "in": "body", + "name": "body", + "description": "Configuration patch.", + "schema": { + "$ref": "#/definitions/SipConfigurationPatch" + } + } + ], + "responses": { + "200": { + "description": "Patched configuration is returned.", + "schema": { + "$ref": "#/definitions/SipConfiguration" + } + }, + "415": { + "description": "Unsupported media type of the patch.", + "schema": { + "$ref": "../../../Common/stable/2021-03-07/common.json#/definitions/CommunicationErrorResponse" + }, + "x-ms-error-response": true + }, + "422": { + "description": "If the request is empty, unprocessable or inconsistent with the stored data.", + "schema": { + "$ref": "../../../Common/stable/2021-03-07/common.json#/definitions/CommunicationErrorResponse" + }, + "x-ms-error-response": true + }, + "500": { + "description": "All other api errors.", + "schema": { + "$ref": "../../../Common/stable/2021-03-07/common.json#/definitions/CommunicationErrorResponse" + }, + "x-ms-error-response": true + }, + "default": { + "description": "Failure", + "schema": { + "$ref": "../../../Common/stable/2021-03-07/common.json#/definitions/CommunicationErrorResponse" + }, + "x-ms-error-response": true + } + }, + "x-ms-examples": { + "Patch SIP configuration for resource": { + "$ref": "./examples/PatchSipConfiguration.json" + } + } + } + } + }, + "definitions": { + "Trunk": { + "description": "Represents a SIP trunk for routing calls. See RFC 4904.", + "required": [ + "sipSignalingPort" + ], + "type": "object", + "properties": { + "sipSignalingPort": { + "format": "int32", + "description": "Gets or sets SIP signaling port of the trunk.", + "type": "integer" + } + } + }, + "TrunkPatch": { + "description": "Represents a SIP trunk patch.", + "type": "object", + "properties": { + "sipSignalingPort": { + "format": "int32", + "description": "Gets or sets SIP signaling port of the trunk.", + "type": "integer" + } + } + }, + "TrunkRoute": { + "description": "Represents a trunk route for routing calls.", + "required": [ + "name", + "numberPattern" + ], + "type": "object", + "properties": { + "description": { + "description": "Gets or sets description of the route.", + "maxLength": 1024, + "type": "string" + }, + "name": { + "description": "Gets or sets name of the route.", + "maxLength": 256, + "type": "string" + }, + "numberPattern": { + "description": "Gets or sets regex number pattern for routing calls. .NET regex format is supported.\r\nThe regex should match only digits with an optional '+' prefix without spaces.\r\nI.e. \"^\\+[1-9][0-9]{3,23}$\".", + "maxLength": 1024, + "type": "string" + }, + "trunks": { + "description": "Gets or sets list of SIP trunks for routing calls. Trunks are represented as FQDN.", + "maxLength": 250, + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "SipConfiguration": { + "description": "Represents a SIP configuration.\r\nWhen a call is being routed the routes are applied in the same order as in the routes list.\r\nA route is matched by its number pattern.\r\nCall is then directed into route's first available trunk, based on the order in the route's trunks list.", + "type": "object", + "properties": { + "trunks": { + "description": "SIP trunks for routing calls.\r\nMap key is trunk's FQDN (1-249 characters).", + "maxLength": 250, + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Trunk" + } + }, + "routes": { + "description": "Trunk routes for routing calls.", + "maxLength": 250, + "type": "array", + "items": { + "$ref": "#/definitions/TrunkRoute" + } + } + } + }, + "SipConfigurationPatch": { + "description": "Represents a SIP configuration patch.", + "type": "object", + "properties": { + "trunks": { + "description": "SIP trunks for routing calls.\r\nMap key is trunk's FQDN (1-249 characters).", + "maxLength": 250, + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/TrunkPatch" + } + }, + "routes": { + "description": "Trunk routes for routing calls.", + "maxLength": 250, + "type": "array", + "items": { + "$ref": "#/definitions/TrunkRoute" + } + } + } + } + }, + "parameters": { + "ApiVersionParameter": { + "in": "query", + "name": "api-version", + "description": "Version of API to invoke", + "required": true, + "type": "string" + }, + "Endpoint": { + "in": "path", + "name": "endpoint", + "description": "The communication resource, for example https://resourcename.communication.azure.com", + "required": true, + "type": "string", + "x-ms-skip-url-encoding": true, + "x-ms-parameter-location": "client" + } + }, + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + }, + "description": "Azure Active Directory OAuth2 Flow" + } + }, + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/Endpoint" + } + ] + } +} diff --git a/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/GetSipConfiguration.json b/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/GetSipConfiguration.json new file mode 100644 index 00000000000..a1d81517a88 --- /dev/null +++ b/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/GetSipConfiguration.json @@ -0,0 +1,35 @@ +{ + "parameters": { + "api-version": "2021-05-01-preview", + "endpoint": "https://resourcename.communication.azure.com/" + }, + "responses": { + "200": { + "headers": {}, + "body": { + "trunks": { + "vendor.xyz.biz": { + "sipSignalingPort": 5061 + }, + "vendor.abc.biz": { + "sipSignalingPort": 5061 + } + }, + "routes": [ + { + "name": "LocalRoute", + "numberPattern": "^\\+1[0-9]{10}$" + }, + { + "name": "VendorXYZ", + "description": "External route XYZ", + "numberPattern": "^\\+?\\d+$", + "trunks": [ + "vendor.xyz.biz" + ] + } + ] + } + } + } +} diff --git a/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/PatchSipConfiguration.json b/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/PatchSipConfiguration.json new file mode 100644 index 00000000000..ba703fcfde7 --- /dev/null +++ b/specification/communication/data-plane/SipRouting/preview/2021-05-01-preview/examples/PatchSipConfiguration.json @@ -0,0 +1,76 @@ +{ + "parameters": { + "api-version": "2021-05-01-preview", + "body": { + "trunks": { + "vendor.xyz.biz": { + "sipSignalingPort": 5061 + } + }, + "routes": [ + { + "name": "VendorXYZ", + "description": "External route XYZ", + "numberPattern": "^\\+?\\d+$", + "trunks": [ + "vendor.xyz.biz" + ] + } + ] + }, + "endpoint": "https://resourcename.communication.azure.com/" + }, + "responses": { + "200": { + "headers": {}, + "body": { + "trunks": { + "vendor.xyz.biz": { + "sipSignalingPort": 5061 + } + }, + "routes": [ + { + "name": "VendorXYZ", + "description": "External route XYZ", + "numberPattern": "^\\+?\\d+$", + "trunks": [ + "vendor.xyz.biz" + ] + } + ] + } + }, + "415": { + "headers": {}, + "body": { + "error": { + "code": "UnsupportedMediaType", + "message": "Unsupported Media Type." + } + } + }, + "422": { + "headers": {}, + "body": { + "error": { + "code": "UnprocessableEntity", + "message": "One or more request inputs are not valid.", + "innererror": { + "code": "InvalidRegex", + "message": "Unsupported regex format provided." + } + } + } + }, + "500": { + "headers": {}, + "body": { + "error": { + "code": "InternalError", + "message": "The server encountered an internal error." + } + } + } + } +} diff --git a/specification/communication/data-plane/SipRouting/readme.csharp.md b/specification/communication/data-plane/SipRouting/readme.csharp.md new file mode 100644 index 00000000000..2efd3715cdc --- /dev/null +++ b/specification/communication/data-plane/SipRouting/readme.csharp.md @@ -0,0 +1,15 @@ +## C + +These settings apply only when `--csharp` is specified on the command line. +Please also specify `--csharp-sdks-folder=`. + +```yaml $(csharp) +csharp: + azure-arm: true + license-header: MICROSOFT_MIT_NO_VERSION + payload-flattening-threshold: 1 + clear-output-folder: true + client-side-validation: false + namespace: Microsoft.CommunicationServices + output-folder: $(csharp-sdks-folder)/communicationservices/management/Microsoft.CommunicationServices/GeneratedProtocol +``` diff --git a/specification/communication/data-plane/SipRouting/readme.md b/specification/communication/data-plane/SipRouting/readme.md new file mode 100644 index 00000000000..0cc6817ee49 --- /dev/null +++ b/specification/communication/data-plane/SipRouting/readme.md @@ -0,0 +1,66 @@ +# communicationservices + +> see https://aka.ms/autorest + +This is the AutoRest configuration file for communicationservices. + +## Getting Started + +To build the SDKs for My API, simply install AutoRest via `npm` (`npm install -g autorest`) and then run: + +> `autorest readme.md` + +To see additional help and options, run: + +> `autorest --help` + +For other options on installation see [Installing AutoRest](https://aka.ms/autorest/install) on the AutoRest github page. + +--- + +## Configuration + +### Basic Information + +These are the global settings for the communicationservices. + +```yaml +openapi-type: data-plane +tag: package-2021-05-01-preview +``` + +### Tag: package-2021-05-01-preview + +These settings apply only when `--tag=package-2021-05-01-preview` is specified on the command line. + +```yaml $(tag) == 'package-2021-05-01-preview' +input-file: + - preview/2021-05-01-preview/communicationservicessiprouting.json +title: + Azure Communication Services +``` + +--- + +# Code Generation + +## Swagger to SDK + +This section describes what SDK should be generated by the automatic system. +This is not used by Autorest itself. + +## Python + +See configuration in [readme.python.md](./readme.python.md) + +## Ruby + +See configuration in [readme.ruby.md](./readme.ruby.md) + +## TypeScript + +See configuration in [readme.typescript.md](./readme.typescript.md) + +## CSharp + +See configuration in [readme.csharp.md](./readme.csharp.md) diff --git a/specification/communication/data-plane/SipRouting/readme.python.md b/specification/communication/data-plane/SipRouting/readme.python.md new file mode 100644 index 00000000000..f5192ef154c --- /dev/null +++ b/specification/communication/data-plane/SipRouting/readme.python.md @@ -0,0 +1,21 @@ +## Python + +These settings apply only when `--python` is specified on the command line. +Please also specify `--python-sdks-folder=`. + +```yaml $(python) +python: + azure-arm: true + license-header: MICROSOFT_MIT_NO_VERSION + payload-flattening-threshold: 2 + namespace: Microsoft.CommunicationServices + package-name: communicationservices + package-version: 2021-05-01-preview + clear-output-folder: true +``` + +```yaml $(python) +python: + no-namespace-folders: true + output-folder: $(python-sdks-folder)/azure-mgmt/communicationservices +``` diff --git a/specification/communication/data-plane/SipRouting/readme.ruby.md b/specification/communication/data-plane/SipRouting/readme.ruby.md new file mode 100644 index 00000000000..3e261aae6a2 --- /dev/null +++ b/specification/communication/data-plane/SipRouting/readme.ruby.md @@ -0,0 +1,19 @@ +## Ruby + +These settings apply only when `--ruby` is specified on the command line. + +```yaml +package-name: azure_mgmt_communicationservices +package-version: 2021-05-01-preview +azure-arm: true +``` + +### Tag: package-2021-05-01-preview and ruby + +These settings apply only when `--tag=package-2021-05-01-preview --ruby` is specified on the command line. +Please also specify `--ruby-sdks-folder=`. + +```yaml $(tag) == 'package-2021-05-01-preview' && $(ruby) +namespace: Microsoft.CommunicationServices +output-folder: $(ruby-sdks-folder)/communicationservices +``` diff --git a/specification/communication/data-plane/SipRouting/readme.typescript.md b/specification/communication/data-plane/SipRouting/readme.typescript.md new file mode 100644 index 00000000000..be9f877fd1c --- /dev/null +++ b/specification/communication/data-plane/SipRouting/readme.typescript.md @@ -0,0 +1,13 @@ +## TypeScript + +These settings apply only when `--typescript` is specified on the command line. +Please also specify `--typescript-sdks-folder=`. + +```yaml $(typescript) +typescript: + azure-arm: true + package-name: "communicationservices" + output-folder: "$(typescript-sdks-folder)/packages/communicationservices" + payload-flattening-threshold: 1 + generate-metadata: true +```