agent_orchestrator/resource/
mod.rs1use crate::cli_types::ResourceKind;
2use crate::config::OrchestratorConfig;
3use anyhow::Result;
4
5pub(crate) const API_VERSION: &str = "orchestrator.dev/v2";
6
7pub(crate) mod agent;
10mod env_store;
11pub(crate) mod execution_profile;
12mod export;
13mod parse;
14mod project;
15pub(crate) mod runtime_policy;
16mod secret_store;
17mod step_template;
18mod trigger;
19pub(crate) mod workflow;
20pub(crate) mod workspace;
21
22mod apply;
23pub(crate) mod helpers;
24mod registry;
25#[cfg(test)]
26pub(crate) mod test_fixtures;
27mod tests;
28
29pub use agent::AgentResource;
32pub use env_store::EnvStoreResource;
33pub use execution_profile::ExecutionProfileResource;
34pub use export::{export_crd_documents, export_manifest_documents, export_manifest_resources};
35pub use parse::{
36 delete_resource_by_kind, kind_as_str, parse_manifests_from_yaml, parse_resources_from_yaml,
37};
38pub use project::ProjectResource;
39pub use runtime_policy::RuntimePolicyResource;
40pub use secret_store::SecretStoreResource;
41pub use step_template::StepTemplateResource;
42pub use trigger::TriggerResource;
43pub use workflow::WorkflowResource;
44pub use workspace::WorkspaceResource;
45
46pub use helpers::metadata_from_store;
49pub(crate) use helpers::{
50 apply_to_store, delete_from_store, manifest_yaml, metadata_with_name, serializes_equal,
51 validate_resource_name,
52};
53pub use registry::*;
54pub use apply::apply_to_project;
56
57pub(crate) use crate::cli_types::ResourceMetadata;
60
61pub use orchestrator_config::resource_store::ApplyResult;
64
65pub trait Resource: Sized {
67 fn kind(&self) -> ResourceKind;
69 fn name(&self) -> &str;
71 fn validate(&self) -> Result<()>;
73 fn apply(&self, config: &mut OrchestratorConfig) -> Result<ApplyResult>;
75 fn to_yaml(&self) -> Result<String>;
77
78 fn get_from_project(
81 config: &OrchestratorConfig,
82 name: &str,
83 project_id: Option<&str>,
84 ) -> Option<Self>;
85
86 fn delete_from_project(
89 config: &mut OrchestratorConfig,
90 name: &str,
91 project_id: Option<&str>,
92 ) -> bool;
93
94 fn get_from(config: &OrchestratorConfig, name: &str) -> Option<Self> {
96 Self::get_from_project(config, name, None)
97 }
98
99 fn delete_from(config: &mut OrchestratorConfig, name: &str) -> bool {
101 Self::delete_from_project(config, name, None)
102 }
103}