gcloud_storage/http/objects/
move.rs

1use crate::http::object_access_controls::Projection;
2use crate::http::objects::copy::CopyObjectRequest;
3use crate::http::objects::delete::DeleteObjectRequest;
4use crate::http::objects::{Encryption, Object};
5
6/// Request message for moving an object.
7#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct MoveObjectRequest {
10    /// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.
11    pub destination_bucket: String,
12    /// Name of the new object. Required when the object metadata is not otherwise provided. Overrides the object metadata's name value, if any.
13    pub destination_object: String,
14    // Name of the source object. For information about how to URL encode object names to be path safe, see Encoding URI path parts.
15    pub source_object: String,
16    /// Name of the bucket in which to find the source object.
17    #[serde(skip_serializing)]
18    pub source_bucket: String,
19
20    /// 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.
21    pub if_generation_match: Option<i64>,
22    /// 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.
23    pub if_generation_not_match: Option<i64>,
24    /// Makes the operation conditional on there being a live destination object with a metageneration number that matches the given value.
25    pub if_metageneration_match: Option<i64>,
26    /// Makes the operation conditional on there being a live destination object with a metageneration number that does not match the given value.
27    pub if_metageneration_not_match: Option<i64>,
28    /// Makes the operation conditional on whether the source object's generation matches the given value.
29    pub if_source_generation_match: Option<i64>,
30    /// Makes the operation conditional on whether the source object's generation does not match the given value.
31    pub if_source_generation_not_match: Option<i64>,
32    /// Makes the operation conditional on whether the source object's current metageneration matches the given value.
33    pub if_source_metageneration_match: Option<i64>,
34    /// Makes the operation conditional on whether the source object's current metageneration does not match the given value.
35    pub if_source_metageneration_not_match: Option<i64>,
36    /// Set of properties to return. Defaults to noAcl, unless the object resource specifies the acl property, when it defaults to full.
37    ///
38    /// Acceptable values are:
39    /// full: Include all properties.
40    /// noAcl: Omit the owner, acl property.
41    pub projection: Option<Projection>,
42    /// If present, selects a specific revision of the source object (as opposed to the latest version, the default)
43    pub source_generation: Option<i64>,
44    /// The Object metadata for updating.
45    #[serde(skip_serializing)]
46    pub metadata: Option<Object>,
47
48    #[serde(skip_serializing)]
49    pub encryption: Option<Encryption>,
50}
51
52impl From<MoveObjectRequest> for CopyObjectRequest {
53    fn from(value: MoveObjectRequest) -> Self {
54        CopyObjectRequest {
55            destination_bucket: value.destination_bucket,
56            destination_object: value.destination_object,
57            source_object: value.source_object,
58            source_bucket: value.source_bucket,
59            if_generation_match: value.if_generation_match,
60            if_generation_not_match: value.if_generation_not_match,
61            if_metageneration_match: value.if_metageneration_match,
62            if_metageneration_not_match: value.if_metageneration_not_match,
63            if_source_generation_match: value.if_source_generation_match,
64            if_source_generation_not_match: value.if_source_generation_not_match,
65            if_source_metageneration_match: value.if_source_metageneration_match,
66            if_source_metageneration_not_match: value.if_source_metageneration_not_match,
67            projection: value.projection,
68            source_generation: value.source_generation,
69            metadata: value.metadata,
70            encryption: value.encryption,
71        }
72    }
73}
74
75impl From<MoveObjectRequest> for DeleteObjectRequest {
76    fn from(value: MoveObjectRequest) -> Self {
77        DeleteObjectRequest {
78            bucket: value.source_bucket,
79            object: value.source_object,
80            generation: value.source_generation,
81            if_generation_match: value.if_source_generation_match,
82            if_generation_not_match: value.if_source_generation_not_match,
83            if_metageneration_match: value.if_metageneration_match,
84            if_metageneration_not_match: value.if_metageneration_not_match,
85        }
86    }
87}