lib/auth0/management/log_streams/get.ex

defmodule Auth0.Management.LogStreams.Get do
  @moduledoc false

  alias Auth0.Config
  alias Auth0.Common.Management.Http

  @type id :: String.t()
  @type config :: Config.t()
  @type entity :: map()
  @type response :: {:ok, entity} | {:error, integer, term} | {:error, term}

  @endpoint "/api/v2/log-streams/{id}"

  @doc """
  Retrieve a log stream configuration and status.

  ## see
  https://auth0.com/docs/api/management/v2#!/Log_Streams/get_log_streams_by_id

  """
  @spec execute(id, config) :: response
  def execute(id, %Config{} = config) do
    @endpoint
    |> String.replace("{id}", id)
    |> Http.get(config)
    |> case do
      {:ok, 200, body} -> {:ok, body |> Jason.decode!()}
      error -> error
    end
  end
end