Skip to content

Commit

Permalink
Merge pull request #696 from davidebriani/fix-support-for-available-d…
Browse files Browse the repository at this point in the history
…eployments-trigger
  • Loading branch information
noaccOS authored Nov 13, 2024
2 parents fee3031 + 71cf516 commit 51efbc3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,16 @@ defmodule Edgehog.Triggers.Handler.ManualActions.HandleTrigger do
end

defp handle_event(%IncomingData{interface: @available_deployments} = event, tenant, _realm_id, _device_id, _timestamp) do
"/" <> deployment_id = event.path
status = event.value["status"]
case String.split(event.path, "/") do
["", deployment_id, "status"] ->
status = event.value

with {:ok, deployment} <- Containers.fetch_deployment(deployment_id, tenant: tenant) do
Containers.deployment_set_status(deployment, status, tenant: tenant)
with {:ok, deployment} <- Containers.fetch_deployment(deployment_id, tenant: tenant) do
Containers.deployment_set_status(deployment, status, tenant: tenant)
end

_ ->
{:error, :unsupported_event_path}
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "edgehog-available-deployments",
"action": {
"http_url": "<%= @trigger_url %>",
"http_method": "post",
"http_static_headers": {},
"ignore_ssl_errors": false
},
"simple_triggers": [
{
"type": "data_trigger",
"interface_name": "io.edgehog.devicemanager.apps.AvailableDeployments",
"interface_major": 0,
"on": "incoming_data",
"match_path": "/*",
"value_match_operator": "*"
}
]
}

0 comments on commit 51efbc3

Please sign in to comment.