Skip to content

Commit

Permalink
Move RequestId to aws-types (#3160)
Browse files Browse the repository at this point in the history
This PR moves `RequestId` into the aws-types stable crate.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
jdisanti authored Nov 11, 2023
1 parent a94a5e0 commit d4e2745
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 53 deletions.
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

0 comments on commit d4e2745

Please sign in to comment.