-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secrets endpoints #91
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use super::WorkersSecret; | ||
|
||
use crate::framework::endpoint::{Endpoint, Method}; | ||
|
||
/// Create Secret | ||
/// https://api.cloudflare.com/#worker-create-secret | ||
pub struct CreateSecret<'a> { | ||
/// account id of owner of the script | ||
pub account_identifier: &'a str, | ||
/// the name of the script to attach the secret to | ||
pub script_name: &'a str, | ||
/// secert's contents | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/secert/secret Also all our comments elsewhere start with a capital, could you please change yours to be consistent? :) |
||
pub params: CreateSecretParams, | ||
} | ||
|
||
impl<'a> Endpoint<WorkersSecret, (), CreateSecretParams> for CreateSecret<'a> { | ||
fn method(&self) -> Method { | ||
Method::Put | ||
} | ||
fn path(&self) -> String { | ||
format!( | ||
"accounts/{}/workers/scripts/{}/secrets", | ||
self.account_identifier, self.script_name | ||
) | ||
} | ||
fn body(&self) -> Option<CreateSecretParams> { | ||
Some(self.params.clone()) | ||
} | ||
} | ||
|
||
#[derive(Serialize, Clone, Debug)] | ||
pub struct CreateSecretParams { | ||
/// the variable name of the secret that will be bound to the script | ||
pub name: String, | ||
/// the string value of the secret | ||
pub text: String, | ||
// type of binding (e.g.secret_text) | ||
#[serde(rename = "type")] | ||
pub secret_type: String, | ||
} |
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,26 @@ | ||
use super::WorkersSecret; | ||
|
||
use crate::framework::endpoint::{Endpoint, Method}; | ||
|
||
/// Delete Secret | ||
/// https://api.cloudflare.com/#worker-delete-secret | ||
pub struct DeleteSecret<'a> { | ||
/// account id of owner of the script | ||
pub account_identifier: &'a str, | ||
/// the name of the script to remove the secret from | ||
pub script_name: &'a str, | ||
/// the variable name of the secret | ||
pub secret_name: &'a str, | ||
} | ||
|
||
impl<'a> Endpoint<WorkersSecret> for DeleteSecret<'a> { | ||
fn method(&self) -> Method { | ||
Method::Delete | ||
} | ||
fn path(&self) -> String { | ||
format!( | ||
"accounts/{}/workers/scripts/{}/secrets/{}", | ||
self.account_identifier, self.script_name, self.secret_name | ||
) | ||
} | ||
} |
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,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 | ||
) | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to think that these should be owned strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by these? @ashleymichal how should we apply this suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically turn
&'a str
into aString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't do this anywhere else :-\
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sssilver i actually started turning all of these
&'a str
's into&'static str
's elsewhere in wrangler. saves the requirement for lifetimes on all your structs and their methods. will illustrate in another pr.