Skip to main content

alien_core/bindings/
container_apps_environment.rs

1//! Azure Container Apps Environment binding definition for pre-existing environments.
2
3use super::BindingValue;
4use serde::{Deserialize, Serialize};
5
6/// Binding configuration for a pre-existing Azure Container Apps Environment.
7///
8/// Used when deploying to an existing environment instead of having Alien provision one.
9/// This is useful for shared environments (e.g., test infrastructure) or enterprise
10/// setups where environments are managed by a separate team.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
12#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
13#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
14#[serde(rename_all = "camelCase")]
15pub struct ContainerAppsEnvironmentBinding {
16    /// The name of the Container Apps Environment in Azure.
17    pub environment_name: BindingValue<String>,
18    /// The full Azure resource ID of the environment.
19    pub resource_id: BindingValue<String>,
20    /// The Azure resource group that contains the environment.
21    /// Stored explicitly so consumers don't need to parse the ARM resource ID path.
22    pub resource_group_name: BindingValue<String>,
23    /// The default domain for applications in this environment.
24    pub default_domain: BindingValue<String>,
25    /// The static IP address of the environment (if applicable).
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub static_ip: Option<BindingValue<String>>,
28}
29
30impl ContainerAppsEnvironmentBinding {
31    /// Creates a new Container Apps Environment binding with required fields.
32    pub fn new(
33        environment_name: impl Into<BindingValue<String>>,
34        resource_id: impl Into<BindingValue<String>>,
35        resource_group_name: impl Into<BindingValue<String>>,
36        default_domain: impl Into<BindingValue<String>>,
37    ) -> Self {
38        Self {
39            environment_name: environment_name.into(),
40            resource_id: resource_id.into(),
41            resource_group_name: resource_group_name.into(),
42            default_domain: default_domain.into(),
43            static_ip: None,
44        }
45    }
46
47    /// Sets the static IP address.
48    pub fn with_static_ip(mut self, static_ip: impl Into<BindingValue<String>>) -> Self {
49        self.static_ip = Some(static_ip.into());
50        self
51    }
52}