[svn-commits] pabelanger: branch 12 r400999 - in /branches/12: res/ rest-api/api-docs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Oct 15 10:26:19 CDT 2013


Author: pabelanger
Date: Tue Oct 15 10:26:17 2013
New Revision: 400999

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=400999
Log:
Use POST / DELETE to toggle hold / moh for ARI channels

This change updates how we handle toggle events, rather then create two
different function names, we'll just use POST / DELETE from HTTP to handle it.


Modified:
    branches/12/res/res_ari_channels.c
    branches/12/rest-api/api-docs/channels.json

Modified: branches/12/res/res_ari_channels.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_ari_channels.c?view=diff&rev=400999&r1=400998&r2=400999
==============================================================================
--- branches/12/res/res_ari_channels.c (original)
+++ branches/12/res/res_ari_channels.c Tue Oct 15 10:26:17 2013
@@ -680,7 +680,7 @@
 	return;
 }
 /*!
- * \brief Parameter parsing callback for /channels/{channelId}/unhold.
+ * \brief Parameter parsing callback for /channels/{channelId}/hold.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -722,23 +722,23 @@
 			is_valid = ast_ari_validate_void(
 				response->message);
 		} else {
-			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/unhold\n", code);
-			is_valid = 0;
-		}
-	}
-
-	if (!is_valid) {
-		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/unhold\n");
-		ast_ari_response_error(response, 500,
-			"Internal Server Error", "Response validation failed");
-	}
-#endif /* AST_DEVMODE */
-
-fin: __attribute__((unused))
-	return;
-}
-/*!
- * \brief Parameter parsing callback for /channels/{channelId}/mohstart.
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/hold\n", code);
+			is_valid = 0;
+		}
+	}
+
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/hold\n");
+		ast_ari_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/moh.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -786,23 +786,23 @@
 			is_valid = ast_ari_validate_void(
 				response->message);
 		} else {
-			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/mohstart\n", code);
-			is_valid = 0;
-		}
-	}
-
-	if (!is_valid) {
-		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mohstart\n");
-		ast_ari_response_error(response, 500,
-			"Internal Server Error", "Response validation failed");
-	}
-#endif /* AST_DEVMODE */
-
-fin: __attribute__((unused))
-	return;
-}
-/*!
- * \brief Parameter parsing callback for /channels/{channelId}/mohstop.
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/moh\n", code);
+			is_valid = 0;
+		}
+	}
+
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/moh\n");
+		ast_ari_response_error(response, 500,
+			"Internal Server Error", "Response validation failed");
+	}
+#endif /* AST_DEVMODE */
+
+fin: __attribute__((unused))
+	return;
+}
+/*!
+ * \brief Parameter parsing callback for /channels/{channelId}/moh.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -844,13 +844,13 @@
 			is_valid = ast_ari_validate_void(
 				response->message);
 		} else {
-			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/mohstop\n", code);
-			is_valid = 0;
-		}
-	}
-
-	if (!is_valid) {
-		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/mohstop\n");
+			ast_log(LOG_ERROR, "Invalid error response %d for /channels/{channelId}/moh\n", code);
+			is_valid = 0;
+		}
+	}
+
+	if (!is_valid) {
+		ast_log(LOG_ERROR, "Response validation failed for /channels/{channelId}/moh\n");
 		ast_ari_response_error(response, 500,
 			"Internal Server Error", "Response validation failed");
 	}
@@ -1199,33 +1199,17 @@
 	.path_segment = "hold",
 	.callbacks = {
 		[AST_HTTP_POST] = ast_ari_hold_channel_cb,
+		[AST_HTTP_DELETE] = ast_ari_unhold_channel_cb,
 	},
 	.num_children = 0,
 	.children = {  }
 };
 /*! \brief REST handler for /api-docs/channels.{format} */
-static struct stasis_rest_handlers channels_channelId_unhold = {
-	.path_segment = "unhold",
-	.callbacks = {
-		[AST_HTTP_POST] = ast_ari_unhold_channel_cb,
-	},
-	.num_children = 0,
-	.children = {  }
-};
-/*! \brief REST handler for /api-docs/channels.{format} */
-static struct stasis_rest_handlers channels_channelId_mohstart = {
-	.path_segment = "mohstart",
+static struct stasis_rest_handlers channels_channelId_moh = {
+	.path_segment = "moh",
 	.callbacks = {
 		[AST_HTTP_POST] = ast_ari_moh_start_channel_cb,
-	},
-	.num_children = 0,
-	.children = {  }
-};
-/*! \brief REST handler for /api-docs/channels.{format} */
-static struct stasis_rest_handlers channels_channelId_mohstop = {
-	.path_segment = "mohstop",
-	.callbacks = {
-		[AST_HTTP_POST] = ast_ari_moh_stop_channel_cb,
+		[AST_HTTP_DELETE] = ast_ari_moh_stop_channel_cb,
 	},
 	.num_children = 0,
 	.children = {  }
@@ -1266,8 +1250,8 @@
 		[AST_HTTP_GET] = ast_ari_get_channel_cb,
 		[AST_HTTP_DELETE] = ast_ari_delete_channel_cb,
 	},
-	.num_children = 12,
-	.children = { &channels_channelId_dial,&channels_channelId_continue,&channels_channelId_answer,&channels_channelId_mute,&channels_channelId_unmute,&channels_channelId_hold,&channels_channelId_unhold,&channels_channelId_mohstart,&channels_channelId_mohstop,&channels_channelId_play,&channels_channelId_record,&channels_channelId_variable, }
+	.num_children = 10,
+	.children = { &channels_channelId_dial,&channels_channelId_continue,&channels_channelId_answer,&channels_channelId_mute,&channels_channelId_unmute,&channels_channelId_hold,&channels_channelId_moh,&channels_channelId_play,&channels_channelId_record,&channels_channelId_variable, }
 };
 /*! \brief REST handler for /api-docs/channels.{format} */
 static struct stasis_rest_handlers channels = {

Modified: branches/12/rest-api/api-docs/channels.json
URL: http://svnview.digium.com/svn/asterisk/branches/12/rest-api/api-docs/channels.json?view=diff&rev=400999&r1=400998&r2=400999
==============================================================================
--- branches/12/rest-api/api-docs/channels.json (original)
+++ branches/12/rest-api/api-docs/channels.json Tue Oct 15 10:26:17 2013
@@ -433,11 +433,11 @@
 			]
 		},
 		{
-			"path": "/channels/{channelId}/unhold",
+			"path": "/channels/{channelId}/hold",
 			"description": "Remove a channel from hold",
 			"operations": [
 				{
-					"httpMethod": "POST",
+					"httpMethod": "DELETE",
 					"summary": "Remove a channel from hold.",
 					"nickname": "unholdChannel",
 					"responseClass": "void",
@@ -465,7 +465,7 @@
 			]
 		},
 		{
-			"path": "/channels/{channelId}/mohstart",
+			"path": "/channels/{channelId}/moh",
 			"description": "Play music on hold to a channel",
 			"operations": [
 				{
@@ -506,11 +506,11 @@
 			]
 		},
 		{
-			"path": "/channels/{channelId}/mohstop",
+			"path": "/channels/{channelId}/moh",
 			"description": "Stop playing music on hold to a channel",
 			"operations": [
 				{
-					"httpMethod": "POST",
+					"httpMethod": "DELETE",
 					"summary": "Stop playing music on hold to a channel.",
 					"nickname": "mohStopChannel",
 					"responseClass": "void",




More information about the svn-commits mailing list