Skip to main content

stackless_provider_sdk/
lib.rs

1//! Provider-facing traits and helpers for stackless catalog integrations.
2//!
3//! Implement [`Hostable`] + [`CatalogResource`] (or [`ProviderOps`] directly) and
4//! register in `stackless-integrations`. Provisioning delegates to Stripe
5//! Projects; this crate is the extension point for bespoke providers.
6
7use std::path::Path;
8
9use async_trait::async_trait;
10use stackless_core::def::StackDef;
11use stackless_core::substrate::StepResource;
12use stackless_stripe_projects::stripe::{CommandRunner, StripeProjects};
13
14pub mod config;
15pub mod error;
16pub mod hostable;
17pub mod observation;
18pub mod resource;
19
20pub use config::{config_bool, config_optional_string, config_string};
21pub use error::IntegrationError;
22pub use hostable::{
23    BlockedSetting, ConfigScope, Hostable, IntegrationHosting, host_bound_hosts,
24    host_bound_supports,
25};
26pub use observation::{Drift, IntegrationObservation};
27pub use resource::{CatalogResource, ResourcePayload};
28
29/// One integration provider's lifecycle behaviour. The registry stores a
30/// `&'static dyn ProviderOps` per provider, so adding a provider is one
31/// registry row + this impl — dispatch never matches on provider strings.
32///
33/// The runner is erased to `&dyn CommandRunner` (sound via
34/// `impl CommandRunner for &T`) so the registry table is not generic.
35#[async_trait]
36pub trait ProviderOps: Send + Sync {
37    // The provision params mirror the established provisioning call; `&self`
38    // for dispatch tips it one over the lint's limit.
39    #[allow(clippy::too_many_arguments)]
40    async fn provision(
41        &self,
42        stripe: &StripeProjects<&dyn CommandRunner>,
43        def: &StackDef,
44        definition_dir: &Path,
45        instance: &str,
46        name: &str,
47        substrate: &str,
48        skip_stripe_instance_context: bool,
49    ) -> Result<StepResource, IntegrationError>;
50
51    /// Post-provision config glue (vendor API toggles, etc.). Called after
52    /// [`Self::provision`] succeeds. Default no-op.
53    #[allow(clippy::too_many_arguments)]
54    async fn apply(
55        &self,
56        _stripe: &StripeProjects<&dyn CommandRunner>,
57        _def: &StackDef,
58        _name: &str,
59        _substrate: &str,
60        _provisioned: &StepResource,
61    ) -> Result<(), IntegrationError> {
62        Ok(())
63    }
64
65    async fn observe(
66        &self,
67        stripe: &StripeProjects<&dyn CommandRunner>,
68        checkpoint_payload: &str,
69        fallback_resource: &str,
70    ) -> Result<IntegrationObservation, IntegrationError>;
71
72    async fn destroy(
73        &self,
74        stripe: &StripeProjects<&dyn CommandRunner>,
75        checkpoint_payload: &str,
76        fallback_resource: &str,
77    ) -> Result<(), IntegrationError>;
78}