Commit c89fd3cf authored by Nugine's avatar Nugine
Browse files

feat(codegen): update model

parent 19cf691f
Loading
Loading
Loading
Loading
+65 −34
Original line number Diff line number Diff line
@@ -669,6 +669,7 @@ impl AwsConversion for s3s::dto::CompleteMultipartUploadInput {
            checksum_sha1: try_from_aws(x.checksum_sha1)?,
            checksum_sha256: try_from_aws(x.checksum_sha256)?,
            expected_bucket_owner: try_from_aws(x.expected_bucket_owner)?,
            if_none_match: try_from_aws(x.if_none_match)?,
            key: unwrap_from_aws(x.key, "key")?,
            multipart_upload: try_from_aws(x.multipart_upload)?,
            request_payer: try_from_aws(x.request_payer)?,
@@ -687,6 +688,7 @@ impl AwsConversion for s3s::dto::CompleteMultipartUploadInput {
        y = y.set_checksum_sha1(try_into_aws(x.checksum_sha1)?);
        y = y.set_checksum_sha256(try_into_aws(x.checksum_sha256)?);
        y = y.set_expected_bucket_owner(try_into_aws(x.expected_bucket_owner)?);
        y = y.set_if_none_match(try_into_aws(x.if_none_match)?);
        y = y.set_key(Some(try_into_aws(x.key)?));
        y = y.set_multipart_upload(try_into_aws(x.multipart_upload)?);
        y = y.set_request_payer(try_into_aws(x.request_payer)?);
@@ -2557,12 +2559,14 @@ impl AwsConversion for s3s::dto::GetBucketLifecycleConfigurationOutput {
    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        Ok(Self {
            rules: try_from_aws(x.rules)?,
            transition_default_minimum_object_size: try_from_aws(x.transition_default_minimum_object_size)?,
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        let mut y = Self::Target::builder();
        y = y.set_rules(try_into_aws(x.rules)?);
        y = y.set_transition_default_minimum_object_size(try_into_aws(x.transition_default_minimum_object_size)?);
        Ok(y.build())
    }
}
@@ -4338,25 +4342,23 @@ impl AwsConversion for s3s::dto::LifecycleRuleFilter {
    type Error = S3Error;

    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        Ok(match x {
            aws_sdk_s3::types::LifecycleRuleFilter::And(v) => Self::And(try_from_aws(v)?),
            aws_sdk_s3::types::LifecycleRuleFilter::ObjectSizeGreaterThan(v) => Self::ObjectSizeGreaterThan(try_from_aws(v)?),
            aws_sdk_s3::types::LifecycleRuleFilter::ObjectSizeLessThan(v) => Self::ObjectSizeLessThan(try_from_aws(v)?),
            aws_sdk_s3::types::LifecycleRuleFilter::Prefix(v) => Self::Prefix(try_from_aws(v)?),
            aws_sdk_s3::types::LifecycleRuleFilter::Tag(v) => Self::Tag(try_from_aws(v)?),
            _ => unimplemented!("unknown variant of aws_sdk_s3::types::LifecycleRuleFilter: {x:?}"),
        Ok(Self {
            and: try_from_aws(x.and)?,
            object_size_greater_than: try_from_aws(x.object_size_greater_than)?,
            object_size_less_than: try_from_aws(x.object_size_less_than)?,
            prefix: try_from_aws(x.prefix)?,
            tag: try_from_aws(x.tag)?,
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        Ok(match x {
            Self::And(v) => aws_sdk_s3::types::LifecycleRuleFilter::And(try_into_aws(v)?),
            Self::ObjectSizeGreaterThan(v) => aws_sdk_s3::types::LifecycleRuleFilter::ObjectSizeGreaterThan(try_into_aws(v)?),
            Self::ObjectSizeLessThan(v) => aws_sdk_s3::types::LifecycleRuleFilter::ObjectSizeLessThan(try_into_aws(v)?),
            Self::Prefix(v) => aws_sdk_s3::types::LifecycleRuleFilter::Prefix(try_into_aws(v)?),
            Self::Tag(v) => aws_sdk_s3::types::LifecycleRuleFilter::Tag(try_into_aws(v)?),
            _ => unimplemented!("unknown variant of LifecycleRuleFilter: {x:?}"),
        })
        let mut y = Self::Target::builder();
        y = y.set_and(try_into_aws(x.and)?);
        y = y.set_object_size_greater_than(try_into_aws(x.object_size_greater_than)?);
        y = y.set_object_size_less_than(try_into_aws(x.object_size_less_than)?);
        y = y.set_prefix(try_into_aws(x.prefix)?);
        y = y.set_tag(try_into_aws(x.tag)?);
        Ok(y.build())
    }
}

@@ -4541,13 +4543,16 @@ impl AwsConversion for s3s::dto::ListBucketsInput {
    type Error = S3Error;

    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        let _ = x;
        Ok(Self {})
        Ok(Self {
            continuation_token: try_from_aws(x.continuation_token)?,
            max_buckets: try_from_aws(x.max_buckets)?,
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        let _ = x;
        let y = Self::Target::builder();
        let mut y = Self::Target::builder();
        y = y.set_continuation_token(try_into_aws(x.continuation_token)?);
        y = y.set_max_buckets(try_into_aws(x.max_buckets)?);
        y.build().map_err(S3Error::internal_error)
    }
}
@@ -4559,6 +4564,7 @@ impl AwsConversion for s3s::dto::ListBucketsOutput {
    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        Ok(Self {
            buckets: try_from_aws(x.buckets)?,
            continuation_token: try_from_aws(x.continuation_token)?,
            owner: try_from_aws(x.owner)?,
        })
    }
@@ -4566,6 +4572,7 @@ impl AwsConversion for s3s::dto::ListBucketsOutput {
    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        let mut y = Self::Target::builder();
        y = y.set_buckets(try_into_aws(x.buckets)?);
        y = y.set_continuation_token(try_into_aws(x.continuation_token)?);
        y = y.set_owner(try_into_aws(x.owner)?);
        Ok(y.build())
    }
@@ -6377,6 +6384,7 @@ impl AwsConversion for s3s::dto::PutBucketLifecycleConfigurationInput {
            checksum_algorithm: try_from_aws(x.checksum_algorithm)?,
            expected_bucket_owner: try_from_aws(x.expected_bucket_owner)?,
            lifecycle_configuration: try_from_aws(x.lifecycle_configuration)?,
            transition_default_minimum_object_size: try_from_aws(x.transition_default_minimum_object_size)?,
        })
    }

@@ -6386,6 +6394,7 @@ impl AwsConversion for s3s::dto::PutBucketLifecycleConfigurationInput {
        y = y.set_checksum_algorithm(try_into_aws(x.checksum_algorithm)?);
        y = y.set_expected_bucket_owner(try_into_aws(x.expected_bucket_owner)?);
        y = y.set_lifecycle_configuration(try_into_aws(x.lifecycle_configuration)?);
        y = y.set_transition_default_minimum_object_size(try_into_aws(x.transition_default_minimum_object_size)?);
        y.build().map_err(S3Error::internal_error)
    }
}
@@ -6395,13 +6404,14 @@ impl AwsConversion for s3s::dto::PutBucketLifecycleConfigurationOutput {
    type Error = S3Error;

    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        let _ = x;
        Ok(Self {})
        Ok(Self {
            transition_default_minimum_object_size: try_from_aws(x.transition_default_minimum_object_size)?,
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        let _ = x;
        let y = Self::Target::builder();
        let mut y = Self::Target::builder();
        y = y.set_transition_default_minimum_object_size(try_into_aws(x.transition_default_minimum_object_size)?);
        Ok(y.build())
    }
}
@@ -6904,6 +6914,7 @@ impl AwsConversion for s3s::dto::PutObjectInput {
            grant_read: try_from_aws(x.grant_read)?,
            grant_read_acp: try_from_aws(x.grant_read_acp)?,
            grant_write_acp: try_from_aws(x.grant_write_acp)?,
            if_none_match: try_from_aws(x.if_none_match)?,
            key: unwrap_from_aws(x.key, "key")?,
            metadata: try_from_aws(x.metadata)?,
            object_lock_legal_hold_status: try_from_aws(x.object_lock_legal_hold_status)?,
@@ -6946,6 +6957,7 @@ impl AwsConversion for s3s::dto::PutObjectInput {
        y = y.set_grant_read(try_into_aws(x.grant_read)?);
        y = y.set_grant_read_acp(try_into_aws(x.grant_read_acp)?);
        y = y.set_grant_write_acp(try_into_aws(x.grant_write_acp)?);
        y = y.set_if_none_match(try_into_aws(x.if_none_match)?);
        y = y.set_key(Some(try_into_aws(x.key)?));
        y = y.set_metadata(try_into_aws(x.metadata)?);
        y = y.set_object_lock_legal_hold_status(try_into_aws(x.object_lock_legal_hold_status)?);
@@ -7457,21 +7469,19 @@ impl AwsConversion for s3s::dto::ReplicationRuleFilter {
    type Error = S3Error;

    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        Ok(match x {
            aws_sdk_s3::types::ReplicationRuleFilter::And(v) => Self::And(try_from_aws(v)?),
            aws_sdk_s3::types::ReplicationRuleFilter::Prefix(v) => Self::Prefix(try_from_aws(v)?),
            aws_sdk_s3::types::ReplicationRuleFilter::Tag(v) => Self::Tag(try_from_aws(v)?),
            _ => unimplemented!("unknown variant of aws_sdk_s3::types::ReplicationRuleFilter: {x:?}"),
        Ok(Self {
            and: try_from_aws(x.and)?,
            prefix: try_from_aws(x.prefix)?,
            tag: try_from_aws(x.tag)?,
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        Ok(match x {
            Self::And(v) => aws_sdk_s3::types::ReplicationRuleFilter::And(try_into_aws(v)?),
            Self::Prefix(v) => aws_sdk_s3::types::ReplicationRuleFilter::Prefix(try_into_aws(v)?),
            Self::Tag(v) => aws_sdk_s3::types::ReplicationRuleFilter::Tag(try_into_aws(v)?),
            _ => unimplemented!("unknown variant of ReplicationRuleFilter: {x:?}"),
        })
        let mut y = Self::Target::builder();
        y = y.set_and(try_into_aws(x.and)?);
        y = y.set_prefix(try_into_aws(x.prefix)?);
        y = y.set_tag(try_into_aws(x.tag)?);
        Ok(y.build())
    }
}

@@ -8398,6 +8408,27 @@ impl AwsConversion for s3s::dto::Transition {
    }
}

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

    fn try_from_aws(x: Self::Target) -> S3Result<Self> {
        Ok(match x {
            aws_sdk_s3::types::TransitionDefaultMinimumObjectSize::AllStorageClasses128k => {
                Self::from_static(Self::ALL_STORAGE_CLASSES_128K)
            }
            aws_sdk_s3::types::TransitionDefaultMinimumObjectSize::VariesByStorageClass => {
                Self::from_static(Self::VARIES_BY_STORAGE_CLASS)
            }
            _ => Self::from(x.as_str().to_owned()),
        })
    }

    fn try_into_aws(x: Self) -> S3Result<Self::Target> {
        Ok(aws_sdk_s3::types::TransitionDefaultMinimumObjectSize::from(x.as_str()))
    }
}

impl AwsConversion for s3s::dto::TransitionStorageClass {
    type Target = aws_sdk_s3::types::TransitionStorageClass;
    type Error = S3Error;
+7 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ impl S3 for Proxy {
        b = b.set_checksum_sha1(try_into_aws(input.checksum_sha1)?);
        b = b.set_checksum_sha256(try_into_aws(input.checksum_sha256)?);
        b = b.set_expected_bucket_owner(try_into_aws(input.expected_bucket_owner)?);
        b = b.set_if_none_match(try_into_aws(input.if_none_match)?);
        b = b.set_key(Some(try_into_aws(input.key)?));
        b = b.set_multipart_upload(try_into_aws(input.multipart_upload)?);
        b = b.set_request_payer(try_into_aws(input.request_payer)?);
@@ -1433,7 +1434,10 @@ impl S3 for Proxy {
    ) -> S3Result<S3Response<s3s::dto::ListBucketsOutput>> {
        let input = req.input;
        debug!(?input);
        let result = self.0.list_buckets().send().await;
        let mut b = self.0.list_buckets();
        b = b.set_continuation_token(try_into_aws(input.continuation_token)?);
        b = b.set_max_buckets(try_into_aws(input.max_buckets)?);
        let result = b.send().await;
        match result {
            Ok(output) => {
                let headers = super::meta::build_headers(&output)?;
@@ -1779,6 +1783,7 @@ impl S3 for Proxy {
        b = b.set_checksum_algorithm(try_into_aws(input.checksum_algorithm)?);
        b = b.set_expected_bucket_owner(try_into_aws(input.expected_bucket_owner)?);
        b = b.set_lifecycle_configuration(try_into_aws(input.lifecycle_configuration)?);
        b = b.set_transition_default_minimum_object_size(try_into_aws(input.transition_default_minimum_object_size)?);
        let result = b.send().await;
        match result {
            Ok(output) => {
@@ -2068,6 +2073,7 @@ impl S3 for Proxy {
        b = b.set_grant_read(try_into_aws(input.grant_read)?);
        b = b.set_grant_read_acp(try_into_aws(input.grant_read_acp)?);
        b = b.set_grant_write_acp(try_into_aws(input.grant_write_acp)?);
        b = b.set_if_none_match(try_into_aws(input.if_none_match)?);
        b = b.set_key(Some(try_into_aws(input.key)?));
        b = b.set_metadata(try_into_aws(input.metadata)?);
        b = b.set_object_lock_legal_hold_status(try_into_aws(input.object_lock_legal_hold_status)?);
+741 −285

File changed.

Preview size limit exceeded, changes collapsed.

+3 −0
Original line number Diff line number Diff line
@@ -282,6 +282,9 @@ pub const X_AMZ_TAGGING_COUNT: HeaderName = HeaderName::from_static("x-amz-taggi

pub const X_AMZ_TAGGING_DIRECTIVE: HeaderName = HeaderName::from_static("x-amz-tagging-directive");

pub const X_AMZ_TRANSITION_DEFAULT_MINIMUM_OBJECT_SIZE: HeaderName =
    HeaderName::from_static("x-amz-transition-default-minimum-object-size");

pub const X_AMZ_VERSION_ID: HeaderName = HeaderName::from_static("x-amz-version-id");

pub const X_AMZ_WEBSITE_REDIRECT_LOCATION: HeaderName = HeaderName::from_static("x-amz-website-redirect-location");
+53 −4
Original line number Diff line number Diff line
@@ -289,6 +289,16 @@ impl http::TryIntoHeaderValue for TaggingDirective {
    }
}

impl http::TryIntoHeaderValue for TransitionDefaultMinimumObjectSize {
    type Error = http::InvalidHeaderValue;
    fn try_into_header_value(self) -> Result<http::HeaderValue, Self::Error> {
        match Cow::from(self) {
            Cow::Borrowed(s) => http::HeaderValue::try_from(s),
            Cow::Owned(s) => http::HeaderValue::try_from(s),
        }
    }
}

impl http::TryFromHeaderValue for ArchiveStatus {
    type Error = http::ParseHeaderError;
    fn try_from_header_value(val: &http::HeaderValue) -> Result<Self, Self::Error> {
@@ -433,6 +443,14 @@ impl http::TryFromHeaderValue for TaggingDirective {
    }
}

impl http::TryFromHeaderValue for TransitionDefaultMinimumObjectSize {
    type Error = http::ParseHeaderError;
    fn try_from_header_value(val: &http::HeaderValue) -> Result<Self, Self::Error> {
        let val = val.to_str().map_err(|_| http::ParseHeaderError::Enum)?;
        Ok(Self::from(val.to_owned()))
    }
}

pub struct AbortMultipartUpload;

impl AbortMultipartUpload {
@@ -502,6 +520,8 @@ impl CompleteMultipartUpload {

        let expected_bucket_owner: Option<AccountId> = http::parse_opt_header(req, &X_AMZ_EXPECTED_BUCKET_OWNER)?;

        let if_none_match: Option<IfNoneMatch> = http::parse_opt_header(req, &IF_NONE_MATCH)?;

        let multipart_upload: Option<CompletedMultipartUpload> = http::take_opt_xml_body(req)?;

        let request_payer: Option<RequestPayer> = http::parse_opt_header(req, &X_AMZ_REQUEST_PAYER)?;
@@ -523,6 +543,7 @@ impl CompleteMultipartUpload {
            checksum_sha1,
            checksum_sha256,
            expected_bucket_owner,
            if_none_match,
            key,
            multipart_upload,
            request_payer,
@@ -2145,6 +2166,11 @@ impl GetBucketLifecycleConfiguration {
    pub fn serialize_http(x: GetBucketLifecycleConfigurationOutput) -> S3Result<http::Response> {
        let mut res = http::Response::with_status(http::StatusCode::OK);
        http::set_xml_body(&mut res, &x)?;
        http::add_opt_header(
            &mut res,
            X_AMZ_TRANSITION_DEFAULT_MINIMUM_OBJECT_SIZE,
            x.transition_default_minimum_object_size,
        )?;
        Ok(res)
    }
}
@@ -3727,8 +3753,15 @@ impl super::Operation for ListBucketMetricsConfigurations {
pub struct ListBuckets;

impl ListBuckets {
    pub fn deserialize_http(_: &mut http::Request) -> S3Result<ListBucketsInput> {
        Ok(ListBucketsInput {})
    pub fn deserialize_http(req: &mut http::Request) -> S3Result<ListBucketsInput> {
        let continuation_token: Option<Token> = http::parse_opt_query(req, "continuation-token")?;

        let max_buckets: Option<MaxBuckets> = http::parse_opt_query(req, "max-buckets")?;

        Ok(ListBucketsInput {
            continuation_token,
            max_buckets,
        })
    }

    pub fn serialize_http(x: ListBucketsOutput) -> S3Result<http::Response> {
@@ -4506,16 +4539,26 @@ impl PutBucketLifecycleConfiguration {

        let lifecycle_configuration: Option<BucketLifecycleConfiguration> = http::take_opt_xml_body(req)?;

        let transition_default_minimum_object_size: Option<TransitionDefaultMinimumObjectSize> =
            http::parse_opt_header(req, &X_AMZ_TRANSITION_DEFAULT_MINIMUM_OBJECT_SIZE)?;

        Ok(PutBucketLifecycleConfigurationInput {
            bucket,
            checksum_algorithm,
            expected_bucket_owner,
            lifecycle_configuration,
            transition_default_minimum_object_size,
        })
    }

    pub fn serialize_http(_: PutBucketLifecycleConfigurationOutput) -> S3Result<http::Response> {
        Ok(http::Response::with_status(http::StatusCode::OK))
    pub fn serialize_http(x: PutBucketLifecycleConfigurationOutput) -> S3Result<http::Response> {
        let mut res = http::Response::with_status(http::StatusCode::OK);
        http::add_opt_header(
            &mut res,
            X_AMZ_TRANSITION_DEFAULT_MINIMUM_OBJECT_SIZE,
            x.transition_default_minimum_object_size,
        )?;
        Ok(res)
    }
}

@@ -5129,6 +5172,8 @@ impl PutObject {

        let grant_write_acp: Option<GrantWriteACP> = http::parse_opt_header(req, &X_AMZ_GRANT_WRITE_ACP)?;

        let if_none_match: Option<IfNoneMatch> = http::parse_opt_header(req, &IF_NONE_MATCH)?;

        let metadata: Option<Metadata> = http::parse_opt_metadata(req)?;

        let object_lock_legal_hold_status: Option<ObjectLockLegalHoldStatus> =
@@ -5186,6 +5231,7 @@ impl PutObject {
            grant_read,
            grant_read_acp,
            grant_write_acp,
            if_none_match,
            key,
            metadata,
            object_lock_legal_hold_status,
@@ -5255,6 +5301,8 @@ impl PutObject {

        let grant_write_acp: Option<GrantWriteACP> = http::parse_field_value(&m, "x-amz-grant-write-acp")?;

        let if_none_match: Option<IfNoneMatch> = http::parse_field_value(&m, "if-none-match")?;

        let metadata: Option<Metadata> = {
            let mut metadata = Metadata::default();
            for (name, value) in m.fields() {
@@ -5327,6 +5375,7 @@ impl PutObject {
            grant_read,
            grant_read_acp,
            grant_write_acp,
            if_none_match,
            key,
            metadata,
            object_lock_legal_hold_status,
Loading