[svn-commits] kharwell: trunk r402788 - in /trunk: ./ res/ res/ari/ rest-api/api-docs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Nov 12 16:17:30 CST 2013


Author: kharwell
Date: Tue Nov 12 16:17:28 2013
New Revision: 402788

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402788
Log:
ari endpoints: GET /ari/endpoints/{invalid-tech} should return a 404

Implementation listing endpoints by technology returned an empty array if no
matching endpoints were found.  Fixed so a "404 Not Found" will be returned
instead.

(closes issue ASTERISK-22803)
Reported by: David M. Lee
........

Merged revisions 402787 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/ari/resource_endpoints.c
    trunk/res/res_ari_endpoints.c
    trunk/rest-api/api-docs/endpoints.json

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Nov 12 16:17:28 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402738,402755,402757,402767,402769
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402738,402755,402757,402767,402769,402787

Modified: trunk/res/ari/resource_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/resource_endpoints.c?view=diff&rev=402788&r1=402787&r2=402788
==============================================================================
--- trunk/res/ari/resource_endpoints.c (original)
+++ trunk/res/ari/resource_endpoints.c Tue Nov 12 16:17:28 2013
@@ -89,8 +89,6 @@
 	struct ao2_iterator i;
 	void *obj;
 
-	/* TODO - if tech isn't a recognized type of endpoint, it should 404 */
-
 	cache = ast_endpoint_cache();
 	if (!cache) {
 		ast_ari_response_error(
@@ -131,7 +129,12 @@
 	}
 	ao2_iterator_destroy(&i);
 
-	ast_ari_response_ok(response, ast_json_ref(json));
+	if (ast_json_array_size(json)) {
+		ast_ari_response_ok(response, ast_json_ref(json));
+	} else {
+		ast_ari_response_error(response, 404, "Not Found",
+				       "No Endpoints found with tech %s", args->tech);
+	}
 }
 void ast_ari_endpoints_get(struct ast_variable *headers,
 	struct ast_ari_endpoints_get_args *args,

Modified: trunk/res/res_ari_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_ari_endpoints.c?view=diff&rev=402788&r1=402787&r2=402788
==============================================================================
--- trunk/res/res_ari_endpoints.c (original)
+++ trunk/res/res_ari_endpoints.c Tue Nov 12 16:17:28 2013
@@ -134,6 +134,7 @@
 		break;
 	case 500: /* Internal Server Error */
 	case 501: /* Not Implemented */
+	case 404: /* Endpoints not found */
 		is_valid = 1;
 		break;
 	default:
@@ -193,6 +194,7 @@
 		break;
 	case 500: /* Internal Server Error */
 	case 501: /* Not Implemented */
+	case 404: /* Endpoints not found */
 		is_valid = 1;
 		break;
 	default:

Modified: trunk/rest-api/api-docs/endpoints.json
URL: http://svnview.digium.com/svn/asterisk/trunk/rest-api/api-docs/endpoints.json?view=diff&rev=402788&r1=402787&r2=402788
==============================================================================
--- trunk/rest-api/api-docs/endpoints.json (original)
+++ trunk/rest-api/api-docs/endpoints.json Tue Nov 12 16:17:28 2013
@@ -35,6 +35,12 @@
 							"paramType": "path",
 							"dataType": "string"
 						}
+					],
+					"errorResponses": [
+						{
+							"code": 404,
+							"reason": "Endpoints not found"
+						}
 					]
 				}
 			]
@@ -60,6 +66,12 @@
 							"description": "ID of the endpoint",
 							"paramType": "path",
 							"dataType": "string"
+						}
+					],
+					"errorResponses": [
+						{
+							"code": 404,
+							"reason": "Endpoints not found"
 						}
 					]
 				}




More information about the svn-commits mailing list