[Asterisk-code-review] ARI: Add duplicate channel ID checking for channel creation. (asterisk[master])

Mark Michelson asteriskteam at digium.com
Wed Oct 19 12:29:40 CDT 2016


Mark Michelson has uploaded a new change for review. ( https://gerrit.asterisk.org/4159 )

Change subject: ARI: Add duplicate channel ID checking for channel creation.
......................................................................

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 attemmpting 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
---
M res/ari/resource_channels.c
M res/res_ari_channels.c
M rest-api/api-docs/channels.json
3 files changed, 13 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/59/4159/1

diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index 8d32921..9bbca6c 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -1823,7 +1823,12 @@
 	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 25da17d..1eff989 100644
--- a/res/res_ari_channels.c
+++ b/res/res_ari_channels.c
@@ -385,6 +385,7 @@
 		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 ee18bfe..efe5f8a 100644
--- a/rest-api/api-docs/channels.json
+++ b/rest-api/api-docs/channels.json
@@ -213,6 +213,12 @@
 							"allowMultiple": false,
 							"dataType": "string"
 						}
+					],
+					"errorResponses": [
+						{
+							"code": 409,
+							"reason": "Channel with given unique ID already exists."
+						}
 					]
 				}
 			]

-- 
To view, visit https://gerrit.asterisk.org/4159
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I77f9253278c6947939c418073b6b31065489187c
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list