Explorar o código

feat: remove the deprecated '/gateway/*' HTTP APIs

JianBo He %!s(int64=2) %!d(string=hai) anos
pai
achega
ec0049af7b

+ 3 - 5
apps/emqx_gateway/src/emqx_gateway_api.erl

@@ -63,11 +63,11 @@ api_spec() ->
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
 
 
 paths() ->
 paths() ->
-    emqx_gateway_utils:make_deprecated_paths([
+    [
         "/gateways",
         "/gateways",
         "/gateways/:name",
         "/gateways/:name",
         "/gateways/:name/enable/:enable"
         "/gateways/:name/enable/:enable"
-    ]).
+    ].
 
 
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% http handlers
 %% http handlers
@@ -240,9 +240,7 @@ schema("/gateways/:name/enable/:enable") ->
                         )
                         )
                     }
                     }
             }
             }
-    };
-schema(Path) ->
-    emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
+    }.
 
 
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% params defines
 %% params defines

+ 4 - 5
apps/emqx_gateway/src/emqx_gateway_api_authn.erl

@@ -61,11 +61,11 @@ api_spec() ->
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
 
 
 paths() ->
 paths() ->
-    emqx_gateway_utils:make_deprecated_paths([
+    [
         "/gateways/:name/authentication",
         "/gateways/:name/authentication",
         "/gateways/:name/authentication/users",
         "/gateways/:name/authentication/users",
         "/gateways/:name/authentication/users/:uid"
         "/gateways/:name/authentication/users/:uid"
-    ]).
+    ].
 
 
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% http handlers
 %% http handlers
@@ -318,9 +318,8 @@ schema("/gateways/:name/authentication/users/:uid") ->
                 responses =>
                 responses =>
                     ?STANDARD_RESP(#{204 => <<"User Deleted">>})
                     ?STANDARD_RESP(#{204 => <<"User Deleted">>})
             }
             }
-    };
-schema(Path) ->
-    emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
+    }.
+
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% params defines
 %% params defines
 
 

+ 3 - 5
apps/emqx_gateway/src/emqx_gateway_api_authn_user_import.erl

@@ -55,10 +55,10 @@ api_spec() ->
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => false}).
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => false}).
 
 
 paths() ->
 paths() ->
-    emqx_gateway_utils:make_deprecated_paths([
+    [
         "/gateways/:name/authentication/import_users",
         "/gateways/:name/authentication/import_users",
         "/gateways/:name/listeners/:id/authentication/import_users"
         "/gateways/:name/listeners/:id/authentication/import_users"
-    ]).
+    ].
 
 
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% http handlers
 %% http handlers
@@ -147,9 +147,7 @@ schema("/gateways/:name/listeners/:id/authentication/import_users") ->
                 responses =>
                 responses =>
                     ?STANDARD_RESP(#{204 => <<"Imported">>})
                     ?STANDARD_RESP(#{204 => <<"Imported">>})
             }
             }
-    };
-schema(Path) ->
-    emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
+    }.
 
 
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% params defines
 %% params defines

+ 3 - 5
apps/emqx_gateway/src/emqx_gateway_api_clients.erl

@@ -70,12 +70,12 @@ api_spec() ->
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
 
 
 paths() ->
 paths() ->
-    emqx_gateway_utils:make_deprecated_paths([
+    [
         "/gateways/:name/clients",
         "/gateways/:name/clients",
         "/gateways/:name/clients/:clientid",
         "/gateways/:name/clients/:clientid",
         "/gateways/:name/clients/:clientid/subscriptions",
         "/gateways/:name/clients/:clientid/subscriptions",
         "/gateways/:name/clients/:clientid/subscriptions/:topic"
         "/gateways/:name/clients/:clientid/subscriptions/:topic"
-    ]).
+    ].
 
 
 -define(CLIENT_QSCHEMA, [
 -define(CLIENT_QSCHEMA, [
     {<<"node">>, atom},
     {<<"node">>, atom},
@@ -541,9 +541,7 @@ schema("/gateways/:name/clients/:clientid/subscriptions/:topic") ->
                 responses =>
                 responses =>
                     ?STANDARD_RESP(#{204 => <<"Unsubscribed">>})
                     ?STANDARD_RESP(#{204 => <<"Unsubscribed">>})
             }
             }
-    };
-schema(Path) ->
-    emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
+    }.
 
 
 params_client_query() ->
 params_client_query() ->
     params_gateway_name_in_path() ++
     params_gateway_name_in_path() ++

+ 3 - 5
apps/emqx_gateway/src/emqx_gateway_api_listeners.erl

@@ -70,13 +70,13 @@ api_spec() ->
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true}).
 
 
 paths() ->
 paths() ->
-    emqx_gateway_utils:make_deprecated_paths([
+    [
         "/gateways/:name/listeners",
         "/gateways/:name/listeners",
         "/gateways/:name/listeners/:id",
         "/gateways/:name/listeners/:id",
         "/gateways/:name/listeners/:id/authentication",
         "/gateways/:name/listeners/:id/authentication",
         "/gateways/:name/listeners/:id/authentication/users",
         "/gateways/:name/listeners/:id/authentication/users",
         "/gateways/:name/listeners/:id/authentication/users/:uid"
         "/gateways/:name/listeners/:id/authentication/users/:uid"
-    ]).
+    ].
 
 
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% http handlers
 %% http handlers
