Miosa.NetworkPolicy (Miosa v1.0.0)

Copy Markdown View Source

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

policy_params()

@type policy_params() :: %{rules: [rule_params()]}

rule_params()

@type rule_params() :: %{
  :direction => String.t(),
  :action => String.t(),
  optional(:host) => String.t(),
  optional(:port) => String.t() | pos_integer()
}

Functions

get(client, computer_id)

Returns the current network policy for a computer.

reset(client, computer_id)

@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.

set(client, computer_id, params)

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 :host and :port.