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

aws_sdk_eventbridge does not re-export HttpResponse #3591

Open
SAdams601 opened this issue Apr 18, 2024 · 7 comments
Open

aws_sdk_eventbridge does not re-export HttpResponse #3591

SAdams601 opened this issue Apr 18, 2024 · 7 comments
Assignees

Comments

@SAdams601
Copy link

aws_sdk_eventbridge::operation::put_events::builders::PutEventsFluentBuilder::send returns a Result<PutEventsOutput, SdkError<PutEventsError, HttpResponse>> but HttpResponse is not available without adding the aws-smithy-runtime-api crate as a dependency.

@jdisanti
Copy link
Collaborator

To solve your immediate problem, if you import SdkError from aws_sdk_eventbridge::error::SdkError, it should have the generic already set: https://docs.rs/aws-sdk-eventbridge/latest/aws_sdk_eventbridge/error/type.SdkError.html

@SAdams601
Copy link
Author

I returning the result of the send call from a function so I need to reference the type in the return type of that function.

@jdisanti
Copy link
Collaborator

Yes. It's defaulted in the SdkError type that is re-exported in aws-sdk-eventbridge, so you don't actually need to reference it.

@klawson88
Copy link

The solution which @jdisanti proposed is fine if one needs to use SdkError in a type annotation, but it does not help when one is looking to construct an instance of the type. My use case, for instance, requires me to do so to produce a fake return value in a test, without the complexity of the recommended solution to mock such a value.

@aajtodd
Copy link
Contributor

aajtodd commented Jun 24, 2024

SdkError and it's constructor functions are public. You should be able to use them to create an instance.

@klawson88
Copy link

klawson88 commented Jun 24, 2024

Can that approach be used to construct variants with the raw component (i.e the R type parameter), where that component is the same type used by the SDK (ex. HttpResponse)? It seems like that not is possible without importing aws-smithy-runtime-api, since those raw types are not re-exported by the service-level packages (in my case, it was aws-sdk-s3).

@JuiceDrinker
Copy link

Have the same use-case as @klawson88. Would like to create a wrapper around aws-sdk-s3 which requires me to type my wrapper function explicilty asResult<GetObjectOutput, SdkError<GetObjectError, HttpResponse>> which is seemingly not possible without importing aws-smithy-runtime-api

github-merge-queue bot pushed a commit that referenced this issue Jul 15, 2024
## Motivation and Context
#3591

## Description
In early days of smithy-rs, we used to re-export
[Request](https://docs.rs/aws-sdk-s3/0.25.0/aws_sdk_s3/client/customize/struct.Request.html)
and
[Response](https://docs.rs/aws-sdk-s3/0.25.0/aws_sdk_s3/client/customize/struct.Request.html)
types. When we overhauled the underlying smithy runtime from middleware
to orchestrator, we did not re-export the corresponding types
[HttpRequest](https://docs.rs/aws-smithy-runtime-api/latest/aws_smithy_runtime_api/client/orchestrator/type.HttpRequest.html)
and
[HttpResponse](https://docs.rs/aws-smithy-runtime-api/latest/aws_smithy_runtime_api/client/orchestrator/type.HttpResponse.html)
to client crates.

This PR will re-export them in `crate::config::http`.

## Testing
Added a new test file for `ClientRuntimeTypesReExportGenerator.kt` that
verifies re-exports.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants