Commit 9726e1c3 authored by Nugine's avatar Nugine
Browse files

feat(codegen/dto): patch `Tag`

parent 42a00af3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes) {
            "SelectObjectContentRequest" => continue,
            "SelectObjectContentInput" => continue,
            "AssumeRoleOutput" => continue,
            "Tag" => continue,
            _ if super::sts::NAMES.iter().any(|n| n.eq_ignore_ascii_case(name)) => continue,
            _ => {}
        }
+15 −0
Original line number Diff line number Diff line
@@ -246,6 +246,21 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes
}

fn patch_types(space: &mut RustTypes) {
    // patch Tag
    {
        let Some(rust::Type::Struct(ty)) = space.get_mut("Tag") else { panic!() };
        for field in &mut ty.fields {
            if field.name == "key" {
                field.is_required = false;
                field.option_type = true;
            }
            if field.name == "value" {
                field.is_required = false;
                field.option_type = true;
            }
        }
    }

    // patch LifecycleExpiration
    {
        let Some(rust::Type::Struct(ty)) = space.get_mut("LifecycleExpiration") else { panic!() };
+20 −0
Original line number Diff line number Diff line
@@ -191,3 +191,23 @@ impl AwsConversion for s3s::dto::SelectObjectContentInput {
            .map_err(S3Error::internal_error)
    }
}

impl AwsConversion for s3s::dto::Tag {
    type Target = aws_sdk_s3::types::Tag;

    type Error = S3Error;

    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        Ok(Self {
            key: Some(try_from_aws(x.key)?),
            value: Some(try_from_aws(x.value)?),
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        let mut y = Self::Target::builder();
        y = y.set_key(try_into_aws(x.key)?);
        y = y.set_value(try_into_aws(x.value)?);
        y.build().map_err(S3Error::internal_error)
    }
}
+0 −19
Original line number Diff line number Diff line
@@ -8236,25 +8236,6 @@ impl AwsConversion for s3s::dto::StorageClassAnalysisSchemaVersion {
    }
}

impl AwsConversion for s3s::dto::Tag {
    type Target = aws_sdk_s3::types::Tag;
    type Error = S3Error;

    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        Ok(Self {
            key: try_from_aws(x.key)?,
            value: try_from_aws(x.value)?,
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        let mut y = Self::Target::builder();
        y = y.set_key(Some(try_into_aws(x.key)?));
        y = y.set_value(Some(try_into_aws(x.value)?));
        y.build().map_err(S3Error::internal_error)
    }
}

impl AwsConversion for s3s::dto::Tagging {
    type Target = aws_sdk_s3::types::Tagging;
    type Error = S3Error;
+10 −6
Original line number Diff line number Diff line
//! Auto generated by `codegen/src/v1/dto.rs:354`
//! Auto generated by `codegen/src/v1/dto.rs:369`
#![allow(clippy::empty_structs_with_brackets)]
#![allow(clippy::too_many_lines)]
@@ -18349,19 +18349,23 @@ impl FromStr for StorageClassAnalysisSchemaVersion {
pub type Suffix = String;
/// <p>A container of a key value name pair.</p>
#[derive(Clone, PartialEq)]
#[derive(Clone, Default, PartialEq)]
pub struct Tag {
    /// <p>Name of the object key.</p>
    pub key: ObjectKey,
    pub key: Option<ObjectKey>,
    /// <p>Value of the tag.</p>
    pub value: Value,
    pub value: Option<Value>,
}
impl fmt::Debug for Tag {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let mut d = f.debug_struct("Tag");
        d.field("key", &self.key);
        d.field("value", &self.value);
        if let Some(ref val) = self.key {
            d.field("key", val);
        }
        if let Some(ref val) = self.value {
            d.field("value", val);
        }
        d.finish_non_exhaustive()
    }
}
Loading