Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<!-- Code generated for API Clients. DO NOT EDIT. -->
## 0.7.0
* Renamed `upstream_proto` to `upstream_protocol` for `endpoint` resources
* Added support for `pooling_enabled` on Endpoints
* Add support for `vaults`
* Add support for `secrets`

## 0.6.0
* Added support for Cloud Endpoints (currently in private beta).
Expand Down
298 changes: 294 additions & 4 deletions src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ pub mod endpoints {
/// Provides streams of pages of [types::EndpointList], or of [types::Endpoint] directly.
pub struct List {
c: std::sync::Arc<Client>,
req: types::Paging,
req: types::EndpointListArgs,
}

impl List {
Expand All @@ -1244,7 +1244,7 @@ pub mod endpoints {
pub async fn pages(self) -> impl Stream<Item = Result<types::EndpointList, Error>> + Unpin {
struct State {
c: std::sync::Arc<Client>,
req: types::Paging,
req: types::EndpointListArgs,
init: bool,
cur_uri: Option<String>,
}
Expand Down Expand Up @@ -1309,15 +1309,15 @@ pub mod endpoints {
/// which will do pagination for you.
pub(crate) async fn list_page(
&self,
req: &types::Paging,
req: &types::EndpointListArgs,
) -> Result<types::EndpointList, Error> {
self.c
.make_request("/endpoints", reqwest::Method::GET, Some(req))
.await
}

/// List all active endpoints on the account
pub fn list(&self, req: types::Paging) -> List {
pub fn list(&self, req: types::EndpointListArgs) -> List {
List {
c: std::sync::Arc::new(self.clone()),
req,
Expand Down Expand Up @@ -2550,6 +2550,148 @@ pub mod reserved_domains {
}
}

/// Secrets is an api service for securely storing and managing sensitive data such
/// as secrets, credentials, and tokens.
pub mod secrets {
use crate::types;
use crate::Error;
use futures::{Stream, TryStreamExt};

/// Secrets is an api service for securely storing and managing sensitive data such
/// as secrets, credentials, and tokens.
#[derive(Debug, Clone)]
pub struct Client {
c: crate::Client,
}
/// Provides streams of pages of [types::SecretList], or of [types::Secret] directly.
pub struct List {
c: std::sync::Arc<Client>,
req: types::Paging,
}

impl List {
/// Iterate over [types::SecretList].
///
/// See [Tokio Streams](https://tokio.rs/tokio/tutorial/streams)
/// documentation for more info on usage.
pub async fn pages(self) -> impl Stream<Item = Result<types::SecretList, Error>> + Unpin {
struct State {
c: std::sync::Arc<Client>,
req: types::Paging,
init: bool,
cur_uri: Option<String>,
}

let s = State {
c: self.c,
req: self.req,
init: true,
cur_uri: None,
};

Box::pin(futures::stream::unfold(s, |s| async move {
let page_resp = match (s.init, &s.cur_uri) {
(true, _) => s.c.list_page(&s.req).await,
(false, None) => {
return None;
}
(false, Some(uri)) => s.c.c.get_by_uri(uri).await,
};
match page_resp {
Err(e) => Some((Err(e), s)),
Ok(page) => {
let next = page.next_page_uri.clone();
Some((
Ok(page),
State {
init: false,
cur_uri: next,
..s
},
))
}
}
}))
}

/// Iterate over [types::Secret] items.
///
/// See [Tokio Streams](https://tokio.rs/tokio/tutorial/streams)
/// documentation for more info on usage.
pub async fn secrets(self) -> impl Stream<Item = Result<types::Secret, Error>> + Unpin {
self.pages()
.await
.map_ok(|page| futures::stream::iter(page.secrets.into_iter().map(Ok)))
.try_flatten()
}
}

impl Client {
pub fn new(c: crate::Client) -> Self {
Self { c }
}

/// Create a new Secret
pub async fn create(&self, req: &types::SecretCreate) -> Result<types::Secret, Error> {
self.c
.make_request("/vault_secrets", reqwest::Method::POST, Some(req))
.await
}

/// Update an existing Secret by ID
pub async fn update(&self, req: &types::SecretUpdate) -> Result<types::Secret, Error> {
self.c
.make_request(
&format!("/vault_secrets/{id}", id = req.id),
reqwest::Method::PATCH,
Some(req),
)
.await
}

/// Delete a Secret
pub async fn delete(&self, id: &str) -> Result<(), Error> {
self.c
.make_request(
&format!("/vault_secrets/{id}", id = id),
reqwest::Method::DELETE,
None::<Option<()>>,
)
.await
}

/// Get a Secret by ID
pub async fn get(&self, id: &str) -> Result<types::Secret, Error> {
self.c
.make_request(
&format!("/vault_secrets/{id}", id = id),
reqwest::Method::GET,
None::<Option<()>>,
)
.await
}

/// Get a single page without pagination. Prefer using list
/// which will do pagination for you.
pub(crate) async fn list_page(
&self,
req: &types::Paging,
) -> Result<types::SecretList, Error> {
self.c
.make_request("/vault_secrets", reqwest::Method::GET, Some(req))
.await
}

/// List all Secrets owned by account
pub fn list(&self, req: types::Paging) -> List {
List {
c: std::sync::Arc::new(self.clone()),
req,
}
}
}
}

/// An SSH Certificate Authority is a pair of an SSH Certificate and its private
/// key that can be used to sign other SSH host and user certificates.
pub mod ssh_certificate_authorities {
Expand Down Expand Up @@ -3447,6 +3589,148 @@ pub mod tunnels {
}
}
}

/// Vaults is an api service for securely storing and managing sensitive data such
/// as secrets, credentials, and tokens.
pub mod vaults {
use crate::types;
use crate::Error;
use futures::{Stream, TryStreamExt};

/// Vaults is an api service for securely storing and managing sensitive data such
/// as secrets, credentials, and tokens.
#[derive(Debug, Clone)]
pub struct Client {
c: crate::Client,
}
/// Provides streams of pages of [types::VaultList], or of [types::Vault] directly.
pub struct List {
c: std::sync::Arc<Client>,
req: types::Paging,
}

impl List {
/// Iterate over [types::VaultList].
///
/// See [Tokio Streams](https://tokio.rs/tokio/tutorial/streams)
/// documentation for more info on usage.
pub async fn pages(self) -> impl Stream<Item = Result<types::VaultList, Error>> + Unpin {
struct State {
c: std::sync::Arc<Client>,
req: types::Paging,
init: bool,
cur_uri: Option<String>,
}

let s = State {
c: self.c,
req: self.req,
init: true,
cur_uri: None,
};

Box::pin(futures::stream::unfold(s, |s| async move {
let page_resp = match (s.init, &s.cur_uri) {
(true, _) => s.c.list_page(&s.req).await,
(false, None) => {
return None;
}
(false, Some(uri)) => s.c.c.get_by_uri(uri).await,
};
match page_resp {
Err(e) => Some((Err(e), s)),
Ok(page) => {
let next = page.next_page_uri.clone();
Some((
Ok(page),
State {
init: false,
cur_uri: next,
..s
},
))
}
}
}))
}

/// Iterate over [types::Vault] items.
///
/// See [Tokio Streams](https://tokio.rs/tokio/tutorial/streams)
/// documentation for more info on usage.
pub async fn vaults(self) -> impl Stream<Item = Result<types::Vault, Error>> + Unpin {
self.pages()
.await
.map_ok(|page| futures::stream::iter(page.vaults.into_iter().map(Ok)))
.try_flatten()
}
}

impl Client {
pub fn new(c: crate::Client) -> Self {
Self { c }
}

/// Create a new Vault
pub async fn create(&self, req: &types::VaultCreate) -> Result<types::Vault, Error> {
self.c
.make_request("/vaults", reqwest::Method::POST, Some(req))
.await
}

/// Update an existing Vault by ID
pub async fn update(&self, req: &types::VaultUpdate) -> Result<types::Vault, Error> {
self.c
.make_request(
&format!("/vaults/{id}", id = req.id),
reqwest::Method::PATCH,
Some(req),
)
.await
}

/// Delete a Vault
pub async fn delete(&self, id: &str) -> Result<(), Error> {
self.c
.make_request(
&format!("/vaults/{id}", id = id),
reqwest::Method::DELETE,
None::<Option<()>>,
)
.await
}

/// Get a Vault by ID
pub async fn get(&self, id: &str) -> Result<types::Vault, Error> {
self.c
.make_request(
&format!("/vaults/{id}", id = id),
reqwest::Method::GET,
None::<Option<()>>,
)
.await
}

/// Get a single page without pagination. Prefer using list
/// which will do pagination for you.
pub(crate) async fn list_page(
&self,
req: &types::Paging,
) -> Result<types::VaultList, Error> {
self.c
.make_request("/vaults", reqwest::Method::GET, Some(req))
.await
}

/// List all Vaults owned by account
pub fn list(&self, req: types::Paging) -> List {
List {
c: std::sync::Arc::new(self.clone()),
req,
}
}
}
}
impl Client {
pub fn abuse_reports(&self) -> abuse_reports::Client {
abuse_reports::Client::new(self.clone())
Expand Down Expand Up @@ -3502,6 +3786,9 @@ impl Client {
pub fn reserved_domains(&self) -> reserved_domains::Client {
reserved_domains::Client::new(self.clone())
}
pub fn secrets(&self) -> secrets::Client {
secrets::Client::new(self.clone())
}
pub fn ssh_certificate_authorities(&self) -> ssh_certificate_authorities::Client {
ssh_certificate_authorities::Client::new(self.clone())
}
Expand All @@ -3520,6 +3807,9 @@ impl Client {
pub fn tunnels(&self) -> tunnels::Client {
tunnels::Client::new(self.clone())
}
pub fn vaults(&self) -> vaults::Client {
vaults::Client::new(self.clone())
}
}

pub mod backends {
Expand Down
Loading
Loading