@@ -590,9 +590,7 @@ schema("/gateways/:name/listeners/:id/authentication/users/:uid") ->
                 responses =>
                 responses =>
                     ?STANDARD_RESP(#{204 => <<"Deleted">>})
                     ?STANDARD_RESP(#{204 => <<"Deleted">>})
             }
             }
-    };
-schema(Path) ->
-    emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
+    }.
 
 
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 %% params defines
 %% params defines

+ 0 - 35
apps/emqx_gateway/src/emqx_gateway_utils.erl

@@ -45,8 +45,6 @@
     is_running/2,
     is_running/2,
     global_chain/1,
     global_chain/1,
     listener_chain/3,
     listener_chain/3,
-    make_deprecated_paths/1,
-    make_compatible_schema/2,
     find_gateway_definitions/0
     find_gateway_definitions/0
 ]).
 ]).
 
 
@@ -531,39 +529,6 @@ default_subopts() ->
         is_new => true
         is_new => true
     }.
     }.
 
 
-%% Since 5.0.8, the API path of the gateway has been changed from "gateway" to "gateways"
-%% and we need to be compatible with the old path
-get_compatible_path("/gateway") ->
-    "/gateways";
-get_compatible_path("/gateway/" ++ Rest) ->
-    "/gateways/" ++ Rest.
-
-get_deprecated_path("/gateways") ->
-    "/gateway";
-get_deprecated_path("/gateways/" ++ Rest) ->
-    "/gateway/" ++ Rest.
-
-make_deprecated_paths(Paths) ->
-    Paths ++ [get_deprecated_path(Path) || Path <- Paths].
-
-make_compatible_schema(Path, SchemaFun) ->
-    OldPath = get_compatible_path(Path),
-    make_compatible_schema2(OldPath, SchemaFun).
-
-make_compatible_schema2(Path, SchemaFun) ->
-    Schema = SchemaFun(Path),
-    maps:map(
-        fun(Key, Value) ->
-            case lists:member(Key, [get, delete, put, post]) of
-                true ->
-                    Value#{deprecated => true};
-                _ ->
-                    Value
-            end
-        end,
-        Schema
-    ).
-
 -spec find_gateway_definitions() -> list(gateway_def()).
 -spec find_gateway_definitions() -> list(gateway_def()).
 find_gateway_definitions() ->
 find_gateway_definitions() ->
     lists:flatten(
     lists:flatten(

+ 2 - 4
apps/emqx_gateway_coap/src/emqx_coap_api.erl

@@ -46,7 +46,7 @@ api_spec() ->
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
     emqx_dashboard_swagger:spec(?MODULE, #{check_schema => true, translate_body => true}).
 
 
 paths() ->
 paths() ->
-    emqx_gateway_utils:make_deprecated_paths([?PREFIX ++ "/request"]).
+    [?PREFIX ++ "/request"].
 
 
 schema(?PREFIX ++ "/request") ->
 schema(?PREFIX ++ "/request") ->
     #{
     #{
@@ -65,9 +65,7 @@ schema(?PREFIX ++ "/request") ->
                 )
                 )
             }
             }
         }
         }
-    };
-schema(Path) ->
-    emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
+    }.
 
 
 request(post, #{body := Body, bindings := Bindings}) ->
 request(post, #{body := Body, bindings := Bindings}) ->
     ClientId = maps:get(clientid, Bindings, undefined),
     ClientId = maps:get(clientid, Bindings, undefined),

+ 1 - 1
apps/emqx_gateway_lwm2m/src/emqx_gateway_lwm2m.app.src

@@ -1,6 +1,6 @@
 {application, emqx_gateway_lwm2m, [
 {application, emqx_gateway_lwm2m, [
     {description, "LwM2M Gateway"},
     {description, "LwM2M Gateway"},
-    {vsn, "0.1.0"},
+    {vsn, "0.1.1"},
     {registered, []},
     {registered, []},
     {applications, [kernel, stdlib, emqx, emqx_gateway, emqx_gateway_coap]},
     {applications, [kernel, stdlib, emqx, emqx_gateway, emqx_gateway_coap]},
     {env, []},
     {env, []},

+ 3 - 5
apps/emqx_gateway_lwm2m/src/emqx_lwm2m_api.erl

@@ -40,9 +40,9 @@ api_spec() ->
     emqx_dashboard_swagger:spec(?MODULE).
     emqx_dashboard_swagger:spec(?MODULE).
 
 
 paths() ->
 paths() ->
-    emqx_gateway_utils:make_deprecated_paths([
+    [
         ?PATH("/lookup"), ?PATH("/observe"), ?PATH("/read"), ?PATH("/write")
         ?PATH("/lookup"), ?PATH("/observe"), ?PATH("/read"), ?PATH("/write")
-    ]).
+    ].
 
 
 schema(?PATH("/lookup")) ->
 schema(?PATH("/lookup")) ->
     #{
     #{
@@ -127,9 +127,7 @@ schema(?PATH("/write")) ->
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
             }
             }
         }
         }
-    };
-schema(Path) ->
-    emqx_gateway_utils:make_compatible_schema(Path, fun schema/1).
+    }.
 
 
 fields(resource) ->
 fields(resource) ->
     [
     [