-
Notifications
You must be signed in to change notification settings - Fork 190
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
Add support for endpoints.json #468
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f27c2af
Add support for endpoints.json
rcoh e0585d2
Backout Smithy 1.8 changes
rcoh b15f954
Delete DefaultAwsEndpoint resolver
rcoh 9677f1b
Add test for iam / fips
rcoh f0a796f
Merge branch 'main' of github.com:awslabs/smithy-rs into endpoints-do…
rcoh 36bdc85
IAM works now
rcoh 5e77339
CR feedback
rcoh 463ed8f
Fix tests
rcoh 2206d6c
CR feedback
rcoh 45b4dc0
Merge branch 'main' into endpoints-dot-json
rcoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
use crate::{AwsEndpoint, BoxError, CredentialScope, ResolveAwsEndpoint}; | ||
use aws_types::region::Region; | ||
use smithy_http::endpoint::Endpoint; | ||
|
||
pub type CompleteEndpoint = Definition; | ||
|
||
/// Endpoint metadata | ||
/// | ||
/// T & P exist to support optional vs. non optional values for Protocol and URI template during | ||
/// merging | ||
#[derive(Debug)] | ||
pub struct Definition { | ||
/// URI for the endpoint. | ||
/// | ||
/// May contain `{region}` which will replaced with the region during endpoint construction | ||
pub uri_template: &'static str, | ||
|
||
/// Protocol to use for this endpoint | ||
pub protocol: Protocol, | ||
|
||
/// Credential scope to set for requests to this endpoint | ||
pub credential_scope: CredentialScope, | ||
|
||
/// Signature versions supported by this endpoint. | ||
/// | ||
/// Currently unused since the SDK only supports SigV4 | ||
pub signature_versions: SignatureVersion, | ||
} | ||
|
||
#[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||
pub enum Protocol { | ||
Http, | ||
Https, | ||
} | ||
|
||
impl Protocol { | ||
fn as_str(&self) -> &'static str { | ||
match self { | ||
Protocol::Http => "http", | ||
Protocol::Https => "https", | ||
} | ||
} | ||
} | ||
|
||
#[derive(Eq, PartialEq, Copy, Clone, Debug)] | ||
pub enum SignatureVersion { | ||
V4, | ||
} | ||
|
||
impl ResolveAwsEndpoint for CompleteEndpoint { | ||
fn resolve_endpoint(&self, region: &Region) -> Result<AwsEndpoint, BoxError> { | ||
let uri = self.uri_template.replace("{region}", region.as_ref()); | ||
let uri = format!("{}://{}", self.protocol.as_str(), uri); | ||
let endpoint = Endpoint::mutable(uri.parse()?); | ||
let ep = AwsEndpoint { | ||
endpoint, | ||
credential_scope: CredentialScope { | ||
service: self.credential_scope.service.clone(), | ||
region: self | ||
.credential_scope | ||
.region | ||
.clone() | ||
.or_else(|| Some(region.clone().into())), | ||
}, | ||
}; | ||
Ok(ep) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated comment?