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