infisical_api/
lib.rs

1#![warn(missing_docs)]
2
3//! # infisical_api
4//!
5//! **Note: The author of this crate is very new to Rust and has likely made many mistakes. Please
6//! feel free to open an issue or pull request for anything that can be improved.**
7//!
8//! The `infisical-api` crate provides a [Client] wrapper around the [Infisical API](https://infisical.com/).
9//! The client provides all the functionality of the Infisical API, including:
10//!
11//! - Updating Secrets
12//! - Accessing Secrets
13//! - Secret Rollback
14//! - Project Management
15//!
16//! infisical_api is built on top of reqwest and utilizes the async feature. An async runtime is
17//! required in order to function. A feature allowing the use of blocking calls may be provided in
18//! the future.
19//!
20//! The crate also includes utility functions for easy encrypting and decrypting of secrets
21//!
22//! Simple secret retrieval can be done by creating a client and providing the workspace id of your
23//! infisical project as well as the environment (dev, test, prod, etc.).
24//!
25//! ```rust
26//! # use infisical_api::Error;
27//! # async fn run() -> Result<(), Error> {
28//! let client = infisical_api::Client::new("Your API key here")?;
29//! let secrets = client.get_encrypted_project_secrets("Your Infisical workspace ID", "Environment here");
30//!
31//! # Ok(())
32//! # }
33//! ```
34//!
35//! The [`Client`][client] defaults to the Infisical Cloud api endpoint, however a [`ClientBuilder`] is provided for more flexibility. It allows a custom API base url to be set and a custom Reqwest ClientBuilder.
36//! ```rust
37//! # use infisical_api::Error;
38//! # async fn run() -> Result<(), Error> {
39//! let reqwest_client_builder = reqwest::Client::builder();
40//! // ...
41//! // Configure reqwest_client_builder as needed
42//! // ...
43//! let client = infisical_api::ClientBuilder::new()
44//!     .api_base("Your custom API endpoint")
45//!     .reqwest_client_builder(reqwest_client_builder)
46//!     .build("Your API key");
47//!
48//! # Ok(())
49//! # }
50//! ```
51//!
52//! The crate also provides the option to decrypt secrets after retrieval if desired.
53//! ```rust
54//! # use infisical_api::Error;
55//! # async fn run() -> Result<(), Error> {
56//! let client = infisical_api::Client::new("Your API key here")?;
57//! let secrets = client
58//!     .get_decrypted_project_secrets("Your Infisical workspace ID", "Environment here", "Your project key").await?;
59//!
60//! # Ok(())
61//! # }
62//! ```
63//! It's recommended that you determine your project key ahead of time as it is required for
64//! encryption and decryption functionality.
65//! ```rust
66//! # use infisical_api::Error;
67//! # async fn run() -> Result<(), Error> {
68//! let client = infisical_api::Client::new("Your API key here")?;
69//! let private_key = client
70//!     .get_user_decrypted_private_key("Your infisical password here")
71//!     .await?;
72//! let project_key = client
73//!     .get_decrypted_project_key("Infisical workspace ID", &private_key)
74//!     .await?;
75//! # Ok(())
76//! # }
77//! ```
78
79pub mod api;
80pub mod client;
81pub mod error;
82pub mod utils;
83
84#[doc(inline)]
85pub use self::client::{Client, ClientBuilder};
86#[doc(inline)]
87pub use self::error::Error;
88pub use reqwest;
89
90#[cfg(test)]
91mod tests {
92    #[test]
93    fn temp() {}
94}