pub struct HostBuilder { /* private fields */ }Expand description
Builder for creating instances of Host.
Provides a fluent interface for constructing a Host object with optional fields,
allowing for more readable and maintainable object construction.
§Examples
use opsview::config::{Host, HostBuilder, MonitoringCluster, HostGroup, HostTemplate};
use opsview::prelude::*;
let some_monitoring_cluster = MonitoringCluster::builder()
.name("example_monitoring_cluster")
.build()
.unwrap();
let parent_hostgroup = HostGroup::minimal("Opsview").unwrap();
let some_hostgroup = HostGroup::builder()
.name("example_hostgroup")
.parent(parent_hostgroup)
.build()
.unwrap();
let some_hosttemplates = ConfigObjectMap::<HostTemplate>::new();
let host = Host::builder()
.name("example_host")
.monitored_by(some_monitoring_cluster) // T: MonitoringClusterRef
.hostgroup(some_hostgroup) // T: HostGroup
.hosttemplates(&some_hosttemplates) // T: ConfigObjectMap<HostTemplate>
.ip("192.168.1.1")
.check_interval(5)
.build()
.unwrap();
assert_eq!(host.name, "example_host".to_string());Implementations§
Source§impl HostBuilder
impl HostBuilder
Sourcepub fn business_components(
self,
business_components: &ConfigObjectMap<BSMComponent>,
) -> Self
pub fn business_components( self, business_components: &ConfigObjectMap<BSMComponent>, ) -> Self
Sets the business_components field.
§Arguments
business_components- A reference to aConfigObjectMapofBSMComponentobjects for theHost.
Sourcepub fn check_attempts(self, check_attempts: u64) -> Self
pub fn check_attempts(self, check_attempts: u64) -> Self
Sets the check_attempts field.
§Arguments
check_attempts- Number of check attempts before a state change.
Sourcepub fn check_command(self, check_command: HostCheckCommand) -> Self
pub fn check_command(self, check_command: HostCheckCommand) -> Self
Sets the check_command field.
§Arguments
check_command- TheHostCheckCommanddefining the check to be performed on theHost.
Sourcepub fn check_interval(self, check_interval: u64) -> Self
pub fn check_interval(self, check_interval: u64) -> Self
Sourcepub fn check_period(self, check_period: TimePeriod) -> Self
pub fn check_period(self, check_period: TimePeriod) -> Self
Sets the check_period field.
§Arguments
check_period- ATimePeriodduring which checks are performed.
Sourcepub fn clear_alias(self) -> Self
pub fn clear_alias(self) -> Self
Clears the alias field.
Sourcepub fn clear_business_components(self) -> Self
pub fn clear_business_components(self) -> Self
Clears the business_components field.
Sourcepub fn clear_check_attempts(self) -> Self
pub fn clear_check_attempts(self) -> Self
Clears the check_attempts field.
Sourcepub fn clear_check_command(self) -> Self
pub fn clear_check_command(self) -> Self
Clears the check_command field.
Sourcepub fn clear_check_interval(self) -> Self
pub fn clear_check_interval(self) -> Self
Clears the check_interval field.
Sourcepub fn clear_check_period(self) -> Self
pub fn clear_check_period(self) -> Self
Clears the check_period field.
Sourcepub fn clear_enable_snmp(self) -> Self
pub fn clear_enable_snmp(self) -> Self
Clears the enable_snmp field.
Sourcepub fn clear_event_handler(self) -> Self
pub fn clear_event_handler(self) -> Self
Clears the event_handler field.
Sourcepub fn clear_event_handler_always_exec(self) -> Self
pub fn clear_event_handler_always_exec(self) -> Self
Clears the event_handler_always_exec field.
Sourcepub fn clear_flap_detection_enabled(self) -> Self
pub fn clear_flap_detection_enabled(self) -> Self
Clears the flap_detection_enabled field.
Clears the keywords field. Alias for clear_keywords().
Sourcepub fn clear_hostattributes(self) -> Self
pub fn clear_hostattributes(self) -> Self
Clears the Hostattributes field.
Sourcepub fn clear_hostgroup(self) -> Self
pub fn clear_hostgroup(self) -> Self
Clears the Hostgroup field.
Sourcepub fn clear_hosttemplates(self) -> Self
pub fn clear_hosttemplates(self) -> Self
Clears the Hosttemplates field.
Sourcepub fn clear_icon(self) -> Self
pub fn clear_icon(self) -> Self
Clears the icon field.
Sourcepub fn clear_keywords(self) -> Self
pub fn clear_keywords(self) -> Self
Clears the keywords field.
Sourcepub fn clear_monitored_by(self) -> Self
pub fn clear_monitored_by(self) -> Self
Clears the monitored_by field.
Sourcepub fn clear_name(self) -> Self
pub fn clear_name(self) -> Self
Clears the name field.
Sourcepub fn clear_nmis_node_type(self) -> Self
pub fn clear_nmis_node_type(self) -> Self
Clears the nmis_node_type field.
Sourcepub fn clear_notification_interval(self) -> Self
pub fn clear_notification_interval(self) -> Self
Clears the notification_interval field.
Sourcepub fn clear_notification_options(self) -> Self
pub fn clear_notification_options(self) -> Self
Clears the notification_options field.
Sourcepub fn clear_notification_period(self) -> Self
pub fn clear_notification_period(self) -> Self
Clears the notification_period field.
Sourcepub fn clear_other_addresses(self) -> Self
pub fn clear_other_addresses(self) -> Self
Clears the other_addresses field.
Sourcepub fn clear_parents(self) -> Self
pub fn clear_parents(self) -> Self
Clears the parents field.
Sourcepub fn clear_rancid_autoenable(self) -> Self
pub fn clear_rancid_autoenable(self) -> Self
Clears the rancid_autoenable field.
Sourcepub fn clear_rancid_connection_type(self) -> Self
pub fn clear_rancid_connection_type(self) -> Self
Clears the rancid_connection_type field.
Sourcepub fn clear_rancid_password(self) -> Self
pub fn clear_rancid_password(self) -> Self
Clears the rancid_password field.
Sourcepub fn clear_rancid_username(self) -> Self
pub fn clear_rancid_username(self) -> Self
Clears the rancid_username field.
Sourcepub fn clear_rancid_vendor(self) -> Self
pub fn clear_rancid_vendor(self) -> Self
Clears the rancid_vendor field.
Sourcepub fn clear_retry_check_interval(self) -> Self
pub fn clear_retry_check_interval(self) -> Self
Clears the retry_check_interval field.
Sourcepub fn clear_servicechecks(self) -> Self
pub fn clear_servicechecks(self) -> Self
Clears the servicechecks field.
Sourcepub fn clear_snmp_community(self) -> Self
pub fn clear_snmp_community(self) -> Self
Clears the snmp_community field.
Sourcepub fn clear_snmp_extended_throughput_data(self) -> Self
pub fn clear_snmp_extended_throughput_data(self) -> Self
Clears the snmp_extended_throughput_data field.
Sourcepub fn clear_snmp_max_msg_size(self) -> Self
pub fn clear_snmp_max_msg_size(self) -> Self
Clears the snmp_max_msg_size field.
Sourcepub fn clear_snmp_port(self) -> Self
pub fn clear_snmp_port(self) -> Self
Clears the snmp_port field.
Sourcepub fn clear_snmp_use_getnext(self) -> Self
pub fn clear_snmp_use_getnext(self) -> Self
Clears the snmp_use_getnext field.
Sourcepub fn clear_snmp_use_ifname(self) -> Self
pub fn clear_snmp_use_ifname(self) -> Self
Clears the snmp_use_ifname field.
Sourcepub fn clear_snmp_version(self) -> Self
pub fn clear_snmp_version(self) -> Self
Clears the snmp_version field.
Sourcepub fn clear_snmpv3_authprotocol(self) -> Self
pub fn clear_snmpv3_authprotocol(self) -> Self
Clears the snmpv3_authprotocol field.
Sourcepub fn clear_snmpv3_privprotocol(self) -> Self
pub fn clear_snmpv3_privprotocol(self) -> Self
Clears the snmpv3_privprotocol field.
Sourcepub fn clear_snmpv3_username(self) -> Self
pub fn clear_snmpv3_username(self) -> Self
Clears the snmpv3_username field.
Sourcepub fn clear_snmpinterfaces(self) -> Self
pub fn clear_snmpinterfaces(self) -> Self
Clears the snmpinterfaces field.
Sourcepub fn clear_tidy_ifdescr_level(self) -> Self
pub fn clear_tidy_ifdescr_level(self) -> Self
Clears the tidy_ifdescr_level field.
Sourcepub fn clear_use_mrtg(self) -> Self
pub fn clear_use_mrtg(self) -> Self
Clears the use_mrtg field.
Sourcepub fn clear_use_nmis(self) -> Self
pub fn clear_use_nmis(self) -> Self
Clears the use_nmis field.
Sourcepub fn clear_use_rancid(self) -> Self
pub fn clear_use_rancid(self) -> Self
Clears the use_rancid field.
Sourcepub fn enable_snmp(self, enable_snmp: bool) -> Self
pub fn enable_snmp(self, enable_snmp: bool) -> Self
Sets the enable_snmp field.
Sourcepub fn event_handler(self, event_handler: &str) -> Self
pub fn event_handler(self, event_handler: &str) -> Self
Sourcepub fn event_handler_always_exec(self, event_handler_always_exec: bool) -> Self
pub fn event_handler_always_exec(self, event_handler_always_exec: bool) -> Self
Sets the event_handler_always_exec field.
§Arguments
event_handler_always_exec- Boolean indicating if the event handler should always execute.
Sourcepub fn flap_detection_enabled(self, flap_detection_enabled: bool) -> Self
pub fn flap_detection_enabled(self, flap_detection_enabled: bool) -> Self
Sets the flap_detection_enabled field.
§Arguments
flap_detection_enabled- Boolean indicating if flap detection is enabled.
Sets the keywords field. Alias for keywords().
§Arguments
keywords- A reference to aConfigObjectMapofHashtagobjects for theHost.
Sourcepub fn hostattributes(self, hostattributes: &ConfigObjectMap<Variable>) -> Self
pub fn hostattributes(self, hostattributes: &ConfigObjectMap<Variable>) -> Self
Sets the hostattributes field.
§Arguments
hostattributes- A reference to aConfigObjectMapofVariableobjects for theHost.
Sourcepub fn hosttemplates(
self,
hosttemplates: &ConfigObjectMap<HostTemplate>,
) -> Self
pub fn hosttemplates( self, hosttemplates: &ConfigObjectMap<HostTemplate>, ) -> Self
Sets the hosttemplates field.
§Arguments
hosttemplates- A reference to aConfigObjectMapofHostTemplateobjects for theHost.
Sourcepub fn keywords(self, keywords: &ConfigObjectMap<Hashtag>) -> Self
pub fn keywords(self, keywords: &ConfigObjectMap<Hashtag>) -> Self
Sets the keywords field.
§Arguments
keywords- A reference to aConfigObjectMapofHashtagobjects for theHost.
Sourcepub fn monitored_by(self, monitored_by: MonitoringCluster) -> Self
pub fn monitored_by(self, monitored_by: MonitoringCluster) -> Self
Sets the monitored_by field.
§Arguments
monitored_by- TheMonitoringClusterresponsible for monitoring theHost.
Sourcepub fn nmis_node_type(self, nmis_node_type: &str) -> Self
pub fn nmis_node_type(self, nmis_node_type: &str) -> Self
Sourcepub fn notification_interval(self, notification_interval: u64) -> Self
pub fn notification_interval(self, notification_interval: u64) -> Self
Sets the notification_interval field.
§Arguments
notification_interval- Interval between notifications.
Sourcepub fn notification_options(self, notification_options: &str) -> Self
pub fn notification_options(self, notification_options: &str) -> Self
Sets the notification_options field.
§Arguments
notification_options- Notification options for theHost. Valid options are:d- send notifications on DOWN stateu- send notifications on UNREACHABLE stater- send notifications on recovery (UP state)f- send notifications when the host starts and stops flapping
Multiple options can be specified, separated by commas.
§Example
“d,u,r”
Sourcepub fn notification_period(self, notification_period: TimePeriod) -> Self
pub fn notification_period(self, notification_period: TimePeriod) -> Self
Sets the notification_period field.
§Arguments
notification_period- ATimePeriodduring which notifications are sent.
Sourcepub fn other_addresses(self, other_addresses: &str) -> Self
pub fn other_addresses(self, other_addresses: &str) -> Self
Sourcepub fn parents(self, parents: &ConfigObjectMap<Host>) -> Self
pub fn parents(self, parents: &ConfigObjectMap<Host>) -> Self
Sets the parents field.
§Arguments
parents- A reference to aConfigObjectMapof parentHostobjects.
Sourcepub fn rancid_autoenable(self, rancid_autoenable: bool) -> Self
pub fn rancid_autoenable(self, rancid_autoenable: bool) -> Self
Sets the rancid_autoenable field.
§Arguments
rancid_autoenable- Boolean indicating whether RANCID auto-enable is active.
Sourcepub fn rancid_connection_type(
self,
rancid_connection_type: RancidConnectionType,
) -> Self
pub fn rancid_connection_type( self, rancid_connection_type: RancidConnectionType, ) -> Self
Sourcepub fn rancid_password(self, rancid_password: &str) -> Self
pub fn rancid_password(self, rancid_password: &str) -> Self
Sourcepub fn rancid_username(self, rancid_username: &str) -> Self
pub fn rancid_username(self, rancid_username: &str) -> Self
Sourcepub fn rancid_vendor(self, rancid_vendor: RancidVendor) -> Self
pub fn rancid_vendor(self, rancid_vendor: RancidVendor) -> Self
Sourcepub fn retry_check_interval(self, retry_check_interval: u64) -> Self
pub fn retry_check_interval(self, retry_check_interval: u64) -> Self
Sets the retry_check_interval field.
§Arguments
retry_check_interval- Interval between retry checks.
Sourcepub fn servicechecks(
self,
servicechecks: &ConfigObjectMap<ServiceCheck>,
) -> Self
pub fn servicechecks( self, servicechecks: &ConfigObjectMap<ServiceCheck>, ) -> Self
Sets the servicechecks field.
§Arguments
servicechecks- A reference to aConfigObjectMapofServiceCheckobjects for theHost.
Sourcepub fn snmp_community(self, snmp_community: &str) -> Self
pub fn snmp_community(self, snmp_community: &str) -> Self
Sourcepub fn snmp_extended_throughput_data(
self,
snmp_extended_throughput_data: bool,
) -> Self
pub fn snmp_extended_throughput_data( self, snmp_extended_throughput_data: bool, ) -> Self
Sets the snmp_extended_throughput_data field.
§Arguments
snmp_extended_throughput_data- Boolean indicating whether extended throughput data is collected via SNMP.
Sourcepub fn snmp_max_msg_size(self, snmp_max_msg_size: u64) -> Self
pub fn snmp_max_msg_size(self, snmp_max_msg_size: u64) -> Self
Sourcepub fn snmp_use_getnext(self, snmp_use_getnext: bool) -> Self
pub fn snmp_use_getnext(self, snmp_use_getnext: bool) -> Self
Sets the snmp_use_getnext field.
§Arguments
snmp_use_getnext- Boolean indicating whether SNMP GETNEXT requests are used.
Sourcepub fn snmp_use_ifname(self, snmp_use_ifname: bool) -> Self
pub fn snmp_use_ifname(self, snmp_use_ifname: bool) -> Self
Sets the snmp_use_ifname field.
§Arguments
snmp_use_ifname- Boolean indicating whether SNMP interface names are used.
Sourcepub fn snmp_version(self, version: SNMPVersion) -> Self
pub fn snmp_version(self, version: SNMPVersion) -> Self
Sourcepub fn snmpv3_authprotocol(self, protocol: SNMPV3AuthProtocol) -> Self
pub fn snmpv3_authprotocol(self, protocol: SNMPV3AuthProtocol) -> Self
Sourcepub fn snmpv3_authpassword(self, snmpv3_authpassword: &str) -> Self
pub fn snmpv3_authpassword(self, snmpv3_authpassword: &str) -> Self
Sets the snmpv3_authpassword field.
§Arguments
snmpv3_authpassword- Authentication password for SNMPv3.
Sourcepub fn snmpv3_privprotocol(self, protocol: SNMPV3PrivProtocol) -> Self
pub fn snmpv3_privprotocol(self, protocol: SNMPV3PrivProtocol) -> Self
Sourcepub fn snmpv3_privpassword(self, snmpv3_privpassword: &str) -> Self
pub fn snmpv3_privpassword(self, snmpv3_privpassword: &str) -> Self
Sourcepub fn snmpv3_username(self, snmpv3_username: &str) -> Self
pub fn snmpv3_username(self, snmpv3_username: &str) -> Self
Sourcepub fn snmpinterfaces(self, snmpinterfaces: SNMPInterfaces) -> Self
pub fn snmpinterfaces(self, snmpinterfaces: SNMPInterfaces) -> Self
Sourcepub fn tidy_ifdescr_level(self, tidy_ifdescr_level: &str) -> Self
pub fn tidy_ifdescr_level(self, tidy_ifdescr_level: &str) -> Self
Sets the tidy_ifdescr_level field.
§Arguments
tidy_ifdescr_level- Interface description level for tidying.
Sourcepub fn use_mrtg(self, use_mrtg: bool) -> Self
pub fn use_mrtg(self, use_mrtg: bool) -> Self
Sets the use_mrtg field.
§Arguments
use_mrtg- Boolean indicating whether MRTG is used for theHost.
Sourcepub fn use_nmis(self, use_nmis: bool) -> Self
pub fn use_nmis(self, use_nmis: bool) -> Self
Sets the use_nmis field.
§Arguments
use_nmis- Boolean indicating whether NMIS is used for theHost.
Sourcepub fn use_rancid(self, use_rancid: bool) -> Self
pub fn use_rancid(self, use_rancid: bool) -> Self
Sets the use_rancid field.
§Arguments
use_rancid- Boolean indicating whether RANCID is used for theHost.
Trait Implementations§
Source§impl Builder for HostBuilder
impl Builder for HostBuilder
Source§fn new() -> Self
fn new() -> Self
Creates a new instance of HostBuilder with default values.
Initializes a new builder for creating a Host object with all fields in their default
state.
Source§fn build(self) -> Result<Host, OpsviewConfigError>
fn build(self) -> Result<Host, OpsviewConfigError>
Completes the construction of a Host object.
Validates the current state of the HostBuilder and assembles a Host object.
This method checks that all required fields are set and any constraints are met.
If a required field is missing or a constraint is violated, an error is returned.
§Errors
Returns an error if any required fields are not set or if there are inconsistencies in the provided data.
§Returns
On success, returns a Result containing the constructed Host object.
On failure, returns a Result containing an OpsviewConfigError.
type ConfigObject = Host
Source§impl Clone for HostBuilder
impl Clone for HostBuilder
Source§fn clone(&self) -> HostBuilder
fn clone(&self) -> HostBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more