Sprites.Policy (Sprites v0.2.0)
View SourceNetwork policy management for sprites.
Summary
Functions
Network policy containing a list of rules.
Creates a network policy from a map.
Gets the current network policy for a sprite.
Gets the current network policy for a sprite by name.
Converts a network policy to a map for JSON encoding.
Updates the network policy for a sprite.
Updates the network policy for a sprite by name.
Types
@type t() :: %Sprites.Policy{rules: [Sprites.Policy.Rule.t()]}
Functions
Network policy containing a list of rules.
Fields
:rules- List ofSprites.Policy.Rulestructs
Creates a network policy from a map.
@spec get(Sprites.Sprite.t()) :: {:ok, t()} | {:error, term()}
Gets the current network policy for a sprite.
Examples
{:ok, policy} = Sprites.Policy.get(sprite)
@spec get_by_name(Sprites.Client.t(), String.t()) :: {:ok, t()} | {:error, term()}
Gets the current network policy for a sprite by name.
Converts a network policy to a map for JSON encoding.
@spec update(Sprites.Sprite.t(), t()) :: :ok | {:error, term()}
Updates the network policy for a sprite.
Examples
policy = %Sprites.Policy{
rules: [
%Sprites.Policy.Rule{domain: "example.com", action: "allow"},
%Sprites.Policy.Rule{domain: "blocked.com", action: "deny"}
]
}
:ok = Sprites.Policy.update(sprite, policy)
@spec update_by_name(Sprites.Client.t(), String.t(), t()) :: :ok | {:error, term()}
Updates the network policy for a sprite by name.