use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct ApiShieldSettingsSetConfigurationProperties<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
normalize: Result<Option<bool>, String>,
body: Result<types::builder::ApiShieldConfiguration, String>,
}
impl<'a> ApiShieldSettingsSetConfigurationProperties<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
normalize: Ok(None),
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 normalize<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.normalize = value
.try_into()
.map(Some)
.map_err(|_| "conversion to `bool` for normalize failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldConfiguration>,
<V as std::convert::TryInto<types::ApiShieldConfiguration>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ApiShieldConfiguration` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldConfiguration,
) -> types::builder::ApiShieldConfiguration,
{
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,
normalize,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let normalize = normalize.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::ApiShieldConfiguration::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/api_gateway/configuration",
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)
.query(&progenitor_client::QueryParam::new("normalize", &normalize))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "api_shield_settings_set_configuration_properties",
};
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 ApiShieldApiPatchDiscoveredOperations<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<types::ApiShieldApiDiscoveryPatchMultipleRequest, String>,
}
impl<'a> ApiShieldApiPatchDiscoveredOperations<'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<types::ApiShieldApiDiscoveryPatchMultipleRequest>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `ApiShieldApiDiscoveryPatchMultipleRequest` 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/{}/api_gateway/discovery/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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "api_shield_api_patch_discovered_operations",
};
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 ApiShieldApiPatchDiscoveredOperation<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
operation_id: Result<types::ApiShieldSchemasUuid, String>,
body: Result<types::builder::ApiShieldApiPatchDiscoveredOperationBody, String>,
}
impl<'a> ApiShieldApiPatchDiscoveredOperation<'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::ApiShieldSchemasUuid>,
{
self.operation_id = value.try_into().map_err(|_| {
"conversion to `ApiShieldSchemasUuid` for operation_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ApiShieldApiPatchDiscoveredOperationBody>,
<V as std::convert::TryInto<types::ApiShieldApiPatchDiscoveredOperationBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ApiShieldApiPatchDiscoveredOperationBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldApiPatchDiscoveredOperationBody,
)
-> types::builder::ApiShieldApiPatchDiscoveredOperationBody,
{
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::ApiShieldApiPatchDiscoveredOperationBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/api_gateway/discovery/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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "api_shield_api_patch_discovered_operation",
};
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 ApiShieldExpressionTemplatesFallthrough<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<types::builder::ApiShieldRequestExpressionTemplatesFallthrough, String>,
}
impl<'a> ApiShieldExpressionTemplatesFallthrough<'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 :: ApiShieldRequestExpressionTemplatesFallthrough > , < V as std :: convert :: TryInto < types :: ApiShieldRequestExpressionTemplatesFallthrough >> :: Error : std :: fmt :: Display ,{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `ApiShieldRequestExpressionTemplatesFallthrough` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldRequestExpressionTemplatesFallthrough,
)
-> types::builder::ApiShieldRequestExpressionTemplatesFallthrough,
{
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::ApiShieldRequestExpressionTemplatesFallthrough::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/api_gateway/expression-template/fallthrough",
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: "api_shield_expression_templates_fallthrough",
};
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 ApiShieldSchemaValidationPostSchema<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
body: Result<types::builder::ApiShieldSchemaValidationPostSchemaBody, String>,
}
impl<'a> ApiShieldSchemaValidationPostSchema<'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::ApiShieldSchemaValidationPostSchemaBody>,
<V as std::convert::TryInto<types::ApiShieldSchemaValidationPostSchemaBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ApiShieldSchemaValidationPostSchemaBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ApiShieldSchemaValidationPostSchemaBody,
)
-> types::builder::ApiShieldSchemaValidationPostSchemaBody,
{
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::ApiShieldSchemaValidationPostSchemaBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/api_gateway/user_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: "api_shield_schema_validation_post_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 ApiShieldSchemaDeleteASchema<'a> {
client: &'a crate::Client,
zone_id: Result<types::ApiShieldSchemasIdentifier, String>,
schema_id: Result<::uuid::Uuid, String>,
}
impl<'a> ApiShieldSchemaDeleteASchema<'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/{}/api_gateway/user_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: "api_shield_schema_delete_a_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)),
}
}
}