mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-03-21 18:41:38 +00:00
Why: * In order to manage a large number of Firezone Sites, Resources, Policies, etc... a REST API is needed as clicking through the UI is too time consuming, as well as prone to error. By providing a REST API Firezone customers will be able to manage things within their Firezone accounts with code.
31 lines
606 B
Elixir
31 lines
606 B
Elixir
defmodule API.PolicyJSON do
|
|
alias API.Pagination
|
|
alias Domain.Policies
|
|
|
|
@doc """
|
|
Renders a list of Policies.
|
|
"""
|
|
def index(%{policies: policies, metadata: metadata}) do
|
|
%{
|
|
data: Enum.map(policies, &data/1),
|
|
metadata: Pagination.metadata(metadata)
|
|
}
|
|
end
|
|
|
|
@doc """
|
|
Render a single Policy
|
|
"""
|
|
def show(%{policy: policy}) do
|
|
%{data: data(policy)}
|
|
end
|
|
|
|
defp data(%Policies.Policy{} = policy) do
|
|
%{
|
|
id: policy.id,
|
|
actor_group_id: policy.actor_group_id,
|
|
resource_id: policy.resource_id,
|
|
description: policy.description
|
|
}
|
|
end
|
|
end
|