]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
ari endpoints: GET /ari/endpoints/{invalid-tech} should return a 404
authorKevin Harwell <kharwell@digium.com>
Tue, 12 Nov 2013 22:15:41 +0000 (22:15 +0000)
committerKevin Harwell <kharwell@digium.com>
Tue, 12 Nov 2013 22:15:41 +0000 (22:15 +0000)
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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@402787 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/ari/resource_endpoints.c
res/res_ari_endpoints.c
rest-api/api-docs/endpoints.json

index 181ce7a503ef3fd53fde23c6a1b184d6fe04140b..e08f6e5594e376c0dc4c8b458faefb71b961f94c 100644 (file)
@@ -89,8 +89,6 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
        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 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
        }
        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,
index 082272518a5427221469a181ccddbc7da84f8145..10accb9680312183b89f77925e52030488ea3309 100644 (file)
@@ -134,6 +134,7 @@ static void ast_ari_endpoints_list_by_tech_cb(
                break;
        case 500: /* Internal Server Error */
        case 501: /* Not Implemented */
+       case 404: /* Endpoints not found */
                is_valid = 1;
                break;
        default:
@@ -193,6 +194,7 @@ static void ast_ari_endpoints_get_cb(
                break;
        case 500: /* Internal Server Error */
        case 501: /* Not Implemented */
+       case 404: /* Endpoints not found */
                is_valid = 1;
                break;
        default:
index c44e3dd7ef7ebb676034a2c268459f6e175fd6c2..fb66357a76431244589d3f7926eae075bd18b3ab 100644 (file)
                                                        "paramType": "path",
                                                        "dataType": "string"
                                                }
+                                       ],
+                                       "errorResponses": [
+                                               {
+                                                       "code": 404,
+                                                       "reason": "Endpoints not found"
+                                               }
                                        ]
                                }
                        ]
                                                        "paramType": "path",
                                                        "dataType": "string"
                                                }
+                                       ],
+                                       "errorResponses": [
+                                               {
+                                                       "code": 404,
+                                                       "reason": "Endpoints not found"
+                                               }
                                        ]
                                }
                        ]