diff options
-rw-r--r-- | lib/azure_ex/application.ex | 3 | ||||
-rw-r--r-- | lib/azure_ex/model/public_ip_address/create_or_update.ex | 1 | ||||
-rw-r--r-- | lib/azure_ex/request.ex | 8 | ||||
-rw-r--r-- | lib/azure_ex/token_hosting.ex | 11 |
4 files changed, 14 insertions, 9 deletions
diff --git a/lib/azure_ex/application.ex b/lib/azure_ex/application.ex index e6be1d4..3b50854 100644 --- a/lib/azure_ex/application.ex +++ b/lib/azure_ex/application.ex @@ -6,7 +6,8 @@ defmodule AzureEx.Application do def start(_tuple, _args) do opts = [strategy: :one_for_one, name: AzureEx.Supervisor] - Supervisor.start_link([{AzureEx.TokenHosting, get_client_oauth_params()}], opts) +# Supervisor.start_link([{AzureEx.TokenHosting, get_client_oauth_params()}], opts) + Supervisor.start_link([], opts) end defp get_client_oauth_params do diff --git a/lib/azure_ex/model/public_ip_address/create_or_update.ex b/lib/azure_ex/model/public_ip_address/create_or_update.ex index 959db34..e745b31 100644 --- a/lib/azure_ex/model/public_ip_address/create_or_update.ex +++ b/lib/azure_ex/model/public_ip_address/create_or_update.ex @@ -9,6 +9,7 @@ defmodule AzureEx.Model.PublicIPAddress.CreateOrUpdate do @derive Jason.Encoder field :publicIPAddressVersion, String.t() + field :dnsSettings, String.t() end typedstruct do diff --git a/lib/azure_ex/request.ex b/lib/azure_ex/request.ex index 67cd5f4..2ed51cc 100644 --- a/lib/azure_ex/request.ex +++ b/lib/azure_ex/request.ex @@ -43,14 +43,14 @@ defmodule AzureEx.Request do @spec send(method, String.t(), data) :: httpoison_result defp send(:get, endpoint, _data) do - headers = [Authorization: "Bearer #{TokenHosting.get_token()}"] + headers = [Authorization: "Bearer #{TokenHosting.get_process_token()}"] HTTPoison.get(endpoint, headers, Config.http_options()) end defp send(:post, endpoint, data) do headers = [ - Authorization: "Bearer #{TokenHosting.get_token()}", + Authorization: "Bearer #{TokenHosting.get_process_token()}", "Content-Type": @data_content_type ] @@ -61,7 +61,7 @@ defmodule AzureEx.Request do defp send(:put, endpoint, data) do headers = [ - Authorization: "Bearer #{TokenHosting.get_token()}", + Authorization: "Bearer #{TokenHosting.get_process_token()}", "Content-Type": @data_content_type ] @@ -71,7 +71,7 @@ defmodule AzureEx.Request do end defp send(:delete, endpoint, _data) do - headers = [Authorization: "Bearer #{TokenHosting.get_token()}"] + headers = [Authorization: "Bearer #{TokenHosting.get_process_token()}"] HTTPoison.delete(endpoint, headers, Config.http_options()) end diff --git a/lib/azure_ex/token_hosting.ex b/lib/azure_ex/token_hosting.ex index 6c0a4c8..04c859c 100644 --- a/lib/azure_ex/token_hosting.ex +++ b/lib/azure_ex/token_hosting.ex @@ -39,8 +39,7 @@ defmodule AzureEx.TokenHosting do } end - def start_link(opts \\ []) do - name = Keyword.get(opts, :name, __MODULE__) + def start_link(opts \\ [], start_opts \\ []) do tenant = Keyword.get(opts, :tenant) client_id = Keyword.get(opts, :client_id) client_secret = Keyword.get(opts, :client_secret) @@ -48,7 +47,7 @@ defmodule AzureEx.TokenHosting do {:ok, token} = apply_token(params) - GenServer.start_link(__MODULE__, %{params: params, token: token}, name: name) + GenServer.start_link(__MODULE__, %{params: params, token: token}, start_opts) end @scope "https://management.azure.com//.default" @@ -89,7 +88,11 @@ defmodule AzureEx.TokenHosting do {:ok, state} end - def get_token do + def get_process_token() do + GenServer.call(Process.get(__MODULE__), :get) + end + + def get_token(name) do GenServer.call(__MODULE__, :get) end |