use surf::http::Method;
use crate::framework::endpoint::Endpoint;
use crate::framework::json_utils::serialize_base64_str;
use super::Tunnel;
#[derive(Debug)]
pub struct CreateTunnel<'a> {
pub account_identifier: &'a str,
pub params: Params<'a>,
}
impl<'a> Endpoint<Tunnel, (), Params<'a>> for CreateTunnel<'a> {
fn method(&self) -> Method {
Method::Post
}
fn path(&self) -> String {
format!("accounts/{}/tunnels", self.account_identifier)
}
fn body(&self) -> Option<Params<'a>> {
Some(self.params.clone())
}
}
#[serde_with::skip_serializing_none]
#[derive(Serialize, Clone, Debug)]
pub struct Params<'a> {
pub name: &'a str,
#[serde(serialize_with = "serialize_base64_str")]
pub tunnel_secret: &'a Vec<u8>,
pub metadata: Option<serde_json::Value>,
}