-
Notifications
You must be signed in to change notification settings - Fork 124
feat(storage): add with_user_agent to the builder. #4601
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -421,6 +421,25 @@ impl ClientBuilder { | |||||||||||||||||||||
| self | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /// Sets the user-agent. | ||||||||||||||||||||||
|
Contributor
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. To achieve parity with the other client libraries you also need to add google-cloud-rust/src/storage/src/storage/read_object.rs Lines 90 to 93 in c3d99d7
google-cloud-rust/src/storage/src/storage/write_object.rs Lines 85 to 87 in c3d99d7
and google-cloud-rust/src/storage/src/storage/open_object.rs Lines 49 to 51 in c3d99d7
|
||||||||||||||||||||||
| /// | ||||||||||||||||||||||
| /// The user-agent header is set in all requests made by the client. | ||||||||||||||||||||||
| /// | ||||||||||||||||||||||
| /// # Example | ||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||
| /// # use google_cloud_storage::client::Storage; | ||||||||||||||||||||||
| /// # async fn sample() -> anyhow::Result<()> { | ||||||||||||||||||||||
| /// let client = Storage::builder() | ||||||||||||||||||||||
| /// .with_user_agent("my-app/1.0.0") | ||||||||||||||||||||||
| /// .build() | ||||||||||||||||||||||
| /// .await?; | ||||||||||||||||||||||
| /// # Ok(()) } | ||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||
| pub fn with_user_agent<V: Into<String>>(mut self, v: V) -> Self { | ||||||||||||||||||||||
| self.config.user_agent = Some(v.into()); | ||||||||||||||||||||||
| self | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /// Configures the authentication credentials. | ||||||||||||||||||||||
| /// | ||||||||||||||||||||||
| /// Google Cloud Storage requires authentication for most buckets. Use this | ||||||||||||||||||||||
|
|
@@ -783,6 +802,16 @@ pub(crate) mod tests { | |||||||||||||||||||||
| ); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||
| fn user_agent() { | ||||||||||||||||||||||
| let agent = "test-agent/1.0.0"; | ||||||||||||||||||||||
| let builder = ClientBuilder::new() | ||||||||||||||||||||||
| .with_credentials(Anonymous::new().build()) | ||||||||||||||||||||||
| .with_user_agent(agent); | ||||||||||||||||||||||
| let config = builder.config; | ||||||||||||||||||||||
| assert_eq!(config.user_agent, Some(agent.to_string())); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| pub(crate) fn test_builder() -> ClientBuilder { | ||||||||||||||||||||||
| ClientBuilder::new() | ||||||||||||||||||||||
| .with_credentials(Anonymous::new().build()) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.