Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service/lib/agama/http/clients/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Clients
# Base for HTTP clients.
class Base
def initialize(logger)
@base_url = "http://localhost/api/"
@base_url = "http://localhost/api/v2/"
@logger = logger
end

Expand Down
19 changes: 15 additions & 4 deletions service/lib/agama/http/clients/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,31 @@ module HTTP
module Clients
# HTTP client to interact with the network API.
class Network < Base
def proposal
JSON.parse(get("proposal"))
end

def connections
JSON.parse(get("network/connections"))
proposal.fetch("network", {}).fetch("connections", [])
end

def devices
JSON.parse(get("network/devices"))
proposal.fetch("network", {}).fetch("devices", [])
end

def persist_connections
post("network/connections/persist", { value: true })
conns = connections.map do |c|
c["persistent"] = true
c
end
# FIXME: This will create a configuration although it was not explicitly given,
# so maybe we should consider to add an action to persist the connections keeping
# also the actual status.
patch("config", { "update" => { "network" => { "connections" => conns } } })
end

def state
JSON.parse(get("network/state"))
proposal.fetch("network", {}).fetch("state", {})
end
end
end
Expand Down
Loading