Read and write the network egress/ingress policy for a MIOSA computer.
A network policy controls which hosts and ports a computer can reach on the public internet. The default policy allows all outbound traffic.
Example
{:ok, policy} = Miosa.NetworkPolicy.get(client, computer_id)
{:ok, policy} = Miosa.NetworkPolicy.set(client, computer_id, %{
rules: [
%{direction: "egress", action: "allow", host: "api.example.com", port: 443},
%{direction: "egress", action: "deny", host: "*", port: "*"}
]
})
:ok = Miosa.NetworkPolicy.reset(client, computer_id)
Summary
Functions
Returns the current network policy for a computer.
Resets the network policy to the default (allow all outbound) for a computer.
Replaces the network policy for a computer.
Types
@type policy_params() :: %{rules: [rule_params()]}
@type rule_params() :: %{ :direction => String.t(), :action => String.t(), optional(:host) => String.t(), optional(:port) => String.t() | pos_integer() }
Functions
@spec get(Miosa.Client.t(), String.t()) :: Miosa.Client.result(Miosa.Types.NetworkPolicy.t())
Returns the current network policy for a computer.
@spec reset(Miosa.Client.t(), String.t()) :: :ok | {:error, Miosa.Error.t()}
Resets the network policy to the default (allow all outbound) for a computer.
@spec set(Miosa.Client.t(), String.t(), policy_params()) :: Miosa.Client.result(Miosa.Types.NetworkPolicy.t())
Replaces the network policy for a computer.
The supplied rules fully replace the existing policy.
Params
:rules— Required. List of rule maps with:direction,:action, and optionally:hostand:port.