HostBuilder

Struct HostBuilder 

Source
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

Source

pub fn alias(self, alias: &str) -> Self

Sets the alias field.

§Arguments
  • alias - The alias of the Host.
Source

pub fn business_components( self, business_components: &ConfigObjectMap<BSMComponent>, ) -> Self

Sets the business_components field.

§Arguments
Source

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

pub fn check_command(self, check_command: HostCheckCommand) -> Self

Sets the check_command field.

§Arguments
  • check_command - The HostCheckCommand defining the check to be performed on the Host.
Source

pub fn check_interval(self, check_interval: u64) -> Self

Sets the check_interval field.

§Arguments
  • check_interval - Interval between checks.
Source

pub fn check_period(self, check_period: TimePeriod) -> Self

Sets the check_period field.

§Arguments
  • check_period - A TimePeriod during which checks are performed.
Source

pub fn clear_alias(self) -> Self

Clears the alias field.

Source

pub fn clear_business_components(self) -> Self

Clears the business_components field.

Source

pub fn clear_check_attempts(self) -> Self

Clears the check_attempts field.

Source

pub fn clear_check_command(self) -> Self

Clears the check_command field.

Source

pub fn clear_check_interval(self) -> Self

Clears the check_interval field.

Source

pub fn clear_check_period(self) -> Self

Clears the check_period field.

Source

pub fn clear_enable_snmp(self) -> Self

Clears the enable_snmp field.

Source

pub fn clear_event_handler(self) -> Self

Clears the event_handler field.

Source

pub fn clear_event_handler_always_exec(self) -> Self

Clears the event_handler_always_exec field.

Source

pub fn clear_flap_detection_enabled(self) -> Self

Clears the flap_detection_enabled field.

Source

pub fn clear_hashtags(self) -> Self

Clears the keywords field. Alias for clear_keywords().

Source

pub fn clear_hostattributes(self) -> Self

Clears the Hostattributes field.

Source

pub fn clear_hostgroup(self) -> Self

Clears the Hostgroup field.

Source

pub fn clear_hosttemplates(self) -> Self

Clears the Hosttemplates field.

Source

pub fn clear_icon(self) -> Self

Clears the icon field.

Source

pub fn clear_ip(self) -> Self

Clears the ip field.

Source

pub fn clear_keywords(self) -> Self

Clears the keywords field.

Source

pub fn clear_monitored_by(self) -> Self

Clears the monitored_by field.

Source

pub fn clear_name(self) -> Self

Clears the name field.

Source

pub fn clear_nmis_node_type(self) -> Self

Clears the nmis_node_type field.

Source

pub fn clear_notification_interval(self) -> Self

Clears the notification_interval field.

Source

pub fn clear_notification_options(self) -> Self

Clears the notification_options field.

Source

pub fn clear_notification_period(self) -> Self

Clears the notification_period field.

Source

pub fn clear_other_addresses(self) -> Self

Clears the other_addresses field.

Source

pub fn clear_parents(self) -> Self

Clears the parents field.

Source

pub fn clear_rancid_autoenable(self) -> Self

Clears the rancid_autoenable field.

Source

pub fn clear_rancid_connection_type(self) -> Self

Clears the rancid_connection_type field.

Source

pub fn clear_rancid_password(self) -> Self

Clears the rancid_password field.

Source

pub fn clear_rancid_username(self) -> Self

Clears the rancid_username field.

Source

pub fn clear_rancid_vendor(self) -> Self

Clears the rancid_vendor field.

Source

pub fn clear_retry_check_interval(self) -> Self

Clears the retry_check_interval field.

Source

pub fn clear_servicechecks(self) -> Self

Clears the servicechecks field.

Source

pub fn clear_snmp_community(self) -> Self

Clears the snmp_community field.

Source

pub fn clear_snmp_extended_throughput_data(self) -> Self

Clears the snmp_extended_throughput_data field.

Source

pub fn clear_snmp_max_msg_size(self) -> Self

Clears the snmp_max_msg_size field.

Source

pub fn clear_snmp_port(self) -> Self

Clears the snmp_port field.

Source

pub fn clear_snmp_use_getnext(self) -> Self

Clears the snmp_use_getnext field.

Source

pub fn clear_snmp_use_ifname(self) -> Self

Clears the snmp_use_ifname field.

Source

pub fn clear_snmp_version(self) -> Self

Clears the snmp_version field.

Source

pub fn clear_snmpv3_authprotocol(self) -> Self

Clears the snmpv3_authprotocol field.

Source

pub fn clear_snmpv3_privprotocol(self) -> Self

Clears the snmpv3_privprotocol field.

Source

pub fn clear_snmpv3_username(self) -> Self

Clears the snmpv3_username field.

Source

pub fn clear_snmpinterfaces(self) -> Self

Clears the snmpinterfaces field.

Source

pub fn clear_tidy_ifdescr_level(self) -> Self

Clears the tidy_ifdescr_level field.

Source

pub fn clear_use_mrtg(self) -> Self

Clears the use_mrtg field.

Source

pub fn clear_use_nmis(self) -> Self

Clears the use_nmis field.

Source

pub fn clear_use_rancid(self) -> Self

Clears the use_rancid field.

Source

pub fn enable_snmp(self, enable_snmp: bool) -> Self

Sets the enable_snmp field.

Source

pub fn event_handler(self, event_handler: &str) -> Self

Sets the event_handler field.

§Arguments
  • event_handler - The event handler for the Host.
Source

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

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

pub fn hashtags(self, hashtags: &ConfigObjectMap<Hashtag>) -> Self

Sets the keywords field. Alias for keywords().

§Arguments
Source

