Search documentation of snmpkit

# SnmpKit.SnmpSim.Config (snmpkit v1.3.17)

Configuration management for SnmpSim with support for JSON and YAML files.

This module provides a convenient way to configure SnmpSim using external configuration files, making it especially useful for container deployments and development environments.

## Supported formats

- JSON files
- YAML files (requires `yaml_elixir` dependency)
- Elixir configuration maps

## Usage

    # Load from JSON file
    {:ok, config} = SnmpKit.SnmpSim.Config.load_from_file("config/devices.json")
    {:ok, devices} = SnmpKit.SnmpSim.Config.start_from_config(config)

    # Load from YAML file
    {:ok, config} = SnmpKit.SnmpSim.Config.load_yaml("config/devices.yaml")
    {:ok, devices} = SnmpKit.SnmpSim.Config.start_from_config(config)

    # Load from environment
    {:ok, config} = SnmpKit.SnmpSim.Config.load_from_environment()
    {:ok, devices} = SnmpKit.SnmpSim.Config.start_from_config(config)

# Summary

## Functions

load_from_environment()

Loads configuration from environment variables.

load_from_file(file_path)

Loads configuration from a JSON file.

load_yaml(file_path)

Loads configuration from a YAML file.

sample_config()

Creates a sample configuration for reference.

start_from_config(map)

Starts devices and services based on the provided configuration.

validate_config(config)

Validates a configuration map and provides helpful error messages.

write_sample_config(file_path, format \\ :json)

Writes a sample configuration to a file.

# Functions

# load_from_environment()

Loads configuration from environment variables.

This function reads common environment variables and creates a configuration map suitable for starting devices and configuring the system.

# load_from_file(file_path)

Loads configuration from a JSON file.

# load_yaml(file_path)

Loads configuration from a YAML file.

Requires the `yaml_elixir` dependency to be added to your mix.exs:

    {:yaml_elixir, "~> 2.9"}

# sample_config()

Creates a sample configuration for reference.

# start_from_config(map)

Starts devices and services based on the provided configuration.

# validate_config(config)

Validates a configuration map and provides helpful error messages.

# write_sample_config(file_path, format \\ :json)

Writes a sample configuration to a file.