use surf::http::Method;
use super::WorkersTail;
use crate::framework::endpoint::Endpoint;
#[derive(Debug)]
pub struct CreateTail<'a> {
pub account_identifier: &'a str,
pub script_name: &'a str,
pub params: CreateTailParams,
}
impl<'a> Endpoint<WorkersTail, (), CreateTailParams> for CreateTail<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!(
"accounts/{}/workers/scripts/{}/tails",
self.account_identifier, self.script_name
)
}
fn body(&self) -> Option<CreateTailParams> {
if self.params.url.is_some() {
Some(self.params.clone())
} else {
None
}
}
}
#[derive(Serialize, Clone, Debug, Default)]
pub struct CreateTailParams {
pub url: Option<String>,
}