fix: generate bridge api response code
fix: generate connector api response code SUITE fix: generate exhook api response code
This commit is contained in:
parent
1748691db1
commit
74e6fa5a94
|
@ -30,6 +30,7 @@
|
||||||
-define(NO_DEFAULT_VALUE, 'NO_DEFAULT_VALUE').
|
-define(NO_DEFAULT_VALUE, 'NO_DEFAULT_VALUE').
|
||||||
-define(DEPENDENCY_EXISTS, 'DEPENDENCY_EXISTS').
|
-define(DEPENDENCY_EXISTS, 'DEPENDENCY_EXISTS').
|
||||||
-define(MESSAGE_ID_SCHEMA_ERROR, 'MESSAGE_ID_SCHEMA_ERROR').
|
-define(MESSAGE_ID_SCHEMA_ERROR, 'MESSAGE_ID_SCHEMA_ERROR').
|
||||||
|
-define(INVALID_ID, 'INVALID_ID').
|
||||||
|
|
||||||
%% Resource Not Found
|
%% Resource Not Found
|
||||||
-define(NOT_FOUND, 'NOT_FOUND').
|
-define(NOT_FOUND, 'NOT_FOUND').
|
||||||
|
@ -63,6 +64,7 @@
|
||||||
, {'NO_DEFAULT_VALUE', <<"Request parameters do not use default values">>}
|
, {'NO_DEFAULT_VALUE', <<"Request parameters do not use default values">>}
|
||||||
, {'DEPENDENCY_EXISTS', <<"Resource is dependent by another resource">>}
|
, {'DEPENDENCY_EXISTS', <<"Resource is dependent by another resource">>}
|
||||||
, {'MESSAGE_ID_SCHEMA_ERROR', <<"Message ID parsing error">>}
|
, {'MESSAGE_ID_SCHEMA_ERROR', <<"Message ID parsing error">>}
|
||||||
|
, {'INVALID_ID', <<"Bad ID schema">>}
|
||||||
, {'MESSAGE_ID_NOT_FOUND', <<"Message ID does not exist">>}
|
, {'MESSAGE_ID_NOT_FOUND', <<"Message ID does not exist">>}
|
||||||
, {'NOT_FOUND', <<"Resource was not found or does not exist">>}
|
, {'NOT_FOUND', <<"Resource was not found or does not exist">>}
|
||||||
, {'CLIENTID_NOT_FOUND', <<"Client ID was not found or does not exist">>}
|
, {'CLIENTID_NOT_FOUND', <<"Client ID was not found or does not exist">>}
|
||||||
|
|
|
@ -267,7 +267,7 @@ schema("/bridges/:id") ->
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => get_response_body_schema(),
|
200 => get_response_body_schema(),
|
||||||
404 => error_schema('NOT_FOUND', "Bridge not found"),
|
404 => error_schema('NOT_FOUND', "Bridge not found"),
|
||||||
400 => error_schema('BAD_REQUEST', "Update bridge failed")
|
400 => error_schema(['BAD_REQUEST', 'INVALID_ID'], "Update bridge failed")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
delete => #{
|
delete => #{
|
||||||
|
@ -276,7 +276,8 @@ schema("/bridges/:id") ->
|
||||||
description => <<"Delete a bridge by Id">>,
|
description => <<"Delete a bridge by Id">>,
|
||||||
parameters => [param_path_id()],
|
parameters => [param_path_id()],
|
||||||
responses => #{
|
responses => #{
|
||||||
204 => <<"Bridge deleted">>
|
204 => <<"Bridge deleted">>,
|
||||||
|
400 => error_schema(['INVALID_ID'], "Update bridge failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -294,8 +295,8 @@ schema("/bridges/:id/operation/:operation") ->
|
||||||
param_path_operation_cluster()
|
param_path_operation_cluster()
|
||||||
],
|
],
|
||||||
responses => #{
|
responses => #{
|
||||||
500 => error_schema('INTERNAL_ERROR', "Operation Failed"),
|
200 => <<"Operation success">>,
|
||||||
200 => <<"Operation success">>
|
400 => error_schema('INVALID_ID', "Bad bridge ID")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -314,8 +315,8 @@ schema("/nodes/:node/bridges/:id/operation/:operation") ->
|
||||||
param_path_operation_on_node()
|
param_path_operation_on_node()
|
||||||
],
|
],
|
||||||
responses => #{
|
responses => #{
|
||||||
500 => error_schema('INTERNAL_ERROR', "Operation Failed"),
|
200 => <<"Operation success">>,
|
||||||
200 => <<"Operation success">>
|
400 => error_schema('INVALID_ID', "Bad bridge ID")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.
|
}.
|
||||||
|
|
|
@ -171,7 +171,8 @@ schema("/connectors/:id") ->
|
||||||
parameters => param_path_id(),
|
parameters => param_path_id(),
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => get_response_body_schema(),
|
200 => get_response_body_schema(),
|
||||||
404 => error_schema(['NOT_FOUND'], "Connector not found")
|
404 => error_schema(['NOT_FOUND'], "Connector not found"),
|
||||||
|
400 => error_schema(['INVALID_ID'], "Bad connector ID")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
put => #{
|
put => #{
|
||||||
|
@ -182,7 +183,8 @@ schema("/connectors/:id") ->
|
||||||
'requestBody' => put_request_body_schema(),
|
'requestBody' => put_request_body_schema(),
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => get_response_body_schema(),
|
200 => get_response_body_schema(),
|
||||||
404 => error_schema(['NOT_FOUND'], "Connector not found")
|
404 => error_schema(['NOT_FOUND'], "Connector not found"),
|
||||||
|
400 => error_schema(['INVALID_ID'], "Bad connector ID")
|
||||||
}},
|
}},
|
||||||
delete => #{
|
delete => #{
|
||||||
tags => [<<"connectors">>],
|
tags => [<<"connectors">>],
|
||||||
|
@ -192,7 +194,8 @@ schema("/connectors/:id") ->
|
||||||
responses => #{
|
responses => #{
|
||||||
204 => <<"Delete connector successfully">>,
|
204 => <<"Delete connector successfully">>,
|
||||||
403 => error_schema(['DEPENDENCY_EXISTS'], "Cannot remove dependent connector"),
|
403 => error_schema(['DEPENDENCY_EXISTS'], "Cannot remove dependent connector"),
|
||||||
404 => error_schema(['NOT_FOUND'], "Delete failed, not found")
|
404 => error_schema(['NOT_FOUND'], "Delete failed, not found"),
|
||||||
|
400 => error_schema(['INVALID_ID'], "Bad connector ID")
|
||||||
}}
|
}}
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|
|
@ -92,11 +92,12 @@ stop_listeners() ->
|
||||||
%% internal
|
%% internal
|
||||||
|
|
||||||
apps() ->
|
apps() ->
|
||||||
[App || {App, _, _} <- application:loaded_applications(),
|
[emqx_exhook].
|
||||||
case re:run(atom_to_list(App), "^emqx") of
|
% [App || {App, _, _} <- application:loaded_applications(),
|
||||||
{match,[{0,4}]} -> true;
|
% case re:run(atom_to_list(App), "^emqx") of
|
||||||
_ -> false
|
% {match,[{0,4}]} -> true;
|
||||||
end].
|
% _ -> false
|
||||||
|
% end].
|
||||||
|
|
||||||
listeners() ->
|
listeners() ->
|
||||||
[begin
|
[begin
|
||||||
|
|
|
@ -241,7 +241,6 @@ move(post, #{bindings := #{name := Name}, body := #{<<"position">> := RawPositio
|
||||||
{ok, ok} ->
|
{ok, ok} ->
|
||||||
{204};
|
{204};
|
||||||
{ok, not_found} ->
|
{ok, not_found} ->
|
||||||
%% TODO: unify status code
|
|
||||||
{400, #{code => <<"BAD_REQUEST">>,
|
{400, #{code => <<"BAD_REQUEST">>,
|
||||||
message => <<"Server not found">>
|
message => <<"Server not found">>
|
||||||
}};
|
}};
|
||||||
|
|
Loading…
Reference in New Issue