pub struct Icinga2 {
pub url: Url,
pub username: String,
/* private fields */
}Expand description
the runtime object for an Icinga2 instance (blocking variant)
Fields§
§url: Urlthe base URL for the Icinga API
username: Stringusername, empty when authenticating with a client certificate
Implementations§
Source§impl Icinga2
impl Icinga2
Sourcepub fn from_instance_config(config: &Icinga2Instance) -> Result<Self, Error>
pub fn from_instance_config(config: &Icinga2Instance) -> Result<Self, Error>
create a new Icinga2 instance from a config that was either manually created or previously loaded via Icinga2Instance::from_config_file
§Errors
this fails if the CA certificate file mentioned in the configuration can not be found or parsed
Sourcepub fn from_parts(
url: &str,
ca_certificate: Option<&Path>,
auth: Icinga2Auth,
) -> Result<Self, Error>
pub fn from_parts( url: &str, ca_certificate: Option<&Path>, auth: Icinga2Auth, ) -> Result<Self, Error>
create a new Icinga2 instance from its URL (without the v1 component), an optional CA certificate to validate the server certificate with and the authentication to use
see also crate::config::instance_file::Icinga2InstanceFile which resolves these parts from an instance config file
§Errors
this fails if the CA certificate file can not be found or parsed, the client certificate can not be parsed or the URL can not be parsed
Sourcepub fn from_config_file(path: &Path) -> Result<Self, Error>
pub fn from_config_file(path: &Path) -> Result<Self, Error>
create a new Icinga2 instance from a TOML config file
§Errors
this fails if the configuration file can not be found or parsed or the CA certificate file mentioned in the configuration file can not be found or parsed
Sourcepub fn rest<ApiEndpoint, Res>(
&self,
api_endpoint: ApiEndpoint,
) -> Result<Res, Error>where
ApiEndpoint: RestApiEndpoint,
<ApiEndpoint as RestApiEndpoint>::RequestBody: Clone + Serialize + Debug,
Res: DeserializeOwned + Debug + RestApiResponse<ApiEndpoint>,
pub fn rest<ApiEndpoint, Res>(
&self,
api_endpoint: ApiEndpoint,
) -> Result<Res, Error>where
ApiEndpoint: RestApiEndpoint,
<ApiEndpoint as RestApiEndpoint>::RequestBody: Clone + Serialize + Debug,
Res: DeserializeOwned + Debug + RestApiResponse<ApiEndpoint>,
common code for the REST API calls
§Errors
this returns an error if encoding, the actual request, or decoding of the response fail