-
Notifications
You must be signed in to change notification settings - Fork 108
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
Support moving an object #284
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
493815e
support operation on object
97b4d41
rust fmt
27a281e
add comments
c6a9146
increment version
9f2e42a
fix typo
cd095ab
Merge branch 'yoshidan:main' into feature/move-object
pratimsc 0940c2c
optimize code and return early
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 |
---|---|---|
|
@@ -13,3 +13,6 @@ Cargo.lock | |
# Added by cargo | ||
|
||
/target | ||
|
||
# IDE | ||
.idea |
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
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,89 @@ | ||
use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder}; | ||
|
||
use crate::http::objects::copy::CopyObjectRequest; | ||
use crate::http::objects::delete::DeleteObjectRequest; | ||
use crate::http::objects::{Encryption, Object}; | ||
use crate::http::{object_access_controls::Projection, Escape}; | ||
|
||
/// Request message for moving an object. | ||
#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct MoveObjectRequest { | ||
/// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. | ||
pub destination_bucket: String, | ||
/// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any. | ||
pub destination_object: String, | ||
// Name of the source object. For information about how to URL encode object names to be path safe, see Encoding URI path parts. | ||
pub source_object: String, | ||
/// Name of the bucket in which to find the source object. | ||
#[serde(skip_serializing)] | ||
pub source_bucket: String, | ||
|
||
/// Makes the operation conditional on there being a live destination object with a generation number that matches the given value. Setting ifGenerationMatch to 0 makes the operation succeed only if there is no live destination object. | ||
pub if_generation_match: Option<i64>, | ||
/// Makes the operation conditional on there being a live destination object with a generation number that does not match the given value. If no live destination object exists, the precondition fails. Setting ifGenerationNotMatch to 0 makes the operation succeed if there is a live version of the object. | ||
pub if_generation_not_match: Option<i64>, | ||
/// Makes the operation conditional on there being a live destination object with a metageneration number that matches the given value. | ||
pub if_metageneration_match: Option<i64>, | ||
/// Makes the operation conditional on there being a live destination object with a metageneration number that does not match the given value. | ||
pub if_metageneration_not_match: Option<i64>, | ||
/// Makes the operation conditional on whether the source object's generation matches the given value. | ||
pub if_source_generation_match: Option<i64>, | ||
/// Makes the operation conditional on whether the source object's generation does not match the given value. | ||
pub if_source_generation_not_match: Option<i64>, | ||
/// Makes the operation conditional on whether the source object's current metageneration matches the given value. | ||
pub if_source_metageneration_match: Option<i64>, | ||
/// Makes the operation conditional on whether the source object's current metageneration does not match the given value. | ||
pub if_source_metageneration_not_match: Option<i64>, | ||
/// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full. | ||
/// | ||
/// Acceptable values are: | ||
/// full: Include all properties. | ||
/// noAcl: Omit the owner, acl property. | ||
pub projection: Option<Projection>, | ||
/// If present, selects a specific revision of the source object (as opposed to the latest version, the default) | ||
pub source_generation: Option<i64>, | ||
/// The Object metadata for updating. | ||
#[serde(skip_serializing)] | ||
pub metadata: Option<Object>, | ||
|
||
#[serde(skip_serializing)] | ||
pub encryption: Option<Encryption>, | ||
} | ||
|
||
impl From<MoveObjectRequest> for CopyObjectRequest { | ||
fn from(value: MoveObjectRequest) -> Self { | ||
CopyObjectRequest { | ||
destination_bucket: value.destination_bucket, | ||
destination_object: value.destination_object, | ||
source_object: value.source_object, | ||
source_bucket: value.source_bucket, | ||
if_generation_match: value.if_generation_match, | ||
if_generation_not_match: value.if_generation_not_match, | ||
if_metageneration_match: value.if_metageneration_match, | ||
if_metageneration_not_match: value.if_metageneration_not_match, | ||
if_source_generation_match: value.if_source_generation_match, | ||
if_source_generation_not_match: value.if_source_generation_not_match, | ||
if_source_metageneration_match: value.if_source_metageneration_match, | ||
if_source_metageneration_not_match: value.if_source_metageneration_not_match, | ||
projection: value.projection, | ||
source_generation: value.source_generation, | ||
metadata: value.metadata, | ||
encryption: value.encryption, | ||
} | ||
} | ||
} | ||
|
||
impl From<MoveObjectRequest> for DeleteObjectRequest { | ||
fn from(value: MoveObjectRequest) -> Self { | ||
DeleteObjectRequest { | ||
bucket: value.source_bucket, | ||
object: value.source_object, | ||
generation: value.source_generation, | ||
if_generation_match: value.if_source_generation_match, | ||
if_generation_not_match: value.if_source_generation_not_match, | ||
if_metageneration_match: value.if_metageneration_match, | ||
if_metageneration_not_match: value.if_metageneration_not_match, | ||
} | ||
} | ||
} |
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.
Early returns reduce the number of conditional branches.
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.
Thanks @yoshidan , I have actioned it.