use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct SchemaValidationListSchemasPaginated<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
omit_source: Result<bool, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
validation_enabled: Result<bool, String>,
}
impl<'a> SchemaValidationListSchemasPaginated<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
omit_source: Err("omit_source was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
validation_enabled: Err("validation_enabled was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn omit_source<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.omit_source = value
.try_into()
.map_err(|_| "conversion to `bool` for omit_source failed".to_string());
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub fn validation_enabled<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.validation_enabled = value
.try_into()
.map_err(|_| "conversion to `bool` for validation_enabled failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
omit_source,
page,
per_page,
validation_enabled,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let omit_source = omit_source.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let validation_enabled = validation_enabled.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/schemas",
client.baseurl,
encode_path(&zone_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new(
"omit_source",
&omit_source,
))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new(
"validation_enabled",
&validation_enabled,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_list_schemas_paginated",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationCreateSchema<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<types::builder::SchemaValidationCreateSchemaBody, String>,
}
impl<'a> SchemaValidationCreateSchema<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::SchemaValidationCreateSchemaBody>,
<V as std::convert::TryInto<types::SchemaValidationCreateSchemaBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `SchemaValidationCreateSchemaBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::SchemaValidationCreateSchemaBody,
) -> types::builder::SchemaValidationCreateSchemaBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::SchemaValidationCreateSchemaBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/schemas",
client.baseurl,
encode_path(&zone_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_create_schema",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationGetSchema<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
schema_id: Result<::uuid::Uuid, String>,
omit_source: Result<bool, String>,
}
impl<'a> SchemaValidationGetSchema<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
schema_id: Err("schema_id was not initialized".to_string()),
omit_source: Err("omit_source was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn schema_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.schema_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for schema_id failed".to_string());
self
}
pub fn omit_source<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.omit_source = value
.try_into()
.map_err(|_| "conversion to `bool` for omit_source failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
schema_id,
omit_source,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let schema_id = schema_id.map_err(Error::InvalidRequest)?;
let omit_source = omit_source.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/schemas/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&schema_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new(
"omit_source",
&omit_source,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_get_schema",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationDeleteSchema<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
schema_id: Result<::uuid::Uuid, String>,
}
impl<'a> SchemaValidationDeleteSchema<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
schema_id: Err("schema_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn schema_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.schema_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for schema_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
schema_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let schema_id = schema_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/schemas/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&schema_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_delete_schema",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationEditSchema<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
schema_id: Result<::uuid::Uuid, String>,
body: Result<types::builder::SchemaValidationEditSchemaBody, String>,
}
impl<'a> SchemaValidationEditSchema<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
schema_id: Err("schema_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn schema_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.schema_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for schema_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::SchemaValidationEditSchemaBody>,
<V as std::convert::TryInto<types::SchemaValidationEditSchemaBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `SchemaValidationEditSchemaBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::SchemaValidationEditSchemaBody,
) -> types::builder::SchemaValidationEditSchemaBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
schema_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let schema_id = schema_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::SchemaValidationEditSchemaBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/schemas/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&schema_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_edit_schema",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationExtractOperationsFromSchema<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
schema_id: Result<::uuid::Uuid, String>,
endpoint: Result<::std::string::String, String>,
feature: Result<Vec<types::SchemaValidationExtractOperationsFromSchemaFeatureItem>, String>,
host: Result<Vec<::std::string::String>, String>,
method: Result<Vec<::std::string::String>, String>,
operation_status:
Result<types::SchemaValidationExtractOperationsFromSchemaOperationStatus, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
}
impl<'a> SchemaValidationExtractOperationsFromSchema<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
schema_id: Err("schema_id was not initialized".to_string()),
endpoint: Err("endpoint was not initialized".to_string()),
feature: Err("feature was not initialized".to_string()),
host: Err("host was not initialized".to_string()),
method: Err("method was not initialized".to_string()),
operation_status: Err("operation_status was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn schema_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.schema_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for schema_id failed".to_string());
self
}
pub fn endpoint<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.endpoint = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for endpoint failed".to_string()
});
self
}
pub fn feature<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<
Vec<types::SchemaValidationExtractOperationsFromSchemaFeatureItem>,
>,
{
self . feature = value . try_into () . map_err (| _ | "conversion to `Vec < SchemaValidationExtractOperationsFromSchemaFeatureItem >` for feature failed" . to_string ()) ;
self
}
pub fn host<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<Vec<::std::string::String>>,
{
self.host = value.try_into().map_err(|_| {
"conversion to `Vec < :: std :: string :: String >` for host failed".to_string()
});
self
}
pub fn method<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<Vec<::std::string::String>>,
{
self.method = value.try_into().map_err(|_| {
"conversion to `Vec < :: std :: string :: String >` for method failed".to_string()
});
self
}
pub fn operation_status<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<
types::SchemaValidationExtractOperationsFromSchemaOperationStatus,
>,
{
self . operation_status = value . try_into () . map_err (| _ | "conversion to `SchemaValidationExtractOperationsFromSchemaOperationStatus` for operation_status failed" . to_string ()) ;
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
schema_id,
endpoint,
feature,
host,
method,
operation_status,
page,
per_page,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let schema_id = schema_id.map_err(Error::InvalidRequest)?;
let endpoint = endpoint.map_err(Error::InvalidRequest)?;
let feature = feature.map_err(Error::InvalidRequest)?;
let host = host.map_err(Error::InvalidRequest)?;
let method = method.map_err(Error::InvalidRequest)?;
let operation_status = operation_status.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/schemas/{}/operations",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&schema_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("endpoint", &endpoint))
.query(&progenitor_client::QueryParam::new("feature", &feature))
.query(&progenitor_client::QueryParam::new("host", &host))
.query(&progenitor_client::QueryParam::new("method", &method))
.query(&progenitor_client::QueryParam::new(
"operation_status",
&operation_status,
))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_extract_operations_from_schema",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationListSchemaHosts<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
}
impl<'a> SchemaValidationListSchemaHosts<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
page,
per_page,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/schemas/hosts",
client.baseurl,
encode_path(&zone_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_list_schema_hosts",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationGetSettings<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
}
impl<'a> SchemaValidationGetSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, zone_id } = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/settings",
client.baseurl,
encode_path(&zone_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_get_settings",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationUpdateSettings<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<types::builder::SchemaValidationUpdateSettingsBody, String>,
}
impl<'a> SchemaValidationUpdateSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::SchemaValidationUpdateSettingsBody>,
<V as std::convert::TryInto<types::SchemaValidationUpdateSettingsBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `SchemaValidationUpdateSettingsBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::SchemaValidationUpdateSettingsBody,
) -> types::builder::SchemaValidationUpdateSettingsBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::SchemaValidationUpdateSettingsBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/settings",
client.baseurl,
encode_path(&zone_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_update_settings",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationEditSettings<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<types::builder::ApiShieldGlobalSettingChangeBase, String>,
}
impl<'a> SchemaValidationEditSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldGlobalSettingChangeBase>,
<V as std::convert::TryInto<types::ApiShieldGlobalSettingChangeBase>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ApiShieldGlobalSettingChangeBase` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldGlobalSettingChangeBase,
) -> types::builder::ApiShieldGlobalSettingChangeBase,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::ApiShieldGlobalSettingChangeBase::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/settings",
client.baseurl,
encode_path(&zone_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_edit_settings",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationListPerOperationSettings<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
}
impl<'a> SchemaValidationListPerOperationSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU64>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU64` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
page,
per_page,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/settings/operations",
client.baseurl,
encode_path(&zone_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_list_per_operation_settings",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationGetPerOperationSetting<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
operation_id: Result<types::ApiShieldUuid, String>,
}
impl<'a> SchemaValidationGetPerOperationSetting<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
operation_id: Err("operation_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn operation_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldUuid>,
{
self.operation_id = value
.try_into()
.map_err(|_| "conversion to `ApiShieldUuid` for operation_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
operation_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let operation_id = operation_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/settings/operations/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&operation_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_get_per_operation_setting",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationUpdatePerOperationSetting<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
operation_id: Result<types::ApiShieldUuid, String>,
body: Result<types::builder::SchemaValidationUpdatePerOperationSettingBody, String>,
}
impl<'a> SchemaValidationUpdatePerOperationSetting<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
operation_id: Err("operation_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn operation_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldUuid>,
{
self.operation_id = value
.try_into()
.map_err(|_| "conversion to `ApiShieldUuid` for operation_id failed".to_string());
self
} pub fn body < V > (mut self , value : V) -> Self where V : std :: convert :: TryInto < types :: SchemaValidationUpdatePerOperationSettingBody > , < V as std :: convert :: TryInto < types :: SchemaValidationUpdatePerOperationSettingBody >> :: Error : std :: fmt :: Display ,{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `SchemaValidationUpdatePerOperationSettingBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::SchemaValidationUpdatePerOperationSettingBody,
)
-> types::builder::SchemaValidationUpdatePerOperationSettingBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
operation_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let operation_id = operation_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::SchemaValidationUpdatePerOperationSettingBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/settings/operations/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&operation_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_update_per_operation_setting",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SchemaValidationDeletePerOperationSetting<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
operation_id: Result<types::ApiShieldUuid, String>,
}
impl<'a> SchemaValidationDeletePerOperationSetting<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
operation_id: Err("operation_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn operation_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldUuid>,
{
self.operation_id = value
.try_into()
.map_err(|_| "conversion to `ApiShieldUuid` for operation_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
operation_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let operation_id = operation_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/schema_validation/settings/operations/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&operation_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "schema_validation_delete_per_operation_setting",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}