Skip to content

Commit

Permalink
Add list secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
exvuma committed Jan 27, 2020
1 parent 6f7da91 commit a3a0b00
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions cloudflare/src/endpoints/workers/list_secrets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use super::WorkersSecret;

use crate::framework::endpoint::{Endpoint, Method};

/// List Secrets
/// Lists all secrets mappings for a given script
/// https://api.cloudflare.com/#worker-secrets-list-secrets
pub struct ListSecrets<'a> {
pub account_identifier: &'a str,
pub script_name: &'a str,
}

impl<'a> Endpoint<Vec<WorkersSecret>> for ListSecrets<'a> {
fn method(&self) -> Method {
Method::Get
}
fn path(&self) -> String {
format!(
"accounts/{}/workers/scripts/{}/secrets",
self.account_identifier, self.script_name
)
}
}
5 changes: 4 additions & 1 deletion cloudflare/src/endpoints/workers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ mod create_secret;
mod delete_route;
mod delete_secret;
mod list_routes;
mod list_secrets;

pub use create_route::{CreateRoute, CreateRouteParams};
pub use create_secret::{CreateSecret, CreateSecretParams};
pub use delete_route::DeleteRoute;
pub use delete_secret::DeleteSecret;
pub use list_routes::ListRoutes;
pub use list_secrets::ListSecrets;

/// Workers KV Route
/// Routes are basic patterns used to enable or disable workers that match requests.
Expand Down Expand Up @@ -50,7 +52,8 @@ impl ApiResult for WorkersRouteIdOnly {}
pub struct WorkersSecret {
/// TODO: these fields depend on the API and may be wrong since unable to test
pub name: String,
pub r#type: String,
#[serde(rename = "type")]
pub secret_type: String,
pub modified_on: DateTime<Utc>,
pub created_on: DateTime<Utc>,
}
Expand Down

0 comments on commit a3a0b00

Please sign in to comment.