use greentic_deploy_spec::{
BundleDeployment, BundleId, CapabilitySlot, DeploymentId, EnvId, EnvPackBinding, Environment,
EnvironmentHostConfig, ExtensionBinding, IdempotencyKey, MessagingEndpoint,
MessagingEndpointId, Revision, RevisionId,
};
use super::StoreError;
pub use greentic_deploy_spec::engine::{
AddBundlePayload, AddMessagingEndpointPayload, AddTrustedKeyPayload, ApplyTrafficSplitOutcome,
ExtensionKey, FieldUpdate, MigrateMergePayload, MigrateSeedPayload, RemoveBundleOutcome,
RevisionTransitionOutcome, RollbackTrafficSplitOutcome, SetMessagingWelcomeFlowPayload,
SetTrafficSplitPayload, StageRevisionPayload, TrustRootAddOutcome, TrustRootRemoveOutcome,
TrustRootSeed, UpdateBundlePayload, UpdateEnvironmentPayload, WarmRevisionPayload,
};
pub trait EnvironmentMutations: Send + Sync {
fn create_environment(
&self,
env_id: &EnvId,
name: String,
host_config: EnvironmentHostConfig,
) -> Result<Environment, StoreError>;
fn update_environment(
&self,
env_id: &EnvId,
patch: UpdateEnvironmentPayload,
) -> Result<Environment, StoreError>;
fn migrate_merge_bindings(
&self,
target_env_id: &EnvId,
payload: MigrateMergePayload,
) -> Result<(Vec<String>, Vec<String>), StoreError>;
fn stage_revision(
&self,
env_id: &EnvId,
payload: StageRevisionPayload,
idempotency_key: IdempotencyKey,
) -> Result<Revision, StoreError>;
fn warm_revision(
&self,
env_id: &EnvId,
payload: WarmRevisionPayload,
idempotency_key: IdempotencyKey,
) -> Result<RevisionTransitionOutcome, StoreError>;
fn drain_revision(
&self,
env_id: &EnvId,
revision_id: RevisionId,
idempotency_key: IdempotencyKey,
) -> Result<RevisionTransitionOutcome, StoreError>;
fn archive_revision(
&self,
env_id: &EnvId,
revision_id: RevisionId,
idempotency_key: IdempotencyKey,
) -> Result<RevisionTransitionOutcome, StoreError>;
fn add_bundle(
&self,
env_id: &EnvId,
payload: AddBundlePayload,
idempotency_key: IdempotencyKey,
) -> Result<BundleDeployment, StoreError>;
fn update_bundle(
&self,
env_id: &EnvId,
payload: UpdateBundlePayload,
idempotency_key: IdempotencyKey,
) -> Result<BundleDeployment, StoreError>;
fn remove_bundle(
&self,
env_id: &EnvId,
deployment_id: DeploymentId,
idempotency_key: IdempotencyKey,
) -> Result<RemoveBundleOutcome, StoreError>;
fn add_pack_binding(
&self,
env_id: &EnvId,
binding: EnvPackBinding,
idempotency_key: IdempotencyKey,
) -> Result<EnvPackBinding, StoreError>;
fn update_pack_binding(
&self,
env_id: &EnvId,
slot: CapabilitySlot,
binding: EnvPackBinding,
idempotency_key: IdempotencyKey,
) -> Result<(EnvPackBinding, u64), StoreError>;
fn remove_pack_binding(
&self,
env_id: &EnvId,
slot: CapabilitySlot,
idempotency_key: IdempotencyKey,
) -> Result<(EnvPackBinding, u64), StoreError>;
fn rollback_pack_binding(
&self,
env_id: &EnvId,
slot: CapabilitySlot,
idempotency_key: IdempotencyKey,
) -> Result<(EnvPackBinding, u64), StoreError>;
fn add_extension_binding(
&self,
env_id: &EnvId,
binding: ExtensionBinding,
idempotency_key: IdempotencyKey,
) -> Result<ExtensionBinding, StoreError>;
fn update_extension_binding(
&self,
env_id: &EnvId,
key: ExtensionKey,
binding: ExtensionBinding,
idempotency_key: IdempotencyKey,
) -> Result<(ExtensionBinding, u64), StoreError>;
fn remove_extension_binding(
&self,
env_id: &EnvId,
key: ExtensionKey,
idempotency_key: IdempotencyKey,
) -> Result<(ExtensionBinding, u64), StoreError>;
fn rollback_extension_binding(
&self,
env_id: &EnvId,
key: ExtensionKey,
idempotency_key: IdempotencyKey,
) -> Result<(ExtensionBinding, u64), StoreError>;
fn set_traffic_split(
&self,
env_id: &EnvId,
payload: SetTrafficSplitPayload,
idempotency_key: IdempotencyKey,
) -> Result<ApplyTrafficSplitOutcome, StoreError>;
fn rollback_traffic_split(
&self,
env_id: &EnvId,
deployment_id: DeploymentId,
idempotency_key: IdempotencyKey,
) -> Result<RollbackTrafficSplitOutcome, StoreError>;
fn add_messaging_endpoint(
&self,
env_id: &EnvId,
payload: AddMessagingEndpointPayload,
idempotency_key: IdempotencyKey,
) -> Result<MessagingEndpoint, StoreError>;
fn link_messaging_bundle(
&self,
env_id: &EnvId,
endpoint_id: MessagingEndpointId,
bundle_id: BundleId,
updated_by: String,
idempotency_key: IdempotencyKey,
) -> Result<MessagingEndpoint, StoreError>;
fn unlink_messaging_bundle(
&self,
env_id: &EnvId,
endpoint_id: MessagingEndpointId,
bundle_id: BundleId,
updated_by: String,
idempotency_key: IdempotencyKey,
) -> Result<MessagingEndpoint, StoreError>;
fn set_messaging_welcome_flow(
&self,
env_id: &EnvId,
payload: SetMessagingWelcomeFlowPayload,
idempotency_key: IdempotencyKey,
) -> Result<MessagingEndpoint, StoreError>;
fn remove_messaging_endpoint(
&self,
env_id: &EnvId,
endpoint_id: MessagingEndpointId,
) -> Result<MessagingEndpointId, StoreError>;
fn rotate_messaging_webhook_secret(
&self,
env_id: &EnvId,
endpoint_id: MessagingEndpointId,
updated_by: String,
idempotency_key: IdempotencyKey,
) -> Result<MessagingEndpoint, StoreError>;
fn bootstrap_trust_root(&self, env_id: &EnvId) -> Result<TrustRootSeed, StoreError>;
fn seed_trust_root_if_absent(
&self,
env_id: &EnvId,
) -> Result<Option<TrustRootSeed>, StoreError>;
fn add_trusted_key(
&self,
env_id: &EnvId,
key_id: String,
public_key_pem: String,
idempotency_key: IdempotencyKey,
) -> Result<TrustRootAddOutcome, StoreError>;
fn remove_trusted_key(
&self,
env_id: &EnvId,
key_id: String,
idempotency_key: IdempotencyKey,
) -> Result<TrustRootRemoveOutcome, StoreError>;
}
#[cfg(test)]
mod tests {
use super::*;
#[allow(dead_code)]
fn _is_object_safe(_: &dyn EnvironmentMutations) {}
}