fix typos
This commit is contained in:
parent
62fca534a1
commit
8e34f31810
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::api::rules::contactgroups::HostContactGroups;
|
||||
use crate::api::rules::snmp::SnmpCommunity;
|
||||
use crate::api::{BulkReadDomainExtention, BulkUpdateDomainExtention, DomainExtention};
|
||||
use crate::api::{BulkReadDomainExtension, BulkUpdateDomainExtension, DomainExtension};
|
||||
use crate::{ApiClient, Client, Result};
|
||||
|
||||
pub const ROOT_FOLDER: &str = "/";
|
||||
@ -109,7 +109,7 @@ pub struct MetaData {
|
||||
pub created_by: Option<String>,
|
||||
}
|
||||
|
||||
impl DomainExtention for FolderConfig {
|
||||
impl DomainExtension for FolderConfig {
|
||||
const DOMAIN_TYPE: super::DomainType = super::DomainType::FolderConfig;
|
||||
|
||||
type CreationRequest = FolderCreationRequest;
|
||||
@ -227,10 +227,10 @@ impl FolderDeleteQuery {
|
||||
pub enum FolderDeleteMode {
|
||||
#[default]
|
||||
Recursive,
|
||||
AbotyOnNonEmpty,
|
||||
AbortOnNonEmpty,
|
||||
}
|
||||
|
||||
impl BulkReadDomainExtention for FolderConfig {
|
||||
impl BulkReadDomainExtension for FolderConfig {
|
||||
type BulkReadQuery = FolderBulkReadQuery;
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ impl FolderBulkReadQuery {
|
||||
}
|
||||
}
|
||||
|
||||
impl BulkUpdateDomainExtention for FolderConfig {
|
||||
impl BulkUpdateDomainExtension for FolderConfig {
|
||||
type BulkUpdateRequest = FolderBulkUpdateRequest;
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::api::folders::FolderAttributes;
|
||||
use crate::api::{
|
||||
BulkCreateDomainExtention, BulkDeleteDomainExtention, BulkReadDomainExtention,
|
||||
BulkUpdateDomainExtention, DomainExtention,
|
||||
BulkCreateDomainExtension, BulkDeleteDomainExtension, BulkReadDomainExtension,
|
||||
BulkUpdateDomainExtension, DomainExtension,
|
||||
};
|
||||
use crate::{ApiClient, Client};
|
||||
|
||||
@ -23,7 +23,7 @@ pub struct HostConfig {
|
||||
pub cluster_nodes: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl DomainExtention for HostConfig {
|
||||
impl DomainExtension for HostConfig {
|
||||
const DOMAIN_TYPE: super::DomainType = super::DomainType::HostConfig;
|
||||
|
||||
type CreationRequest = HostCreationRequest;
|
||||
@ -105,14 +105,14 @@ impl HostUpdateRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl BulkCreateDomainExtention for HostConfig {}
|
||||
impl BulkReadDomainExtention for HostConfig {
|
||||
impl BulkCreateDomainExtension for HostConfig {}
|
||||
impl BulkReadDomainExtension for HostConfig {
|
||||
type BulkReadQuery = HostBulkReadQuery;
|
||||
}
|
||||
impl BulkUpdateDomainExtention for HostConfig {
|
||||
impl BulkUpdateDomainExtension for HostConfig {
|
||||
type BulkUpdateRequest = HostBulkUpdateRequest;
|
||||
}
|
||||
impl BulkDeleteDomainExtention for HostConfig {}
|
||||
impl BulkDeleteDomainExtension for HostConfig {}
|
||||
|
||||
#[derive(Debug, Default, Clone, Serialize)]
|
||||
pub struct HostBulkReadQuery {
|
||||
|
||||
@ -81,7 +81,7 @@ pub(crate) struct DomainCollection<E> {
|
||||
// pub extensions: Option<E>,
|
||||
}
|
||||
|
||||
pub trait DomainExtention: DeserializeOwned + Serialize {
|
||||
pub trait DomainExtension: DeserializeOwned + Serialize {
|
||||
const DOMAIN_TYPE: DomainType;
|
||||
|
||||
type CreationRequest: Serialize;
|
||||
@ -91,14 +91,14 @@ pub trait DomainExtention: DeserializeOwned + Serialize {
|
||||
type DeleteQuery: Serialize;
|
||||
}
|
||||
|
||||
// these are essentials tags for domain extentions to signal that bulk operations are possible
|
||||
// not every extention supports bulk operations. and not all extentions that do support all of them
|
||||
// these are essential tags for domain extensions to signal that bulk operations are possible
|
||||
// not every extension supports bulk operations. and not all extensions that do support all of them
|
||||
// and those that do tend to have a bit different types
|
||||
pub trait BulkCreateDomainExtention: DomainExtention {}
|
||||
pub trait BulkReadDomainExtention: DomainExtention {
|
||||
pub trait BulkCreateDomainExtension: DomainExtension {}
|
||||
pub trait BulkReadDomainExtension: DomainExtension {
|
||||
type BulkReadQuery: Serialize;
|
||||
}
|
||||
pub trait BulkUpdateDomainExtention: DomainExtention {
|
||||
pub trait BulkUpdateDomainExtension: DomainExtension {
|
||||
type BulkUpdateRequest: Serialize;
|
||||
}
|
||||
pub trait BulkDeleteDomainExtention: DomainExtention {}
|
||||
pub trait BulkDeleteDomainExtension: DomainExtension {}
|
||||
|
||||
@ -5,6 +5,6 @@ pub struct HostContactGroups {
|
||||
groups: Vec<String>,
|
||||
r#use: bool,
|
||||
use_for_services: bool,
|
||||
recuse_use: bool,
|
||||
recuse_perms: bool,
|
||||
recurse_use: bool,
|
||||
recurse_perms: bool,
|
||||
}
|
||||
|
||||
@ -11,8 +11,8 @@ use serde::de::DeserializeOwned;
|
||||
use tokio::sync::Semaphore;
|
||||
|
||||
use crate::api::{
|
||||
BulkCreateDomainExtention, BulkDeleteDomainExtention, BulkReadDomainExtention,
|
||||
BulkUpdateDomainExtention, DomainCollection, DomainExtention, DomainObject, DomainType,
|
||||
BulkCreateDomainExtension, BulkDeleteDomainExtension, BulkReadDomainExtension,
|
||||
BulkUpdateDomainExtension, DomainCollection, DomainExtension, DomainObject, DomainType,
|
||||
};
|
||||
use crate::{Error, Result};
|
||||
|
||||
@ -26,8 +26,8 @@ pub(crate) struct InnerClient {
|
||||
|
||||
#[derive(Default, PartialEq, Eq)]
|
||||
enum SslStrategy {
|
||||
NoSll,
|
||||
IngoreHostname,
|
||||
NoSsl,
|
||||
IgnoreHostname,
|
||||
IgnoreCertificate,
|
||||
#[default]
|
||||
Strict,
|
||||
@ -96,7 +96,7 @@ pub enum ClientBuildError {
|
||||
#[error("failed to build client: {0}")]
|
||||
BuildClient(#[from] reqwest::Error),
|
||||
#[error(
|
||||
"invalid credentials. thise can only consist of visibly ASCII characters (ie. (32-127))"
|
||||
"invalid credentials. these can only consist of visible ASCII characters (i.e. (32-127))"
|
||||
)]
|
||||
InvalidCredentials(#[from] reqwest::header::InvalidHeaderValue),
|
||||
}
|
||||
@ -107,14 +107,14 @@ impl ClientBuilder<RequiresNothing> {
|
||||
self
|
||||
}
|
||||
pub fn without_ssl(mut self) -> Self {
|
||||
self.ssl = SslStrategy::NoSll;
|
||||
self.ssl = SslStrategy::NoSsl;
|
||||
self
|
||||
}
|
||||
pub fn ignore_hostname_verification(mut self) -> Self {
|
||||
self.ssl = SslStrategy::IngoreHostname;
|
||||
self.ssl = SslStrategy::IgnoreHostname;
|
||||
self
|
||||
}
|
||||
pub fn ignore_certificate_veritifcation(mut self) -> Self {
|
||||
pub fn ignore_certificate_verification(mut self) -> Self {
|
||||
self.ssl = SslStrategy::IgnoreCertificate;
|
||||
self
|
||||
}
|
||||
@ -128,7 +128,7 @@ impl ClientBuilder<RequiresNothing> {
|
||||
}
|
||||
|
||||
fn protocol(&self) -> &str {
|
||||
if self.ssl == SslStrategy::NoSll {
|
||||
if self.ssl == SslStrategy::NoSsl {
|
||||
"http"
|
||||
} else {
|
||||
"https"
|
||||
@ -137,7 +137,7 @@ impl ClientBuilder<RequiresNothing> {
|
||||
fn port(&self) -> u16 {
|
||||
if self.port != 0 {
|
||||
self.port
|
||||
} else if self.ssl == SslStrategy::NoSll {
|
||||
} else if self.ssl == SslStrategy::NoSsl {
|
||||
80
|
||||
} else {
|
||||
443
|
||||
@ -165,7 +165,7 @@ impl ClientBuilder<RequiresNothing> {
|
||||
let mut builder = reqwest::ClientBuilder::new()
|
||||
.default_headers(headers)
|
||||
.danger_accept_invalid_certs(self.ssl == SslStrategy::IgnoreCertificate)
|
||||
.danger_accept_invalid_hostnames(self.ssl == SslStrategy::IngoreHostname);
|
||||
.danger_accept_invalid_hostnames(self.ssl == SslStrategy::IgnoreHostname);
|
||||
|
||||
if let Some(sock) = self.resolve {
|
||||
builder = builder.resolve(&self.hostname, sock);
|
||||
@ -181,7 +181,7 @@ impl ClientBuilder<RequiresNothing> {
|
||||
};
|
||||
|
||||
// checkmk api struggles with more than 10 requests at a time
|
||||
// not sure if this has been inproved since 2.2
|
||||
// not sure if this has been improved since 2.2
|
||||
let semaphore = Semaphore::new(10);
|
||||
|
||||
Ok(Client(Arc::new(InnerClient {
|
||||
@ -282,7 +282,7 @@ impl InnerClient {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn create_domain_object<E: DomainExtention>(
|
||||
pub(crate) async fn create_domain_object<E: DomainExtension>(
|
||||
&self,
|
||||
body: &E::CreationRequest,
|
||||
query: &E::CreationQuery,
|
||||
@ -297,7 +297,7 @@ impl InnerClient {
|
||||
|
||||
self.invoke_api(request).await
|
||||
}
|
||||
pub(crate) async fn read_domain_object<E: DomainExtention>(
|
||||
pub(crate) async fn read_domain_object<E: DomainExtension>(
|
||||
&self,
|
||||
id: impl Display,
|
||||
query: &E::ReadQuery,
|
||||
@ -311,7 +311,7 @@ impl InnerClient {
|
||||
|
||||
self.query_api(request).await
|
||||
}
|
||||
pub(crate) async fn update_domain_object<E: DomainExtention>(
|
||||
pub(crate) async fn update_domain_object<E: DomainExtension>(
|
||||
&self,
|
||||
id: impl Display,
|
||||
request: &E::UpdateRequest,
|
||||
@ -328,7 +328,7 @@ impl InnerClient {
|
||||
|
||||
self.invoke_api(request).await
|
||||
}
|
||||
pub(crate) async fn delete_domain_object<E: DomainExtention>(
|
||||
pub(crate) async fn delete_domain_object<E: DomainExtension>(
|
||||
&self,
|
||||
id: impl Display,
|
||||
query: &E::DeleteQuery,
|
||||
@ -343,13 +343,13 @@ impl InnerClient {
|
||||
self.invoke_api(request).await
|
||||
}
|
||||
|
||||
pub(crate) async fn bulk_create_domain_objects<E: BulkCreateDomainExtention>(
|
||||
pub(crate) async fn bulk_create_domain_objects<E: BulkCreateDomainExtension>(
|
||||
&self,
|
||||
entries: &[E::CreationRequest],
|
||||
query: &E::CreationQuery,
|
||||
) -> Result<()> {
|
||||
#[derive(Serialize)]
|
||||
struct Request<'a, D: BulkCreateDomainExtention> {
|
||||
struct Request<'a, D: BulkCreateDomainExtension> {
|
||||
entries: &'a [D::CreationRequest],
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ impl InnerClient {
|
||||
|
||||
self.invoke_api(request).await
|
||||
}
|
||||
pub(crate) async fn bulk_read_domain_objects<E: BulkReadDomainExtention>(
|
||||
pub(crate) async fn bulk_read_domain_objects<E: BulkReadDomainExtension>(
|
||||
&self,
|
||||
query: &E::BulkReadQuery,
|
||||
) -> Result<Vec<DomainObject<E>>> {
|
||||
@ -377,12 +377,12 @@ impl InnerClient {
|
||||
let response: DomainCollection<E> = self.query_api(request).await?;
|
||||
Ok(response.value)
|
||||
}
|
||||
pub(crate) async fn bulk_update_domain_objects<E: BulkUpdateDomainExtention>(
|
||||
pub(crate) async fn bulk_update_domain_objects<E: BulkUpdateDomainExtension>(
|
||||
&self,
|
||||
entries: &[E::BulkUpdateRequest],
|
||||
) -> Result<()> {
|
||||
#[derive(Serialize)]
|
||||
struct Request<'a, D: BulkUpdateDomainExtention> {
|
||||
struct Request<'a, D: BulkUpdateDomainExtension> {
|
||||
entries: &'a [D::BulkUpdateRequest],
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ impl InnerClient {
|
||||
|
||||
self.invoke_api(request).await
|
||||
}
|
||||
pub(crate) async fn bulk_delete_domain_objects<E: BulkDeleteDomainExtention>(
|
||||
pub(crate) async fn bulk_delete_domain_objects<E: BulkDeleteDomainExtension>(
|
||||
&self,
|
||||
entries: &[String],
|
||||
) -> Result<()> {
|
||||
@ -433,12 +433,12 @@ impl Display for BulkAction {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ApiClient<D: DomainExtention> {
|
||||
pub struct ApiClient<D: DomainExtension> {
|
||||
pub(crate) inner: Arc<InnerClient>,
|
||||
_marker: PhantomData<D>,
|
||||
}
|
||||
|
||||
impl<D: DomainExtention> From<&Client> for ApiClient<D> {
|
||||
impl<D: DomainExtension> From<&Client> for ApiClient<D> {
|
||||
fn from(value: &Client) -> Self {
|
||||
Self {
|
||||
inner: value.0.clone(),
|
||||
@ -447,7 +447,7 @@ impl<D: DomainExtention> From<&Client> for ApiClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: DomainExtention> ApiClient<D> {
|
||||
impl<D: DomainExtension> ApiClient<D> {
|
||||
pub async fn create(
|
||||
&self,
|
||||
request: &D::CreationRequest,
|
||||
@ -469,7 +469,7 @@ impl<D: DomainExtention> ApiClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: BulkCreateDomainExtention> ApiClient<D> {
|
||||
impl<D: BulkCreateDomainExtension> ApiClient<D> {
|
||||
pub async fn bulk_create(
|
||||
&self,
|
||||
request: &[D::CreationRequest],
|
||||
@ -481,7 +481,7 @@ impl<D: BulkCreateDomainExtention> ApiClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: BulkReadDomainExtention> ApiClient<D> {
|
||||
impl<D: BulkReadDomainExtension> ApiClient<D> {
|
||||
pub async fn bulk_read(&self, query: &D::BulkReadQuery) -> Result<Vec<D>> {
|
||||
let objs = self.inner.bulk_read_domain_objects::<D>(query).await?;
|
||||
let exts = objs.into_iter().map(|obj| obj.extensions).collect();
|
||||
@ -489,13 +489,13 @@ impl<D: BulkReadDomainExtention> ApiClient<D> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: BulkUpdateDomainExtention> ApiClient<D> {
|
||||
impl<D: BulkUpdateDomainExtension> ApiClient<D> {
|
||||
pub async fn bulk_update(&self, entries: &[D::BulkUpdateRequest]) -> Result<()> {
|
||||
self.inner.bulk_update_domain_objects::<D>(entries).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: BulkDeleteDomainExtention> ApiClient<D> {
|
||||
impl<D: BulkDeleteDomainExtension> ApiClient<D> {
|
||||
pub async fn bulk_delete(&self, ids: &[String]) -> Result<()> {
|
||||
self.inner.bulk_delete_domain_objects::<D>(ids).await
|
||||
}
|
||||
|
||||
@ -15,14 +15,14 @@ pub enum Error {
|
||||
#[error(
|
||||
"Failed to send request: {}: {}", .0,
|
||||
.0.cause().map(|e| e.to_string())
|
||||
.unwrap_or_else(|| "Uknown Cause".to_string())
|
||||
.unwrap_or_else(|| "Unknown Cause".to_string())
|
||||
)]
|
||||
SendRequest(#[source] reqwest::Error),
|
||||
#[error("Failed to receive response-body: {0}")]
|
||||
ReceiveBody(#[source] reqwest::Error),
|
||||
#[error("Failed to deserialize response: {0}")]
|
||||
DeserializeResponse(#[source] serde_json::Error),
|
||||
#[error("Recieved an error from checkmk ({}): {}", .0.status, .0.detail)]
|
||||
#[error("Received an error from checkmk ({}): {}", .0.status, .0.detail)]
|
||||
CheckmkError(#[source] CheckmkError),
|
||||
|
||||
#[error("Checkmk site has not yet started. log in as site user and execute 'omd start'")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user