pub struct Icinga2InstanceFile {
pub url: String,
pub ca_certificate: Option<PathBuf>,
pub web_base_url: Option<String>,
pub auth: Icinga2InstanceFileAuth,
}Expand description
one Icinga instance config file
Fields§
§url: Stringthe API URL, without the v1 component, e.g. https://icinga.example.com:5665
ca_certificate: Option<PathBuf>the CA certificate to validate the server certificate with
web_base_url: Option<String>the Icinga Web base URL, e.g. https://icinga.example.com/monitoring/,
not used by this crate, for tools that link to the web interface
auth: Icinga2InstanceFileAuthhow to authenticate
Implementations§
Source§impl Icinga2InstanceFile
impl Icinga2InstanceFile
Sourcepub fn from_file(path: &Path) -> Result<Self, Icinga2InstanceFileError>
pub fn from_file(path: &Path) -> Result<Self, Icinga2InstanceFileError>
Sourcepub fn load_dir(
dir: &Path,
) -> Result<Vec<(String, Self)>, Icinga2InstanceFileError>
pub fn load_dir( dir: &Path, ) -> Result<Vec<(String, Self)>, Icinga2InstanceFileError>
read all *.toml files in a directory, sorted by name
the name of each instance is its file stem
§Errors
fails if the directory or any of the files can not be read or parsed
Sourcepub fn username(&self) -> Option<&str>
pub fn username(&self) -> Option<&str>
the basic auth username, None for client certificate auth
Sourcepub fn resolve_auth(&self) -> Result<Icinga2Auth, Icinga2InstanceFileError>
pub fn resolve_auth(&self) -> Result<Icinga2Auth, Icinga2InstanceFileError>
resolve the auth, running the password command or reading the client certificate if necessary
the password command gets no stdin and inherits stderr
§Errors
fails if the password command fails or prints no password, or if the client certificate or key can not be read
Sourcepub async fn resolve_auth_async(
&self,
timeout: Option<Duration>,
) -> Result<Icinga2Auth, Icinga2InstanceFileError>
pub async fn resolve_auth_async( &self, timeout: Option<Duration>, ) -> Result<Icinga2Auth, Icinga2InstanceFileError>
like Self::resolve_auth but runs the password command
asynchronously, killing it if it does not finish within timeout
(e.g. while a password store waits for a locked key)
§Errors
fails like Self::resolve_auth or if the timeout expires
Sourcepub fn connect_blocking(&self) -> Result<Icinga2, Icinga2InstanceFileError>
pub fn connect_blocking(&self) -> Result<Icinga2, Icinga2InstanceFileError>
resolve the auth and build a blocking client
§Errors
fails if the auth can not be resolved or the client can not be built
Sourcepub async fn connect_async(
&self,
timeout: Option<Duration>,
) -> Result<Icinga2Async, Icinga2InstanceFileError>
pub async fn connect_async( &self, timeout: Option<Duration>, ) -> Result<Icinga2Async, Icinga2InstanceFileError>
resolve the auth asynchronously (see Self::resolve_auth_async) and
build an async client
§Errors
fails if the auth can not be resolved or the client can not be built