apify_client/clients/
key_value_store_collection.rs1use crate::clients::base::{get_or_create_named, list_resource, ResourceContext};
4use crate::clients::pagination::{list_iterator, ListIterator};
5use crate::common::{PaginationList, QueryParams, StorageListOptions};
6use crate::error::ApifyClientResult;
7use crate::http_client::HttpClient;
8use crate::models::KeyValueStore;
9
10#[derive(Debug, Clone)]
12pub struct KeyValueStoreCollectionClient {
13 ctx: ResourceContext,
14}
15
16impl KeyValueStoreCollectionClient {
17 pub(crate) fn new(http: HttpClient, base_url: &str) -> Self {
18 Self {
19 ctx: ResourceContext::collection(http, base_url, "key-value-stores"),
20 }
21 }
22
23 pub async fn list(
26 &self,
27 options: StorageListOptions,
28 ) -> ApifyClientResult<PaginationList<KeyValueStore>> {
29 let mut params = QueryParams::new();
30 options.apply(&mut params);
31 list_resource(&self.ctx, None, ¶ms).await
32 }
33
34 pub fn iterate(&self, options: StorageListOptions) -> ListIterator<KeyValueStore> {
41 list_iterator!(self, options, list)
42 }
43
44 pub async fn get_or_create(&self, name: Option<&str>) -> ApifyClientResult<KeyValueStore> {
46 get_or_create_named(&self.ctx, name).await
47 }
48}