UnifiApi.Network.Resources (UnifiApi v0.4.0)

Copy Markdown View Source

UniFi Network API — supporting resources.

Read-only endpoints for WANs, VPN tunnels/servers, RADIUS profiles, device tags, DPI data, and country lists. These are typically used as reference data when building firewall rules, ACLs, or network configs.

Summary

Functions

Lists countries (not site-scoped).

Lists device tags on a site.

Lists DPI applications (not site-scoped).

Lists DPI categories (not site-scoped).

Lists RADIUS profiles on a site.

Lists VPN servers on a site.

Lists site-to-site VPN tunnels.

Lists WAN interfaces on a site.

Returns a lazy stream that auto-paginates through all countries.

Returns a lazy stream that auto-paginates through all device tags.

Returns a lazy stream that auto-paginates through all DPI applications.

Returns a lazy stream that auto-paginates through all DPI categories.

Returns a lazy stream that auto-paginates through all RADIUS profiles.

Returns a lazy stream that auto-paginates through all VPN servers.

Returns a lazy stream that auto-paginates through all VPN tunnels.

Returns a lazy stream that auto-paginates through all WANs.

Functions

list_countries(client, opts \\ [])

@spec list_countries(
  Req.Request.t(),
  keyword()
) :: {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists countries (not site-scoped).

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, countries} = UnifiApi.Network.Resources.list_countries(client)

list_device_tags(client, site_id, opts \\ [])

@spec list_device_tags(Req.Request.t(), String.t(), keyword()) ::
  {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists device tags on a site.

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, tags} = UnifiApi.Network.Resources.list_device_tags(client, site_id)

list_dpi_applications(client, opts \\ [])

@spec list_dpi_applications(
  Req.Request.t(),
  keyword()
) :: {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists DPI applications (not site-scoped).

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, apps} = UnifiApi.Network.Resources.list_dpi_applications(client)

list_dpi_categories(client, opts \\ [])

@spec list_dpi_categories(
  Req.Request.t(),
  keyword()
) :: {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists DPI categories (not site-scoped).

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, categories} = UnifiApi.Network.Resources.list_dpi_categories(client)

list_radius_profiles(client, site_id, opts \\ [])

@spec list_radius_profiles(Req.Request.t(), String.t(), keyword()) ::
  {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists RADIUS profiles on a site.

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, profiles} = UnifiApi.Network.Resources.list_radius_profiles(client, site_id)

list_vpn_servers(client, site_id, opts \\ [])

@spec list_vpn_servers(Req.Request.t(), String.t(), keyword()) ::
  {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists VPN servers on a site.

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, servers} = UnifiApi.Network.Resources.list_vpn_servers(client, site_id)

list_vpn_tunnels(client, site_id, opts \\ [])

@spec list_vpn_tunnels(Req.Request.t(), String.t(), keyword()) ::
  {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists site-to-site VPN tunnels.

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, tunnels} = UnifiApi.Network.Resources.list_vpn_tunnels(client, site_id)

list_wans(client, site_id, opts \\ [])

@spec list_wans(Req.Request.t(), String.t(), keyword()) ::
  {:ok, term()} | {:error, UnifiApi.Error.t()}

Lists WAN interfaces on a site.

Options

Supports pagination: :offset, :limit, :filter.

Examples

{:ok, wans} = UnifiApi.Network.Resources.list_wans(client, site_id)

stream_countries(client, opts \\ [])

@spec stream_countries(
  Req.Request.t(),
  keyword()
) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all countries.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_countries(client) |> Enum.to_list()

stream_device_tags(client, site_id, opts \\ [])

@spec stream_device_tags(Req.Request.t(), String.t(), keyword()) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all device tags.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_device_tags(client, site_id) |> Enum.to_list()

stream_dpi_applications(client, opts \\ [])

@spec stream_dpi_applications(
  Req.Request.t(),
  keyword()
) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all DPI applications.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_dpi_applications(client) |> Enum.to_list()

stream_dpi_categories(client, opts \\ [])

@spec stream_dpi_categories(
  Req.Request.t(),
  keyword()
) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all DPI categories.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_dpi_categories(client) |> Enum.to_list()

stream_radius_profiles(client, site_id, opts \\ [])

@spec stream_radius_profiles(Req.Request.t(), String.t(), keyword()) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all RADIUS profiles.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_radius_profiles(client, site_id) |> Enum.to_list()

stream_vpn_servers(client, site_id, opts \\ [])

@spec stream_vpn_servers(Req.Request.t(), String.t(), keyword()) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all VPN servers.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_vpn_servers(client, site_id) |> Enum.to_list()

stream_vpn_tunnels(client, site_id, opts \\ [])

@spec stream_vpn_tunnels(Req.Request.t(), String.t(), keyword()) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all VPN tunnels.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_vpn_tunnels(client, site_id) |> Enum.to_list()

stream_wans(client, site_id, opts \\ [])

@spec stream_wans(Req.Request.t(), String.t(), keyword()) :: Enumerable.t()

Returns a lazy stream that auto-paginates through all WANs.

Error contract

A mid-stream error does not raise by default: the stream halts and yields {:error, %UnifiApi.StreamError{}, last_offset} as its final element, so the enumerable is heterogeneous. Match the tail:

case Enum.to_list(stream) do
  items when is_list(items) ->
    case List.last(items) do
      {:error, error, cursor} -> {:error, error, cursor}
      _ -> {:ok, items}
    end
end

Pass raise_errors: true to raise UnifiApi.StreamError instead.

Options

  • :max_pages — halt after this many successful pages (default: unbounded).
  • :max_items — halt once this many items have been yielded (default: unbounded).
  • :raise_errors — raise UnifiApi.StreamError on error instead of yielding the error tuple (default: false).

Examples

UnifiApi.Network.Resources.stream_wans(client, site_id) |> Enum.to_list()