cloudflare/endpoints/workerskv/
delete_bulk.rs

1use surf::http::Method;
2
3use crate::framework::endpoint::Endpoint;
4
5/// Delete Key-Value Pairs in Bulk
6/// Deletes multiple key-value pairs from Workers KV at once.
7/// A 404 is returned if a delete action is for a namespace ID the account doesn't have.
8/// https://api.cloudflare.com/#workers-kv-namespace-delete-multiple-key-value-pairs
9#[derive(Debug)]
10pub struct DeleteBulk<'a> {
11    pub account_identifier: &'a str,
12    pub namespace_identifier: &'a str,
13    pub bulk_keys: Vec<String>,
14}
15
16impl<'a> Endpoint<(), (), Vec<String>> for DeleteBulk<'a> {
17    fn method(&self) -> Method {
18        Method::Delete
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<String>> {
27        Some(self.bulk_keys.clone())
28    }
29    // default content-type is already application/json
30}