cloudflare/endpoints/workerskv/
write_bulk.rs1use surf::http::Method;
2
3use crate::framework::endpoint::Endpoint;
4
5#[derive(Debug)]
10pub struct WriteBulk<'a> {
11 pub account_identifier: &'a str,
12 pub namespace_identifier: &'a str,
13 pub bulk_key_value_pairs: Vec<KeyValuePair>,
14}
15
16impl<'a> Endpoint<(), (), Vec<KeyValuePair>> for WriteBulk<'a> {
17 fn method(&self) -> Method {
18 Method::Put
19 }
20 fn path(&self) -> String {
21 format!(
22 "accounts/{}/storage/kv/namespaces/{}/bulk",
23 self.account_identifier, self.namespace_identifier
24 )
25 }
26 fn body(&self) -> Option<Vec<KeyValuePair>> {
27 Some(self.bulk_key_value_pairs.clone())
28 }
29 }
31
32#[serde_with::skip_serializing_none]
33#[derive(Serialize, Deserialize, Clone, Debug)]
34pub struct KeyValuePair {
35 pub key: String,
36 pub value: String,
37 pub expiration: Option<i64>,
38 pub expiration_ttl: Option<i64>,
39 pub base64: Option<bool>,
40}