-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support create/revoke signing key (#91)
- Loading branch information
1 parent
107f8c1
commit 2303a17
Showing
9 changed files
with
123 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule client-sdk-rust
updated
10 files
+2 −0 | Cargo.toml | |
+3 −2 | src/endpoint_resolver.rs | |
+49 −0 | src/generated/control_client.rs | |
+1 −0 | src/jwt.rs | |
+15 −0 | src/protos/controlclient.proto | |
+9 −0 | src/response/create_signing_key_response.rs | |
+1 −0 | src/response/mod.rs | |
+76 −31 | src/simple_cache_client.rs | |
+23 −0 | src/utils.rs | |
+30 −0 | tests/integration_test.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod account; | ||
pub mod cache; | ||
pub mod configure; | ||
pub mod signingkey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod signingkey_cli; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use log::debug; | ||
use momento::simple_cache_client::SimpleCacheClient; | ||
|
||
use crate::error::CliError; | ||
|
||
async fn get_momento_instance(auth_token: String) -> Result<SimpleCacheClient, CliError> { | ||
match SimpleCacheClient::new(auth_token, 100).await { | ||
Ok(m) => Ok(m), | ||
Err(e) => Err(CliError { msg: e.to_string() }), | ||
} | ||
} | ||
|
||
pub async fn create_signing_key(ttl_minutes: u32, auth_token: String) -> Result<(), CliError> { | ||
debug!("creating signing key..."); | ||
let mut momento = get_momento_instance(auth_token).await?; | ||
match momento.create_signing_key(ttl_minutes).await { | ||
Ok(res) => { | ||
println!("{}", serde_json::to_string_pretty(&res).unwrap()); | ||
} | ||
Err(e) => return Err(CliError { msg: e.to_string() }), | ||
}; | ||
Ok(()) | ||
} | ||
|
||
pub async fn revoke_signing_key(key_id: String, auth_token: String) -> Result<(), CliError> { | ||
debug!("revoking signing key..."); | ||
let mut momento = get_momento_instance(auth_token).await?; | ||
match momento.revoke_signing_key(&key_id).await { | ||
Ok(_) => (), | ||
Err(e) => return Err(CliError { msg: e.to_string() }), | ||
}; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters