grow_infisical/lib.rs
1// Skeleton created by sdk-kit 0.1.0; owned by this repository (edit freely).
2//! # grow-infisical
3//!
4//! Rust SDK for [Infisical](https://grow-codes-packages.github.io/infisical/) by Grow Codes:
5//! one async client (tokio) for Universal / token / Kubernetes / AWS IAM auth with automatic
6//! token refresh, secrets (v4 with a v3 fallback detected at run time, batch operations,
7//! versions, reference expansion), folders, projects and environments, tags, secret imports,
8//! environment injection and the Grow [`SecretsProvider`](secrets::SecretsProvider).
9//!
10//! ```no_run
11//! # async fn demo() -> grow_infisical::Result<()> {
12//! use grow_infisical::secrets::SecretsProvider;
13//! use grow_infisical::{InfisicalClient, InfisicalConfig, UpdateSecretOptions};
14//!
15//! // explicit > GROW_INFISICAL_* > INFISICAL_* > defaults
16//! let client = InfisicalClient::new(InfisicalConfig::from_env()?)?;
17//! println!("healthy: {}", client.health().await?.healthy);
18//!
19//! // secrets in the configured project / environment / path
20//! client.create_secret("DB_PASSWORD", "s3cr3t", None).await?;
21//! let secret = client.get_secret("DB_PASSWORD", None).await?;
22//! assert_eq!(secret.value.reveal(), "s3cr3t");
23//! let update = UpdateSecretOptions { value: Some("rotated".into()), ..Default::default() };
24//! client.update_secret("DB_PASSWORD", Some(&update)).await?;
25//!
26//! // the Grow SecretsProvider (folders are created on demand)
27//! let secrets = client.secrets();
28//! secrets.set("app/API_KEY", "abc123".into(), None).await?;
29//! assert_eq!(secrets.get_string("app/API_KEY", None).await?.as_deref(), Some("abc123"));
30//!
31//! client.close().await;
32//! # Ok(())
33//! # }
34//! ```
35//!
36//! Features: `blocking` (a blocking client), `testing` (in-memory fakes and the conformance
37//! runner).
38#![cfg_attr(docsrs, feature(doc_cfg))]
39
40pub mod core;
41
42mod api;
43mod auth;
44mod client;
45mod config;
46mod envload;
47mod models;
48mod provider;
49mod resources;
50mod secrets_api;
51
52#[cfg(feature = "blocking")]
53#[cfg_attr(docsrs, doc(cfg(feature = "blocking")))]
54pub mod blocking;
55
56#[cfg(feature = "testing")]
57#[cfg_attr(docsrs, doc(cfg(feature = "testing")))]
58pub mod testing;
59
60pub mod secrets;
61
62pub use crate::core::{Error, ErrorCode, HealthStatus, Result, RetryPolicy, Secret};
63
64pub use crate::config::{ApiVersion, DEFAULT_SECRET_PATH, DEFAULT_URL};
65
66pub use crate::client::InfisicalClient;
67
68pub use crate::config::InfisicalConfig;
69
70pub use crate::config::InfisicalConfigBuilder;
71
72pub use crate::api::normalize_path;
73pub use crate::auth::{
74 sign_v4, AccessToken, Auth, AuthMethod, AwsIamAuth, AwsLoginRequest, KubernetesAuth,
75 SigV4Request, TokenAuth, UniversalAuth, DEFAULT_KUBERNETES_TOKEN_PATH,
76};
77pub use crate::envload::{format_dotenv, EnvOptions};
78pub use crate::models::{
79 Actor, BatchUpdateMode, Environment, Folder, ImportedSecrets, Project, ProjectPage,
80 SecretEntry, SecretImport, SecretList, SecretType, SecretVersion, Tag,
81};
82pub use crate::provider::{ProjectSecretsProvider, SecretsProviderOptions};
83pub use crate::resources::{
84 CreateEnvironmentOptions, CreateFolderOptions, CreateSecretImportOptions, DeleteFolderOptions,
85 ListFoldersOptions, ListProjectsOptions, SecretImportOptions, UpdateFolderOptions,
86 DEFAULT_TAG_COLOR,
87};
88pub use crate::secrets_api::{
89 BatchScope, CreateSecretOptions, DeleteSecretOptions, DeleteSecretsOptions, GetSecretOptions,
90 ListSecretVersionsOptions, ListSecretsOptions, SecretInput, SecretUpdate, UpdateSecretOptions,
91 UpdateSecretsOptions,
92};
93
94/// Service-prefixed alias of [`Error`].
95pub type InfisicalError = Error;