From: Mark Michelson Date: Wed, 19 Oct 2016 17:05:28 +0000 (-0500) Subject: ARI: Add duplicate channel ID checking for channel creation. X-Git-Tag: 14.2.0-rc1~75^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba145944a010441c1b1a744063178d967744f91f;p=thirdparty%2Fasterisk.git ARI: Add duplicate channel ID checking for channel creation. This is similar to what is done for origination, but for the 14 and up channel creation method. When attempting to create a channel, if a channel ID is specified and a channel already exists with that ID, then a 409 is returned. Change-Id: I77f9253278c6947939c418073b6b31065489187c --- diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c index 89c9d7f844..dfd9bc66bc 100644 --- a/res/ari/resource_channels.c +++ b/res/ari/resource_channels.c @@ -1826,7 +1826,12 @@ void ast_ari_channels_create(struct ast_variable *headers, ao2_cleanup(request_cap); if (!chan_data->chan) { - ast_ari_response_alloc_failed(response); + if (ast_channel_errno() == AST_CHANNEL_ERROR_ID_EXISTS) { + ast_ari_response_error(response, 409, "Conflict", + "Channel with given unique ID already exists"); + } else { + ast_ari_response_alloc_failed(response); + } ast_channel_cleanup(originator); chan_data_destroy(chan_data); return; diff --git a/res/res_ari_channels.c b/res/res_ari_channels.c index b7c088c4d1..9e8eeb4e90 100644 --- a/res/res_ari_channels.c +++ b/res/res_ari_channels.c @@ -386,6 +386,7 @@ static void ast_ari_channels_create_cb( break; case 500: /* Internal Server Error */ case 501: /* Not Implemented */ + case 409: /* Channel with given unique ID already exists. */ is_valid = 1; break; default: diff --git a/rest-api/api-docs/channels.json b/rest-api/api-docs/channels.json index 522cc00c49..e707c068f5 100644 --- a/rest-api/api-docs/channels.json +++ b/rest-api/api-docs/channels.json @@ -217,6 +217,12 @@ "allowMultiple": false, "dataType": "string" } + ], + "errorResponses": [ + { + "code": 409, + "reason": "Channel with given unique ID already exists." + } ] } ]