diff --git a/res/ari/resource_endpoints.c b/res/ari/resource_endpoints.c index 181ce7a503..e08f6e5594 100644 --- a/res/ari/resource_endpoints.c +++ b/res/ari/resource_endpoints.c @@ -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, diff --git a/res/res_ari_endpoints.c b/res/res_ari_endpoints.c index 082272518a..10accb9680 100644 --- a/res/res_ari_endpoints.c +++ b/res/res_ari_endpoints.c @@ -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: diff --git a/rest-api/api-docs/endpoints.json b/rest-api/api-docs/endpoints.json index c44e3dd7ef..fb66357a76 100644 --- a/rest-api/api-docs/endpoints.json +++ b/rest-api/api-docs/endpoints.json @@ -35,6 +35,12 @@ "paramType": "path", "dataType": "string" } + ], + "errorResponses": [ + { + "code": 404, + "reason": "Endpoints not found" + } ] } ] @@ -61,6 +67,12 @@ "paramType": "path", "dataType": "string" } + ], + "errorResponses": [ + { + "code": 404, + "reason": "Endpoints not found" + } ] } ]