Packages
arke_server
0.1.28
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.4.0-bulk.0
0.3.18
0.3.17
0.3.16
0.3.15
0.3.14
0.3.13
0.3.12
0.3.11
0.3.10
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.1.42
0.1.41
0.1.40
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.32
0.1.31
0.1.30
0.1.29
0.1.28
0.1.27
0.1.26
0.1.25
0.1.24
0.1.23
0.1.22
0.1.21
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Arke server
Current section
Files
Jump to
Current section
Files
lib/arke_server/router.ex
# Copyright 2023 Arkemis S.r.l.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
defmodule ArkeServer.Router do
@moduledoc """
Module where all the routes are defined. Too see run in the CLI: `mix phx.routes ArkeServer.Router`
""" && false
use ArkeServer, :router
pipeline :api do
plug(:accepts, ["json", "multipart"])
plug(ArkeServer.Plugs.NotAuthPipeline)
end
pipeline :auth_api do
plug(:accepts, ["json", "multipart"])
plug(ArkeServer.Plugs.AuthPipeline)
end
pipeline :project do
plug(ArkeServer.Plugs.GetProject)
plug(ArkeServer.Plugs.BuildFilters)
end
pipeline :get_unit do
plug(ArkeServer.Plugs.GetUnit)
end
pipeline :openapi do
plug(OpenApiSpex.Plug.PutApiSpec, module: ArkeServer.ApiSpec)
end
# ------ OPENAPI -------
scope "/lib/doc" do
get("/swaggerui", OpenApiSpex.Plug.SwaggerUI, path: "/lib/doc/openapi")
pipe_through([:openapi])
get("/openapi", OpenApiSpex.Plug.RenderSpec, [])
end
scope "/lib", ArkeServer do
# -------- AUTH --------
pipe_through([:openapi])
scope "/auth" do
pipe_through([:project])
post("/signin", AuthController, :signin)
post("/:arke_id/signup", AuthController, :signup)
post("/recover_password", AuthController, :recover_password)
post("/reset_password", AuthController, :reset_password)
post("/reset_password/:token", AuthController, :reset_password)
pipe_through(:api)
post("/refresh", AuthController, :refresh)
post("/verify", AuthController, :verify)
end
# ↑ Not auth endpoint (no access token)
pipe_through([:auth_api])
# ↓ Auth endpoint (no access token)
post("/auth/change_password", AuthController, :change_password)
# -------- PROJECT --------
scope "/arke_project" do
get("/unit", ProjectController, :get_all_unit)
get("/unit/:unit_id", ProjectController, :get_unit)
put("/unit/:unit_id", ProjectController, :update)
post("/unit", ProjectController, :create)
delete("/unit/:unit_id", ProjectController, :delete)
end
# ↑ Do not need arke-project-key
pipe_through([:project])
# ↓ Must have arke-project-key
# GROUP
scope "/group/:group_id" do
get("/arke", GroupController, :get_arke)
get("/struct", GroupController, :struct)
get("/unit", GroupController, :get_unit)
get("/unit/:unit_id", GroupController, :unit_detail)
end
pipe_through([:get_unit])
# -------- PUT --------
# UNIT
put("/:arke_id/unit/:unit_id", UnitController, :update)
put("/:arke_id/parameter/:arke_parameter_id", TopologyController, :update_parameter)
# -------- POST --------
post("/:arke_id/unit", ArkeController, :create)
post("/:arke_id/parameter/:arke_parameter_id", TopologyController, :add_parameter)
post(
"/:arke_id/unit/:arke_unit_id/link/:link_id/:arke_id_two/unit/:unit_id_two",
TopologyController,
:create_node
)
# -------- DELETE --------
delete(
"/:arke_id/unit/:arke_unit_id/link/:link_id/:arke_id_two/unit/:unit_id_two",
TopologyController,
:delete_node
)
delete("/:arke_id/unit/:unit_id", ArkeController, :delete)
# -------- CALL FUNCTION --------
get("/:arke_id/function/:function_name", ArkeController, :call_arke_function)
get("/:arke_id/unit/:unit_id/function/:function_name", ArkeController, :call_unit_function)
post("/:arke_id/function/:function_name", ArkeController, :call_arke_function)
post("/:arke_id/unit/:unit_id/function/:function_name", ArkeController, :call_unit_function)
# -------- PARAMETER --------
get("/parameter/:parameter_id", ParameterController, :get_parameter_value)
post("/parameter/:parameter_id", ParameterController, :add_link_parameter_value)
put("/parameter/:parameter_id", ParameterController, :update_parameter_value)
delete("/parameter/:parameter_id/:unit_id", ParameterController, :remove_link_parameter_value)
# -------- GET --------
# ARKE
scope "/:arke_id" do
get("/struct", StructController, :get_arke_struct)
get("/group", ArkeController, :get_groups)
# UNIT
scope "/unit" do
get("/", ArkeController, :get_all_unit)
get("/:unit_id", ArkeController, :get_unit)
# TOPOLOGY
scope "/:arke_unit_id" do
get("/link/:direction", TopologyController, :get_node)
get("/struct", StructController, :get_unit_struct)
end
end
end
# GLOBAL SEARCH
get("/unit", UnitController, :search)
end
end