defmodule Towerops.Snmp.Profiles.Vendors.RuckusSz do
  @moduledoc """
  Ruckus SmartZone wireless controller device-specific SNMP handling.

  Supports Ruckus SmartZone wireless LAN controllers.

  Supported devices:
  - SmartZone 100 (SZ-100)
  - SmartZone 144 (SZ-144)
  - SmartZone 300 (SZ-300)
  - Virtual SmartZone (vSZ)
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

  alias Towerops.Snmp.Client
  alias Towerops.Snmp.Profiles.Vendors.Vendor

  # Ruckus Enterprise OID: 1.3.6.1.4.1.25053
  @model_oid "1.3.6.1.4.1.25053.1.1.1.0"

  @impl true
  def profile_names do
    ["ruckuswireless-sz"]
  end

  @impl true
  def detect_hardware(client_opts) do
    case Client.get(client_opts, @model_oid) do
      {:ok, model} when is_binary(model) -> model
      _ -> nil
    end
  end

  @impl true
  def discover_wireless_sensors(client_opts) do
    Vendor.fetch_sensors(wireless_oid_defs(), client_opts)
  end

  @impl true
  def wireless_oid_defs do
    [
      # Total Access Points
      %{
        oid: "1.3.6.1.4.1.25053.1.2.1.1.1.1.1.0",
        sensor_type: "count",
        sensor_descr: "Total Access Points",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Connected Access Points
      %{
        oid: "1.3.6.1.4.1.25053.1.2.1.1.1.1.2.0",
        sensor_type: "count",
        sensor_descr: "Connected Access Points",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # Total Wireless Clients
      %{
        oid: "1.3.6.1.4.1.25053.1.2.1.1.1.1.3.0",
        sensor_type: "clients",
        sensor_descr: "Total Wireless Clients",
        sensor_unit: "",
        sensor_divisor: 1
      },
      # CPU Utilization
      %{
        oid: "1.3.6.1.4.1.25053.1.2.1.1.1.2.1.0",
        sensor_type: "load",
        sensor_descr: "CPU Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Memory Utilization
      %{
        oid: "1.3.6.1.4.1.25053.1.2.1.1.1.2.2.0",
        sensor_type: "load",
        sensor_descr: "Memory Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      }
    ]
  end
end
