use surf::http::Method;
use crate::endpoints::load_balancing::{Origin, Pool};
use crate::framework::endpoint::Endpoint;
#[derive(Debug)]
pub struct CreatePool<'a> {
pub account_identifier: &'a str,
pub params: Params<'a>,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
pub struct Params<'a> {
pub name: &'a str,
pub origins: &'a [Origin],
#[serde(flatten)]
pub optional_params: Option<OptionalParams<'a>>,
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug, Default)]
pub struct OptionalParams<'a> {
pub description: Option<&'a str>,
pub enabled: Option<bool>,
pub minimum_origins: Option<u8>,
pub monitor: Option<&'a str>,
pub notification_email: Option<&'a str>,
}
impl<'a> Endpoint<Pool, (), Params<'a>> for CreatePool<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("accounts/{}/load_balancers/pools", self.account_identifier)
}
fn body(&self) -> Option<Params<'a>> {
Some(self.params.clone())
}
}