summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavi Oliveira <davi.oliveira@locaweb.com>2021-02-11 11:29:00 -0300
committerDavi Oliveira <davi.oliveira@locaweb.com>2021-02-11 11:29:00 -0300
commita5a8c093cc5db8ddd6e23a9edf0171546ff577a2 (patch)
treec47a40170b8d85643242db42a0b4ee0be259d4a2
parentAdd put methot in record_manager (diff)
Format files
-rw-r--r--lib/powerdnsex.ex11
-rw-r--r--lib/powerdnsex/gen_server/server.ex2
-rw-r--r--lib/powerdnsex/http_client.ex3
-rw-r--r--lib/powerdnsex/managers/zones_manager.ex10
-rw-r--r--test/lib/powerdnsex/config_test.exs5
-rw-r--r--test/support/fake_config.exs1
6 files changed, 20 insertions, 12 deletions
diff --git a/lib/powerdnsex.ex b/lib/powerdnsex.ex
index 8f13ee6..cc6db9e 100644
--- a/lib/powerdnsex.ex
+++ b/lib/powerdnsex.ex
@@ -48,6 +48,10 @@ defmodule PowerDNSex do
call({:show_zone, zone, server_name})
end
+ @spec get_zone(String.t(), String.t()) :: :ok | {:error, String.t()}
+ @doc """
+ Show / Retrive info of the specific Zone without RRSets
+ """
def get_zone(zone, server_name \\ @default_server) when is_binary(zone) do
call({:get_zone, zone, server_name})
end
@@ -87,6 +91,11 @@ defmodule PowerDNSex do
def update_record(%Zone{} = zone, %{} = rrset_attrs) do
call({:update_record, zone, rrset_attrs})
end
+
+ @spec put_record(Zone.t(), struct) :: :ok | {:error, String.t()}
+ @doc """
+ Update Record of the given Zone
+ """
def put_record(%Zone{} = zone, %{} = rrset_attrs) do
call({:put_record, zone, rrset_attrs})
end
@@ -114,7 +123,7 @@ defmodule PowerDNSex do
defp call(params) do
:poolboy.transaction(@name, fn pid ->
- GenServer.call(pid, params, Config.powerdns_timeout)
+ GenServer.call(pid, params, Config.powerdns_timeout())
end)
end
end
diff --git a/lib/powerdnsex/gen_server/server.ex b/lib/powerdnsex/gen_server/server.ex
index b252143..149351b 100644
--- a/lib/powerdnsex/gen_server/server.ex
+++ b/lib/powerdnsex/gen_server/server.ex
@@ -47,7 +47,7 @@ defmodule PowerDNSex.Server do
{:reply, RecordsManager.update(zone, attrs), state}
end
- def handle_call({:update_record, zone, rrset_attrs}, _from, state) do
+ def handle_call({:put_record, zone, rrset_attrs}, _from, state) do
attrs = Converter.keys_to_atom(rrset_attrs)
{:reply, RecordsManager.put(zone, attrs), state}
end
diff --git a/lib/powerdnsex/http_client.ex b/lib/powerdnsex/http_client.ex
index 3431795..98e299d 100644
--- a/lib/powerdnsex/http_client.ex
+++ b/lib/powerdnsex/http_client.ex
@@ -15,8 +15,7 @@ defmodule PowerDNSex.HttpClient do
end
def process_request_options(options) do
- custom_options = [ssl: [{:versions, [:'tlsv1.1']}], recv_timeout: Config.powerdns_timeout()]
+ custom_options = [ssl: [{:versions, [:"tlsv1.1"]}], recv_timeout: Config.powerdns_timeout()]
Keyword.merge(options, custom_options)
end
-
end
diff --git a/lib/powerdnsex/managers/zones_manager.ex b/lib/powerdnsex/managers/zones_manager.ex
index 7a8f1df..b1567ef 100644
--- a/lib/powerdnsex/managers/zones_manager.ex
+++ b/lib/powerdnsex/managers/zones_manager.ex
@@ -21,11 +21,11 @@ defmodule PowerDNSex.Managers.ZonesManager do
end
def get(zone_name, server_name \\ @default_server)
- when is_bitstring(zone_name) do
- server_name
- |> zone_path_light(zone_name)
- |> HttpClient.get!()
- |> process_request_response
+ when is_bitstring(zone_name) do
+ server_name
+ |> zone_path_light(zone_name)
+ |> HttpClient.get!()
+ |> process_request_response
end
def delete(zone_name, server_name \\ @default_server)
diff --git a/test/lib/powerdnsex/config_test.exs b/test/lib/powerdnsex/config_test.exs
index c8649ae..394d97c 100644
--- a/test/lib/powerdnsex/config_test.exs
+++ b/test/lib/powerdnsex/config_test.exs
@@ -67,9 +67,10 @@ defmodule PowerDNSex.ConfigTest do
@tag :configs
test "uses default timeout" do
existing = Application.get_env(:powerdnsex, :timeout)
- on_exit fn ->
+
+ on_exit(fn ->
Application.put_env(:powerdnsex, :timeout, existing)
- end
+ end)
Application.delete_env(:powerdnsex, :timeout)
diff --git a/test/support/fake_config.exs b/test/support/fake_config.exs
index e05db22..80912e1 100644
--- a/test/support/fake_config.exs
+++ b/test/support/fake_config.exs
@@ -7,7 +7,6 @@ defmodule PowerDNSex.FakeConfig do
def set_token, do: Application.put_env(:powerdnsex, :token, @app_config_token)
def set_timeout, do: Application.put_env(:powerdnsex, :timeout, @app_config_timeout)
-
def token, do: @app_config_token
def url, do: @app_config_url
def timeout, do: @app_config_timeout