use greentic_deploy_spec::{
BundleId, Environment, EnvironmentHostConfig, MessagingEndpoint, MessagingEndpointId,
SchemaVersion,
};
use greentic_types::EnvId;
pub(crate) fn env_id() -> EnvId {
EnvId::try_from("local").unwrap()
}
pub(crate) fn endpoint(provider_id: &str, bundles: &[&str]) -> MessagingEndpoint {
endpoint_typed("teams", provider_id, bundles)
}
pub(crate) fn endpoint_typed(
provider_type: &str,
provider_id: &str,
bundles: &[&str],
) -> MessagingEndpoint {
let now = chrono::Utc::now();
MessagingEndpoint {
schema: SchemaVersion::new(SchemaVersion::MESSAGING_ENDPOINT_V1),
env_id: env_id(),
endpoint_id: MessagingEndpointId::new(),
provider_id: provider_id.to_string(),
provider_type: provider_type.to_string(),
display_name: provider_id.to_string(),
secret_refs: Vec::new(),
linked_bundles: bundles.iter().map(|b| BundleId::new(*b)).collect(),
welcome_flow: None,
generation: 1,
created_at: now,
updated_at: now,
updated_by: "test".to_string(),
}
}
pub(crate) fn env_with(endpoints: Vec<MessagingEndpoint>) -> Environment {
Environment {
schema: SchemaVersion::new(SchemaVersion::ENVIRONMENT_V1),
environment_id: env_id(),
name: "local".to_string(),
host_config: EnvironmentHostConfig {
env_id: env_id(),
region: None,
tenant_org_id: None,
listen_addr: None,
},
packs: Vec::new(),
messaging_endpoints: endpoints,
extensions: Vec::new(),
credentials_ref: None,
bundles: Vec::new(),
revisions: Vec::new(),
traffic_splits: Vec::new(),
revocation: Default::default(),
retention: Default::default(),
health: Default::default(),
}
}