pub fn hostattributes(self, hostattributes: &ConfigObjectMap<Variable>) -> Self

Sets the hostattributes field.

§Arguments
Source

pub fn hostgroup(self, hostgroup: HostGroup) -> Self

Sets the hostgroup field.

§Arguments
  • hostgroup - The HostGroup object for the Host.
Source

pub fn hosttemplates( self, hosttemplates: &ConfigObjectMap<HostTemplate>, ) -> Self

Sets the hosttemplates field.

§Arguments
Source

pub fn icon(self, icon: HostIcon) -> Self

Sets the icon field.

§Arguments
  • icon - The HostIcon associated with the Host.
Source

pub fn ip(self, ip: &str) -> Self

Sets the ip field.

§Arguments
  • ip - IP address of the Host.
Source

pub fn keywords(self, keywords: &ConfigObjectMap<Hashtag>) -> Self

Sets the keywords field.

§Arguments
Source

pub fn monitored_by(self, monitored_by: MonitoringCluster) -> Self

Sets the monitored_by field.

§Arguments
Source

pub fn nmis_node_type(self, nmis_node_type: &str) -> Self

Sets the nmis_node_type field.

§Arguments
  • nmis_node_type - NMIS node type.
Source

pub fn notification_interval(self, notification_interval: u64) -> Self

Sets the notification_interval field.

§Arguments
  • notification_interval - Interval between notifications.
Source

pub fn notification_options(self, notification_options: &str) -> Self

Sets the notification_options field.

§Arguments
  • notification_options - Notification options for the Host. Valid options are:
    • d - send notifications on DOWN state
    • u - send notifications on UNREACHABLE state
    • r - 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”

Source

pub fn notification_period(self, notification_period: TimePeriod) -> Self

Sets the notification_period field.

§Arguments
  • notification_period - A TimePeriod during which notifications are sent.
Source

pub fn other_addresses(self, other_addresses: &str) -> Self

Sets the other_addresses field.

§Arguments
  • other_addresses - Additional addresses for the Host.
Source

pub fn parents(self, parents: &ConfigObjectMap<Host>) -> Self

Sets the parents field.

§Arguments
Source

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

pub fn rancid_connection_type( self, rancid_connection_type: RancidConnectionType, ) -> Self

Sets the rancid_connection_type field.

§Arguments
  • rancid_connection_type - RANCID connection type.
Source

pub fn rancid_password(self, rancid_password: &str) -> Self

Sets the rancid_password field.

§Arguments
  • rancid_password - Password for RANCID.
Source

pub fn rancid_username(self, rancid_username: &str) -> Self

Sets the rancid_username field.

§Arguments
  • rancid_username - Username for RANCID.
Source

pub fn rancid_vendor(self, rancid_vendor: RancidVendor) -> Self

Sets the rancid_vendor field.

§Arguments
Source

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

pub fn servicechecks( self, servicechecks: &ConfigObjectMap<ServiceCheck>, ) -> Self

Sets the servicechecks field.

§Arguments
Source

pub fn snmp_community(self, snmp_community: &str) -> Self

Sets the snmp_community field.

§Arguments
  • snmp_community - SNMP community string.
Source

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

pub fn snmp_max_msg_size(self, snmp_max_msg_size: u64) -> Self

Sets the snmp_max_msg_size field.

§Arguments
  • snmp_max_msg_size - Maximum SNMP message size.
Source

pub fn snmp_port(self, snmp_port: u64) -> Self

Sets the snmp_port field.

§Arguments
  • snmp_port - SNMP port number.
Source

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

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

pub fn snmp_version(self, version: SNMPVersion) -> Self

Sets the snmp_version field.

§Arguments
Source

pub fn snmpv3_authprotocol(self, protocol: SNMPV3AuthProtocol) -> Self

Sets the snmpv3_authprotocol field.

§Arguments
Source

pub fn snmpv3_authpassword(self, snmpv3_authpassword: &str) -> Self

Sets the snmpv3_authpassword field.

§Arguments
  • snmpv3_authpassword - Authentication password for SNMPv3.
Source

pub fn snmpv3_privprotocol(self, protocol: SNMPV3PrivProtocol) -> Self

Sets the snmpv3_privprotocol field.

§Arguments
Source

pub fn snmpv3_privpassword(self, snmpv3_privpassword: &str) -> Self

Sets the snmpv3_privpassword field.

§Arguments
  • snmpv3_privpassword - Privacy password for SNMPv3.
Source

pub fn snmpv3_username(self, snmpv3_username: &str) -> Self

Sets the snmpv3_username field.

§Arguments
  • snmpv3_username - Username for SNMPv3.
Source

pub fn snmpinterfaces(self, snmpinterfaces: SNMPInterfaces) -> Self

Sets the snmpinterfaces field.

§Arguments
Source

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

pub fn use_mrtg(self, use_mrtg: bool) -> Self

Sets the use_mrtg field.

§Arguments
  • use_mrtg - Boolean indicating whether MRTG is used for the Host.
Source

pub fn use_nmis(self, use_nmis: bool) -> Self

Sets the use_nmis field.

§Arguments
  • use_nmis - Boolean indicating whether NMIS is used for the Host.
Source

pub fn use_rancid(self, use_rancid: bool) -> Self

Sets the use_rancid field.

§Arguments
  • use_rancid - Boolean indicating whether RANCID is used for the Host.

Trait Implementations§

Source§

impl Builder for HostBuilder

Source§

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 name(self, name: &str) -> Self

Sets the name field.

§Arguments
  • name - Name of the Host.
Source§

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.

Source§

type ConfigObject = Host

Source§

impl Clone for HostBuilder

Source§

fn clone(&self) -> HostBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HostBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HostBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,