Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Update swagger endpoints and models.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali7862 committed Oct 25, 2019
1 parent 4d06a4c commit a6da1c3
Show file tree
Hide file tree
Showing 14 changed files with 368 additions and 111 deletions.
174 changes: 119 additions & 55 deletions assets/public/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"description": ""
}
],
"operationId": "EdgeCommanderWeb.SitesController.get_all_sites",
"operationId": "EdgeCommanderWeb.SitesController.get_all_sites_by_users",
"description": "Returns sites list"
}
},
Expand All @@ -109,7 +109,7 @@
"required": true,
"name": "sim_number",
"in": "path",
"description": "Sim number in given format (08xxxxxxxx)"
"description": "Sim number in given format (+353xxxxxxxx)"
},
{
"type": "string",
Expand Down Expand Up @@ -147,7 +147,7 @@
"required": true,
"name": "sim_number",
"in": "path",
"description": "Sim number in given format (08xxxxxxxx)"
"description": "Sim number in given format (+353xxxxxxxx)"
},
{
"type": "string",
Expand Down Expand Up @@ -190,7 +190,7 @@
"required": true,
"name": "sim_number",
"in": "path",
"description": "Sim number in given format (08xxxxxxxx)"
"description": "Sim number in given format (+353xxxxxxxx)"
},
{
"type": "string",
Expand Down Expand Up @@ -228,7 +228,7 @@
"required": true,
"name": "sim_number",
"in": "path",
"description": "Sim number in given format (08xxxxxxxx)"
"description": "Sim number in given format (+353xxxxxxxx)"
},
{
"type": "string",
Expand Down Expand Up @@ -276,7 +276,7 @@
"description": ""
}
],
"operationId": "EdgeCommanderWeb.SimsController.get_sim_logs",
"operationId": "EdgeCommanderWeb.SimsController.get_all_sims_by_users",
"description": ""
}
},
Expand Down Expand Up @@ -345,7 +345,7 @@
"description": ""
}
],
"operationId": "EdgeCommanderWeb.CommandsController.get_all_rules",
"operationId": "EdgeCommanderWeb.CommandsController.get_all_rules_by_users",
"description": "Returns rules list"
}
},
Expand Down Expand Up @@ -564,7 +564,7 @@
"description": ""
}
],
"operationId": "EdgeCommanderWeb.RoutersController.get_all_routers",
"operationId": "EdgeCommanderWeb.RoutersController.get_all_routers_by_users",
"description": "Returns routers list"
}
},
Expand Down Expand Up @@ -825,7 +825,7 @@
"description": ""
}
],
"operationId": "EdgeCommanderWeb.NvrsController.get_all_nvrs",
"operationId": "EdgeCommanderWeb.NvrsController.get_all_nvrs_by_users",
"description": "Returns nvrs list"
}
}
Expand All @@ -834,16 +834,17 @@
"version": "1.0",
"title": "Edge Commander"
},
"host": "app.edgecommander.com",
"host": "localhost:4000",
"definitions": {
"Site": {
"type": "object",
"title": "Site",
"required": [
"lat",
"lng",
"location",
"created_at",
"name",
"nvr_id",
"nvr_name",
"router_id",
"router_name",
"sim_number"
],
Expand All @@ -856,61 +857,95 @@
"type": "string",
"description": ""
},
"router_id": {
"type": "integer",
"description": ""
},
"nvr_name": {
"type": "string",
"description": ""
},
"notes": {
"type": "string",
"nvr_id": {
"type": "integer",
"description": ""
},
"location": {
"notes": {
"type": "string",
"description": ""
},
"lng": {
"name": {
"type": "string",
"description": "Longitude of the location"
"description": ""
},
"lat": {
"type": "string",
"description": "Latitude of the location"
"location": {
"type": "object",
"properties": {
"map_area": {
"type": "string",
"description": ""
},
"lng": {
"type": "float",
"description": ""
},
"lat": {
"type": "float",
"description": ""
}
}
},
"id": {
"type": "integer",
"description": ""
},
"created_at": {
"type": "string",
"description": ""
}
},
"description": "A site of the application"
"description": "A site module of the application"
},
"Rule": {
"type": "object",
"title": "Rule",
"required": [
"active",
"category",
"variable",
"value",
"rule_name",
"recipients",
"rule_name"
"created_at",
"category",
"active"
],
"properties": {
"variable": {
"type": "string",
"example": "greater_than",
"description": ""
},
"value": {
"type": "integer",
"description": ""
},
"rule_name": {
"type": "string",
"description": ""
},
"recipients": {
"type": "string",
"example": "[email protected], [email protected]",
"type": "array",
"example": "['[email protected]', '[email protected]']",
"description": ""
},
"id": {
"type": "integer",
"description": ""
},
"created_at": {
"type": "string",
"description": ""
},
"category": {
"type": "string",
"enum": [
"usage_command"
],
"description": ""
},
"active": {
Expand All @@ -919,7 +954,7 @@
"default": false
}
},
"description": "A rule of the application"
"description": "A rule module of the application"
},
"Router": {
"type": "object",
Expand Down Expand Up @@ -947,12 +982,20 @@
"default": false
},
"ip": {
"type": "integer",
"type": "string",
"description": ""
},
"id": {
"type": "integer",
"description": ""
},
"extra": {
"type": "json",
"description": ""
},
"created_at": {
"type": "string",
"description": ""
}
},
"description": "A router of the application"
Expand All @@ -961,15 +1004,15 @@
"type": "object",
"title": "Nvr",
"required": [
"is_monitoring",
"sdk_port",
"rtsp_port",
"vh_port",
"port",
"ip",
"password",
"username",
"name"
"name",
"is_monitoring",
"ip"
],
"properties": {
"vh_port": {
Expand All @@ -980,10 +1023,6 @@
"type": "string",
"description": ""
},
"serial_number": {
"type": "string",
"description": ""
},
"sdk_port": {
"type": "integer",
"description": ""
Expand All @@ -992,10 +1031,6 @@
"type": "integer",
"description": ""
},
"reason": {
"type": "string",
"description": "Offline reason"
},
"port": {
"type": "integer",
"description": ""
Expand All @@ -1016,10 +1051,6 @@
"type": "string",
"description": ""
},
"mac_address": {
"type": "string",
"description": ""
},
"is_monitoring": {
"type": "boolean",
"description": "",
Expand All @@ -1037,15 +1068,48 @@
"type": "string",
"description": ""
},
"firmware_released_date": {
"type": "string",
"description": ""
},
"encoder_version": {
"type": "string",
"description": ""
"extra": {
"type": "object",
"properties": {
"serial_number": {
"type": "string",
"description": ""
},
"reason": {
"type": "string",
"description": ""
},
"mac_address": {
"type": "string",
"description": ""
},
"firmware_released_date": {
"type": "string",
"description": ""
},
"encoder_version": {
"type": "string",
"description": ""
},
"encoder_released_date": {
"type": "string",
"description": ""
},
"device_type": {
"type": "string",
"description": ""
},
"device_name": {
"type": "string",
"description": ""
},
"device_id": {
"type": "string",
"description": ""
}
}
},
"encoder_released_date": {
"created_at": {
"type": "string",
"description": ""
}
Expand Down
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# is restricted to this project.
use Mix.Config

config :phoenix, :json_library, Jason

# General application configuration
config :edge_commander,
ecto_repos: [EdgeCommander.Repo]
Expand Down
6 changes: 6 additions & 0 deletions lib/edge_commander/commands/commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ defmodule EdgeCommander.Commands do

def get_rule!(id), do: Repo.get!(Rule, id)

def get_rules_by_user(user_id) do
Rule
|> where(user_id: ^user_id)
|> Repo.all
end

def create_rule(attrs \\ %{}) do
%Rule{}
|> Rule.changeset(attrs)
Expand Down
Loading

0 comments on commit a6da1c3

Please sign in to comment.