Skip to main content

apify_client/clients/
actor_env_var.rs

1//! Client for a single Actor-version environment variable.
2
3use crate::clients::base::{delete_resource, get_resource, update_resource, ResourceContext};
4use crate::common::QueryParams;
5use crate::error::ApifyClientResult;
6use crate::http_client::HttpClient;
7use crate::models::ActorEnvVar;
8
9/// Client for a specific environment variable of an Actor version.
10#[derive(Debug, Clone)]
11pub struct ActorEnvVarClient {
12    ctx: ResourceContext,
13}
14
15impl ActorEnvVarClient {
16    pub(crate) fn new(http: HttpClient, base_url: &str, name: &str) -> Self {
17        Self {
18            ctx: ResourceContext::single(http, base_url, "env-vars", name),
19        }
20    }
21
22    /// Fetches the environment variable, or `None` if it does not exist.
23    pub async fn get(&self) -> ApifyClientResult<Option<ActorEnvVar>> {
24        get_resource(&self.ctx, None, &QueryParams::new()).await
25    }
26
27    /// Updates the environment variable.
28    pub async fn update(&self, env_var: &ActorEnvVar) -> ApifyClientResult<ActorEnvVar> {
29        update_resource(&self.ctx, None, env_var).await
30    }
31
32    /// Deletes the environment variable.
33    pub async fn delete(&self) -> ApifyClientResult<()> {
34        delete_resource(&self.ctx, None).await
35    }
36}