Skip to main content

apify_client/clients/
actor_env_var_collection.rs

1//! Client for an Actor version's environment variable collection.
2
3use crate::clients::base::{create_resource, list_resource, ResourceContext};
4use crate::common::{PaginationList, QueryParams};
5use crate::error::ApifyClientResult;
6use crate::http_client::HttpClient;
7use crate::models::ActorEnvVar;
8
9/// Client for listing and creating environment variables of an Actor version.
10#[derive(Debug, Clone)]
11pub struct ActorEnvVarCollectionClient {
12    ctx: ResourceContext,
13}
14
15impl ActorEnvVarCollectionClient {
16    pub(crate) fn new(http: HttpClient, base_url: &str) -> Self {
17        Self {
18            ctx: ResourceContext::collection(http, base_url, "env-vars"),
19        }
20    }
21
22    /// Lists the environment variables of the Actor version.
23    pub async fn list(&self) -> ApifyClientResult<PaginationList<ActorEnvVar>> {
24        list_resource(&self.ctx, None, &QueryParams::new()).await
25    }
26
27    /// Creates a new environment variable.
28    pub async fn create(&self, env_var: &ActorEnvVar) -> ApifyClientResult<ActorEnvVar> {
29        create_resource(&self.ctx, &QueryParams::new(), env_var).await
30    }
31}