1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
defmodule ExOvh.Utils do
@moduledoc false
alias ExOvh.Auth.Ovh.Cache, as: OvhCache
alias ExOvh.Auth.Openstack.Swift.Cache, as: SwiftCache
alias ExOvh.Ovh.Defaults
@doc """
For naming an ets table to incorporate the name of the client.
The client name is required so that when a client makes a request, the correct ets table
is looked up if there are multiple clients in use.
"""
defmacro ets_tablename(client) do
# caller = __CALLER__.module
quote do
"Ets."
<>
(
unquote(client) |> Atom.to_string()
)
|> String.to_atom()
end
end
@doc """
Changes the timeout option for a http_query.
"""
@spec change_http_query_timeout(Openstex.HttpQuery.t, integer) :: Openstex.HttpQuery.t
def change_http_query_timeout(%Openstex.HttpQuery{options: options} = http_query, new_timeout) do
new_options = Map.merge(options, Map.put(options, :timeout, new_timeout))
Map.put(http_query, :options, new_options)
end
@doc """
Returns a string with the formatted date
"""
@spec formatted_date() :: String.t
def formatted_date() do
{year, month, date} = :erlang.date()
Integer.to_string(date) <> "." <>
Integer.to_string(month) <> "." <>
Integer.to_string(year)
end
end