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