use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct TokenValidationConfigGet<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
config_id: Result<types::ApiShieldSchemasUuid, String>,
}
impl<'a> TokenValidationConfigGet<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
config_id: Err("config_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 config_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasUuid>,
{
self.config_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasUuid` for config_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,
config_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let config_id = config_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/config/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&config_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: "token_validation_config_get",
};
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 TokenValidationConfigDelete<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
config_id: Result<types::ApiShieldSchemasUuid, String>,
}
impl<'a> TokenValidationConfigDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
config_id: Err("config_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 config_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasUuid>,
{
self.config_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasUuid` for config_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,
config_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let config_id = config_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/config/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&config_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: "token_validation_config_delete",
};
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 TokenValidationConfigEdit<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
config_id: Result<types::ApiShieldSchemasUuid, String>,
body: Result<types::builder::TokenValidationConfigEditBody, String>,
}
impl<'a> TokenValidationConfigEdit<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
config_id: Err("config_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 config_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasUuid>,
{
self.config_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasUuid` for config_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TokenValidationConfigEditBody>,
<V as std::convert::TryInto<types::TokenValidationConfigEditBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `TokenValidationConfigEditBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::TokenValidationConfigEditBody,
) -> types::builder::TokenValidationConfigEditBody,
{
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,
config_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let config_id = config_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::TokenValidationConfigEditBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/config/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&config_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: "token_validation_config_edit",
};
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 TokenValidationConfigCredentialsUpdate<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
config_id: Result<types::ApiShieldSchemasUuid, String>,
body: Result<types::builder::ApiShieldCredentials, String>,
}
impl<'a> TokenValidationConfigCredentialsUpdate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
config_id: Err("config_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 config_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasUuid>,
{
self.config_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasUuid` for config_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldCredentials>,
<V as std::convert::TryInto<types::ApiShieldCredentials>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ApiShieldCredentials` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldCredentials,
) -> types::builder::ApiShieldCredentials,
{
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,
config_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let config_id = config_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::ApiShieldCredentials::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/config/{}/credentials",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&config_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: "token_validation_config_credentials_update",
};
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 TokenValidationRulesGet<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
rule_id: Result<types::ApiShieldSchemasUuid, String>,
}
impl<'a> TokenValidationRulesGet<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
rule_id: Err("rule_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 rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasUuid>,
{
self.rule_id = value
.try_into()
.map_err(|_| "conversion to `ApiShieldSchemasUuid` for rule_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,
rule_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&rule_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: "token_validation_rules_get",
};
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 TokenValidationRulesDelete<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
rule_id: Result<types::ApiShieldSchemasUuid, String>,
}
impl<'a> TokenValidationRulesDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
rule_id: Err("rule_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 rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasUuid>,
{
self.rule_id = value
.try_into()
.map_err(|_| "conversion to `ApiShieldSchemasUuid` for rule_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,
rule_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&rule_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: "token_validation_rules_delete",
};
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 TokenValidationRulesEdit<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
rule_id: Result<types::ApiShieldSchemasUuid, String>,
body: Result<types::builder::ApiShieldEditSingleRuleRequest, String>,
}
impl<'a> TokenValidationRulesEdit<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
rule_id: Err("rule_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 rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSchemasUuid>,
{
self.rule_id = value
.try_into()
.map_err(|_| "conversion to `ApiShieldSchemasUuid` for rule_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldEditSingleRuleRequest>,
<V as std::convert::TryInto<types::ApiShieldEditSingleRuleRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ApiShieldEditSingleRuleRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldEditSingleRuleRequest,
) -> types::builder::ApiShieldEditSingleRuleRequest,
{
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,
rule_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::ApiShieldEditSingleRuleRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&rule_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: "token_validation_rules_edit",
};
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 TokenValidationRulesBulkCreate<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<::std::vec::Vec<types::ApiShieldCreateSingleRuleRequest>, String>,
}
impl<'a> TokenValidationRulesBulkCreate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
body: Err("body 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 body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::ApiShieldCreateSingleRuleRequest>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < ApiShieldCreateSingleRuleRequest >` for body 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,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/rules/bulk",
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: "token_validation_rules_bulk_create",
};
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 TokenValidationRulesBulkEdit<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<::std::vec::Vec<types::TokenValidationRulesBulkEditBodyItem>, String>,
}
impl<'a> TokenValidationRulesBulkEdit<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
body: Err("body 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 body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::TokenValidationRulesBulkEditBodyItem>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < TokenValidationRulesBulkEditBodyItem >` for body 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,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/rules/bulk",
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: "token_validation_rules_bulk_edit",
};
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 TokenValidationRulesPreview<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
endpoint: Result<::std::vec::Vec<types::ApiShieldEndpoint>, String>,
host: Result<::std::vec::Vec<types::ApiShieldHost>, String>,
hostname: Result<::std::vec::Vec<types::ApiShieldHost>, String>,
method: Result<::std::vec::Vec<types::ApiShieldMethod>, String>,
page: Result<::std::num::NonZeroU64, String>,
per_page: Result<i64, String>,
state: Result<::std::vec::Vec<types::ApiShieldSelectorOperationState>, String>,
body: Result<types::builder::ApiShieldSelector, String>,
}
impl<'a> TokenValidationRulesPreview<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
endpoint: Err("endpoint was not initialized".to_string()),
host: Err("host was not initialized".to_string()),
hostname: Err("hostname was not initialized".to_string()),
method: Err("method was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
state: Err("state 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 endpoint<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::ApiShieldEndpoint>>,
{
self.endpoint = value.try_into().map_err(|_| {
"conversion to `:: std :: vec :: Vec < ApiShieldEndpoint >` for endpoint failed"
.to_string()
});
self
}
pub fn host<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::ApiShieldHost>>,
{
self.host = value.try_into().map_err(|_| {
"conversion to `:: std :: vec :: Vec < ApiShieldHost >` for host failed".to_string()
});
self
}
pub fn hostname<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::ApiShieldHost>>,
{
self.hostname = value.try_into().map_err(|_| {
"conversion to `:: std :: vec :: Vec < ApiShieldHost >` for hostname failed"
.to_string()
});
self
}
pub fn method<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::ApiShieldMethod>>,
{
self.method = value.try_into().map_err(|_| {
"conversion to `:: std :: vec :: Vec < ApiShieldMethod >` for method 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 state<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::ApiShieldSelectorOperationState>>,
{
self . state = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < ApiShieldSelectorOperationState >` for state failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldSelector>,
<V as std::convert::TryInto<types::ApiShieldSelector>>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `ApiShieldSelector` for body failed: {}", s));
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldSelector,
) -> types::builder::ApiShieldSelector,
{
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,
endpoint,
host,
hostname,
method,
page,
per_page,
state,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let endpoint = endpoint.map_err(Error::InvalidRequest)?;
let host = host.map_err(Error::InvalidRequest)?;
let hostname = hostname.map_err(Error::InvalidRequest)?;
let method = method.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let state = state.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::ApiShieldSelector::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/token_validation/rules/preview",
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)
.query(&progenitor_client::QueryParam::new("endpoint", &endpoint))
.query(&progenitor_client::QueryParam::new("host", &host))
.query(&progenitor_client::QueryParam::new("hostname", &hostname))
.query(&progenitor_client::QueryParam::new("method", &method))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("state", &state))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "token_validation_rules_preview",
};
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)),
}
}
}