Skip to content

Commit

Permalink
feat(codegen/error): add ReplicationConfigurationNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
Nugine committed Dec 12, 2024
1 parent 09fae30 commit 42a00af
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
20 changes: 20 additions & 0 deletions codegen/src/v1/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,29 @@ fn collect_errors(model: &smithy::Model) -> Errors {
err.status.push(status);
}

patch_extra_errors(&mut errors);

errors
}

// https://github.com/Nugine/s3s/issues/224
fn patch_extra_errors(errors: &mut Errors) {
// https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ReplicationErrorCodeList
{
let code = "ReplicationConfigurationNotFoundError";
let desc = "There is no replication configuration for this bucket.";
let status = "404 Not Found";
errors.insert(
code.to_owned(),
Error {
code: code.to_owned(),
description: vec![Some(desc.to_owned())],
status: vec![Some(status.to_owned())],
},
);
}
}

#[allow(clippy::too_many_lines)]
pub fn codegen(model: &smithy::Model) {
let errors = collect_errors(model);
Expand Down
40 changes: 25 additions & 15 deletions crates/s3s/src/error/generated.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Auto generated by `codegen/src/v1/error.rs:127`
//! Auto generated by `codegen/src/v1/error.rs:147`
#![allow(clippy::doc_markdown)]

Expand Down Expand Up @@ -407,6 +407,12 @@ pub enum S3ErrorCode {
///
Redirect,

/// There is no replication configuration for this bucket.
///
/// HTTP Status Code: 404 Not Found
///
ReplicationConfigurationNotFoundError,

/// Bucket POST must be of the enclosure-type multipart/form-data.
///
/// HTTP Status Code: 400 Bad Request
Expand Down Expand Up @@ -562,6 +568,7 @@ impl S3ErrorCode {
"PermanentRedirect",
"PreconditionFailed",
"Redirect",
"ReplicationConfigurationNotFoundError",
"RequestIsNotMultiPartContent",
"RequestTimeTooSkewed",
"RequestTimeout",
Expand Down Expand Up @@ -647,20 +654,21 @@ impl S3ErrorCode {
Self::PermanentRedirect => 63,
Self::PreconditionFailed => 64,
Self::Redirect => 65,
Self::RequestIsNotMultiPartContent => 66,
Self::RequestTimeTooSkewed => 67,
Self::RequestTimeout => 68,
Self::RequestTorrentOfBucketError => 69,
Self::RestoreAlreadyInProgress => 70,
Self::ServiceUnavailable => 71,
Self::SignatureDoesNotMatch => 72,
Self::SlowDown => 73,
Self::TemporaryRedirect => 74,
Self::TokenRefreshRequired => 75,
Self::TooManyBuckets => 76,
Self::UnexpectedContent => 77,
Self::UnresolvableGrantByEmailAddress => 78,
Self::UserKeyMustBeSpecified => 79,
Self::ReplicationConfigurationNotFoundError => 66,
Self::RequestIsNotMultiPartContent => 67,
Self::RequestTimeTooSkewed => 68,
Self::RequestTimeout => 69,
Self::RequestTorrentOfBucketError => 70,
Self::RestoreAlreadyInProgress => 71,
Self::ServiceUnavailable => 72,
Self::SignatureDoesNotMatch => 73,
Self::SlowDown => 74,
Self::TemporaryRedirect => 75,
Self::TokenRefreshRequired => 76,
Self::TooManyBuckets => 77,
Self::UnexpectedContent => 78,
Self::UnresolvableGrantByEmailAddress => 79,
Self::UserKeyMustBeSpecified => 80,
Self::Custom(_) => usize::MAX,
}
}
Expand Down Expand Up @@ -738,6 +746,7 @@ impl S3ErrorCode {
b"PermanentRedirect" => Some(Self::PermanentRedirect),
b"PreconditionFailed" => Some(Self::PreconditionFailed),
b"Redirect" => Some(Self::Redirect),
b"ReplicationConfigurationNotFoundError" => Some(Self::ReplicationConfigurationNotFoundError),
b"RequestIsNotMultiPartContent" => Some(Self::RequestIsNotMultiPartContent),
b"RequestTimeTooSkewed" => Some(Self::RequestTimeTooSkewed),
b"RequestTimeout" => Some(Self::RequestTimeout),
Expand Down Expand Up @@ -826,6 +835,7 @@ impl S3ErrorCode {
Self::PermanentRedirect => Some(StatusCode::MOVED_PERMANENTLY),
Self::PreconditionFailed => Some(StatusCode::PRECONDITION_FAILED),
Self::Redirect => Some(StatusCode::TEMPORARY_REDIRECT),
Self::ReplicationConfigurationNotFoundError => Some(StatusCode::NOT_FOUND),
Self::RequestIsNotMultiPartContent => Some(StatusCode::BAD_REQUEST),
Self::RequestTimeTooSkewed => Some(StatusCode::FORBIDDEN),
Self::RequestTimeout => Some(StatusCode::BAD_REQUEST),
Expand Down

0 comments on commit 42a00af

Please sign in to comment.