cloudflare_but_works/endpoints/workers/
create_secret.rs1use super::WorkersSecret;
2
3use crate::framework::endpoint::{EndpointSpec, Method, RequestBody};
4
5use crate::framework::response::ApiSuccess;
6use serde::Serialize;
7
8#[derive(Debug)]
11pub struct CreateSecret<'a> {
12 pub account_identifier: &'a str,
14 pub script_name: &'a str,
16 pub params: CreateSecretParams,
18}
19
20impl EndpointSpec for CreateSecret<'_> {
21 type JsonResponse = WorkersSecret;
22 type ResponseType = ApiSuccess<Self::JsonResponse>;
23
24 fn method(&self) -> Method {
25 Method::PUT
26 }
27 fn path(&self) -> String {
28 format!(
29 "accounts/{}/workers/scripts/{}/secrets",
30 self.account_identifier, self.script_name
31 )
32 }
33 #[inline]
34 fn body(&self) -> Option<RequestBody> {
35 let body = serde_json::to_string(&self.params).unwrap();
36 Some(RequestBody::Json(body))
37 }
38}
39
40#[derive(Serialize, Clone, Debug)]
41pub struct CreateSecretParams {
42 pub name: String,
44 pub text: String,
46 #[serde(rename = "type")]
48 pub secret_type: String,
49}