Skip to content
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

Move RequestId to aws-types #3160

Merged
merged 4 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,9 @@ message = "ProvideCredentials and SharedCredentialsProvider are now re-exported.
references = ["smithy-rs#3173", "smithy-rs#3155"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "rcoh"

[[aws-sdk-rust]]
message = "The `RequestId` trait has moved from the aws-http crate into aws-types."
references = ["smithy-rs#3160"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "jdisanti"
3 changes: 1 addition & 2 deletions aws/rust-runtime/aws-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ license = "Apache-2.0"
repository = "https://github.com/smithy-lang/smithy-rs"

[dependencies]
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http" }
aws-smithy-runtime-api = { path = "../../../rust-runtime/aws-smithy-runtime-api", features = ["client"] }
aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types" }
aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types", features = ["http-body-0-4-x"] }
aws-types = { path = "../aws-types" }
bytes = "1.1"
http = "0.2.3"
Expand Down
3 changes: 0 additions & 3 deletions aws/rust-runtime/aws-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ pub mod user_agent;

/// AWS-specific content-encoding tools
pub mod content_encoding;

/// AWS-specific request ID support
pub mod request_id;
10 changes: 3 additions & 7 deletions aws/rust-runtime/aws-inlineable/src/s3_request_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

use aws_smithy_http::http::HttpHeaders;
use aws_smithy_runtime_api::client::result::SdkError;
use aws_smithy_runtime_api::http::{Headers, Response};
use aws_smithy_types::error::metadata::{
Expand All @@ -21,14 +20,11 @@ pub trait RequestIdExt {
fn extended_request_id(&self) -> Option<&str>;
}

impl<E, R> RequestIdExt for SdkError<E, R>
where
R: HttpHeaders,
{
impl<E> RequestIdExt for SdkError<E, Response> {
fn extended_request_id(&self) -> Option<&str> {
match self {
Self::ResponseError(err) => err.raw().http_headers().extended_request_id(),
Self::ServiceError(err) => err.raw().http_headers().extended_request_id(),
Self::ResponseError(err) => err.raw().headers().extended_request_id(),
Self::ServiceError(err) => err.raw().headers().extended_request_id(),
_ => None,
}
}
Expand Down
2 changes: 2 additions & 0 deletions aws/rust-runtime/aws-types/external-types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ allowed_external_types = [
"aws_smithy_runtime_api::client::http::SharedHttpClient",
"aws_smithy_runtime_api::client::identity::ResolveCachedIdentity",
"aws_smithy_runtime_api::client::identity::SharedIdentityCache",
"aws_smithy_runtime_api::http::headers::Headers",
"aws_smithy_types::config_bag::storable::Storable",
"aws_smithy_types::config_bag::storable::StoreReplace",
"aws_smithy_types::config_bag::storable::Storer",
"aws_smithy_types::error::metadata::Builder",
"aws_smithy_types::retry::RetryConfig",
"aws_smithy_types::timeout::TimeoutConfig",
]
1 change: 1 addition & 0 deletions aws/rust-runtime/aws-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod endpoint_config;
#[doc(hidden)]
pub mod os_shim_internal;
pub mod region;
pub mod request_id;
pub mod sdk_config;
pub use sdk_config::SdkConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

use aws_smithy_http::http::HttpHeaders;
use aws_smithy_runtime_api::client::orchestrator::HttpResponse;
//! AWS-specific request ID support

use aws_smithy_runtime_api::client::result::SdkError;
use aws_smithy_runtime_api::http::Headers;
use aws_smithy_runtime_api::http::Response;
use aws_smithy_types::error::metadata::{
Builder as ErrorMetadataBuilder, ErrorMetadata, ProvideErrorMetadata,
};
Expand All @@ -21,14 +22,11 @@ pub trait RequestId {
fn request_id(&self) -> Option<&str>;
}

impl<E, R> RequestId for SdkError<E, R>
where
R: HttpHeaders,
{
impl<E> RequestId for SdkError<E, Response> {
fn request_id(&self) -> Option<&str> {
match self {
Self::ResponseError(err) => err.raw().http_headers().request_id(),
Self::ServiceError(err) => err.raw().http_headers().request_id(),
Self::ResponseError(err) => err.raw().headers().request_id(),
Self::ServiceError(err) => err.raw().headers().request_id(),
_ => None,
}
}
Expand All @@ -46,7 +44,7 @@ impl RequestId for Unhandled {
}
}

impl RequestId for HttpResponse {
impl<B> RequestId for Response<B> {
fn request_id(&self) -> Option<&str> {
self.headers().request_id()
}
Expand Down Expand Up @@ -84,6 +82,7 @@ pub fn apply_request_id(builder: ErrorMetadataBuilder, headers: &Headers) -> Err
#[cfg(test)]
mod tests {
use super::*;
use aws_smithy_runtime_api::client::orchestrator::HttpResponse;
use aws_smithy_types::body::SdkBody;
use http::{HeaderValue, Response};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AwsRequestIdDecorator : BaseRequestIdDecorator() {
override val accessorFunctionName: String = "request_id"

private fun requestIdModule(codegenContext: ClientCodegenContext): RuntimeType =
AwsRuntimeType.awsHttp(codegenContext.runtimeConfig).resolve("request_id")
AwsRuntimeType.awsTypes(codegenContext.runtimeConfig).resolve("request_id")

override fun accessorTrait(codegenContext: ClientCodegenContext): RuntimeType =
requestIdModule(codegenContext).resolve("RequestId")
Expand Down
30 changes: 0 additions & 30 deletions rust-runtime/aws-smithy-http/src/http.rs

This file was deleted.

1 change: 0 additions & 1 deletion rust-runtime/aws-smithy-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub mod endpoint;
#[doc(hidden)]
pub mod futures_stream_adapter;
pub mod header;
pub mod http;
pub mod label;
pub mod operation;
pub mod query;
Expand Down
Loading