diff --git a/service/lib/agama/http/clients/base.rb b/service/lib/agama/http/clients/base.rb index 84804671fa..4a4940231a 100644 --- a/service/lib/agama/http/clients/base.rb +++ b/service/lib/agama/http/clients/base.rb @@ -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 diff --git a/service/lib/agama/http/clients/network.rb b/service/lib/agama/http/clients/network.rb index ad98ab1d0d..a0c24b6a0d 100644 --- a/service/lib/agama/http/clients/network.rb +++ b/service/lib/agama/http/clients/network.rb @@ -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