Skip to main content

greentic_distributor_client/
lib.rs

1pub mod config;
2pub mod error;
3pub mod source;
4pub mod types;
5
6#[cfg(feature = "dist-client")]
7pub mod dist;
8#[cfg(feature = "dist-cli")]
9pub mod dist_cli;
10#[cfg(feature = "http-runtime")]
11mod http;
12#[cfg(feature = "oci-components")]
13pub mod oci_components;
14#[cfg(feature = "pack-fetch")]
15pub mod oci_packs;
16#[cfg(feature = "runner-api")]
17pub mod runner_api;
18pub mod store_auth;
19mod wit_client;
20
21pub use config::DistributorClientConfig;
22#[cfg(feature = "dist-client")]
23#[allow(deprecated)]
24pub use dist::{
25    AccessMode, AdvisorySet, ArtifactDescriptor, ArtifactOpenOutput, ArtifactOpenRequest,
26    ArtifactOpener, ArtifactSource, ArtifactSourceKind, ArtifactType, BundleLifecycleState,
27    BundleManifestSummary, BundleOpenMode, BundleOpenOutput, BundleOpenRequest, BundleOpener,
28    BundleRecord, CacheEntry, CacheEntryState, CachePolicy, DistClient, DistOptions,
29    InjectedResolution, IntegrationError, IntegrationErrorCode, IntegrityState, LockHint,
30    PreliminaryDecision, ReleaseTrainDescriptor, ResolvePolicy, ResolveRefInjector,
31    ResolveRefRequest, ResolvedArtifact, ResolvedVia, RetentionDecision, RetentionDisposition,
32    RetentionEnvironment, RetentionInput, RetentionOutcome, RetentionReport, RollbackAuditFields,
33    RollbackBundleInput, RollbackBundleResult, SourceSnapshot, StageAuditFields, StageBundleInput,
34    StageBundleResult, TransportHints, VerificationCheck, VerificationEnvironment,
35    VerificationOutcome, VerificationPolicy, VerificationReport, WarmAuditFields, WarmBundleInput,
36    WarmBundleResult,
37};
38pub use error::DistributorError;
39#[cfg(feature = "http-runtime")]
40pub use http::HttpDistributorClient;
41#[cfg(feature = "oci-components")]
42pub use oci_components::{
43    ComponentResolveOptions, ComponentsExtension, ComponentsMode, OciComponentError,
44    OciComponentResolver, ResolvedComponent, ResolvedComponentDescriptor,
45};
46#[cfg(feature = "pack-fetch")]
47pub use oci_packs::{OciPackError, OciPackFetcher, PackFetchOptions, ResolvedPack};
48#[cfg(feature = "pack-fetch")]
49pub use oci_packs::{
50    default_pack_layer_media_types, default_preferred_pack_layer_media_types, fetch_pack,
51    fetch_pack_to_cache, fetch_pack_to_cache_with_options,
52    fetch_pack_to_cache_with_options_and_client, fetch_pack_with_options,
53    fetch_pack_with_options_and_client,
54};
55pub use source::{ChainedDistributorSource, DistributorSource};
56pub use store_auth::{
57    StoreAuth, StoreAuthError, StoreCredentials, load_login, load_login_default, save_login,
58    save_login_default,
59};
60pub use types::*;
61pub use wit_client::{
62    DistributorApiBindings, GeneratedDistributorApiBindings, WitDistributorClient,
63};
64
65use async_trait::async_trait;
66
67/// Trait implemented by clients that can communicate with a Distributor.
68#[async_trait]
69pub trait DistributorClient: Send + Sync {
70    async fn resolve_component(
71        &self,
72        req: ResolveComponentRequest,
73    ) -> Result<ResolveComponentResponse, DistributorError>;
74
75    async fn get_pack_status(
76        &self,
77        tenant: &TenantCtx,
78        env: &DistributorEnvironmentId,
79        pack_id: &str,
80    ) -> Result<serde_json::Value, DistributorError>;
81
82    async fn get_pack_status_v2(
83        &self,
84        tenant: &TenantCtx,
85        env: &DistributorEnvironmentId,
86        pack_id: &str,
87    ) -> Result<PackStatusResponse, DistributorError>;
88
89    async fn warm_pack(
90        &self,
91        tenant: &TenantCtx,
92        env: &DistributorEnvironmentId,
93        pack_id: &str,
94    ) -> Result<(), DistributorError>;
95}